Update docker build and push workflow

This commit is contained in:
Miguel Tenorio
2025-10-13 22:55:32 +08:00
committed by GitHub
parent 00ea75e5c8
commit 30d7f6989a

View File

@@ -1,58 +1,45 @@
name: Docker 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: on:
push: push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+**'
jobs: jobs:
# Set variables that will be available to all builds. # Build and push the Docker image
env_vars: build-and-push:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs:
release_version: ${{ steps.release_version.outputs.release_version }}
binary: ${{ steps.binary.outputs.binary }}
steps: steps:
- id: release_version - name: Check out repository
run: | uses: actions/checkout@v4
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
# Build. # This step extracts the version number from the tag
build: # e.g., if the tag is 'v1.2.3', this will output '1.2.3'
runs-on: ubuntu-latest - name: Extract release version
needs: [env_vars] id: release_version
steps: run: |
- name: Check out repository into the Go module directory echo "version=$(echo ${{ github.ref_name }} | sed -e 's/^v//')" >> $GITHUB_OUTPUT
uses: actions/checkout@v3
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v2 uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub - name: Login to Docker Hub
uses: docker/login-action@v2 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push - name: Build and push
uses: docker/build-push-action@v4 uses: docker/build-push-action@v5
with: with:
context: . context: .
platforms: linux/amd64,linux/arm64/v8 platforms: linux/amd64,linux/arm64/v8
push: true push: true
tags: wealdtech/ethdo:latest tags: |
wealdtech/ethdo:${{ steps.release_version.outputs.version }}
- name: build and push on release wealdtech/ethdo:latest
uses: docker/build-push-action@v4
if: ${{ github.event.release.tag_name != '' }}
with:
context: .
platforms: linux/amd64,linux/arm64/v8
push: true
tags: wealdtech/ethdo:${{ github.event.release.tag_name }}