From 30d7f6989a755e0c78187dec32d6cc20dada98f2 Mon Sep 17 00:00:00 2001 From: Miguel Tenorio <46824157+AntiD2ta@users.noreply.github.com> Date: Mon, 13 Oct 2025 22:55:32 +0800 Subject: [PATCH] Update docker build and push workflow --- .github/workflows/docker.yml | 55 ++++++++++++++---------------------- 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 62049a9..d36bf58 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,58 +1,45 @@ name: Docker +# This workflow is triggered on a push to a tag that follows semantic versioning +# e.g., v1.2.3, v2.0.0-rc1 on: push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+**' jobs: - # Set variables that will be available to all builds. - env_vars: + # Build and push the Docker image + build-and-push: runs-on: ubuntu-latest - outputs: - release_version: ${{ steps.release_version.outputs.release_version }} - binary: ${{ steps.binary.outputs.binary }} steps: - - id: release_version - run: | - RELEASE_VERSION=$(echo ${{ github.ref_name }} | sed -e 's/^[vt]//') - echo "release_version=${RELEASE_VERSION}" >> $GITHUB_OUTPUT - - id: binary - run: | - BINARY=$(basename ${{ github.repository }}) - echo "binary=${BINARY}" >> $GITHUB_OUTPUT + - name: Check out repository + uses: actions/checkout@v4 - # Build. - build: - runs-on: ubuntu-latest - needs: [env_vars] - steps: - - name: Check out repository into the Go module directory - uses: actions/checkout@v3 + # This step extracts the version number from the tag + # e.g., if the tag is 'v1.2.3', this will output '1.2.3' + - name: Extract release version + id: release_version + run: | + echo "version=$(echo ${{ github.ref_name }} | sed -e 's/^v//')" >> $GITHUB_OUTPUT - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v4 - with: - context: . - platforms: linux/amd64,linux/arm64/v8 - push: true - tags: wealdtech/ethdo:latest - - - name: build and push on release - uses: docker/build-push-action@v4 - if: ${{ github.event.release.tag_name != '' }} + uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64,linux/arm64/v8 push: true - tags: wealdtech/ethdo:${{ github.event.release.tag_name }} + tags: | + wealdtech/ethdo:${{ steps.release_version.outputs.version }} + wealdtech/ethdo:latest