Skip to content

Commit b450e96

Browse files
authored
Merge pull request #174 from wealdtech/update-docker-workflow
Update docker build and push workflow
2 parents 00ea75e + 30d7f69 commit b450e96

File tree

1 file changed

+21
-34
lines changed

1 file changed

+21
-34
lines changed

.github/workflows/docker.yml

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,45 @@
11
name: Docker
22

3+
# This workflow is triggered on a push to a tag that follows semantic versioning
4+
# e.g., v1.2.3, v2.0.0-rc1
35
on:
46
push:
7+
tags:
8+
- 'v[0-9]+.[0-9]+.[0-9]+**'
59

610
jobs:
7-
# Set variables that will be available to all builds.
8-
env_vars:
11+
# Build and push the Docker image
12+
build-and-push:
913
runs-on: ubuntu-latest
10-
outputs:
11-
release_version: ${{ steps.release_version.outputs.release_version }}
12-
binary: ${{ steps.binary.outputs.binary }}
1314
steps:
14-
- id: release_version
15-
run: |
16-
RELEASE_VERSION=$(echo ${{ github.ref_name }} | sed -e 's/^[vt]//')
17-
echo "release_version=${RELEASE_VERSION}" >> $GITHUB_OUTPUT
18-
- id: binary
19-
run: |
20-
BINARY=$(basename ${{ github.repository }})
21-
echo "binary=${BINARY}" >> $GITHUB_OUTPUT
15+
- name: Check out repository
16+
uses: actions/checkout@v4
2217

23-
# Build.
24-
build:
25-
runs-on: ubuntu-latest
26-
needs: [env_vars]
27-
steps:
28-
- name: Check out repository into the Go module directory
29-
uses: actions/checkout@v3
18+
# This step extracts the version number from the tag
19+
# e.g., if the tag is 'v1.2.3', this will output '1.2.3'
20+
- name: Extract release version
21+
id: release_version
22+
run: |
23+
echo "version=$(echo ${{ github.ref_name }} | sed -e 's/^v//')" >> $GITHUB_OUTPUT
3024
3125
- name: Set up QEMU
32-
uses: docker/setup-qemu-action@v2
26+
uses: docker/setup-qemu-action@v3
3327

3428
- name: Set up Docker Buildx
35-
uses: docker/setup-buildx-action@v2
29+
uses: docker/setup-buildx-action@v3
3630

3731
- name: Login to Docker Hub
38-
uses: docker/login-action@v2
32+
uses: docker/login-action@v3
3933
with:
4034
username: ${{ secrets.DOCKERHUB_USERNAME }}
4135
password: ${{ secrets.DOCKERHUB_TOKEN }}
4236

4337
- name: Build and push
44-
uses: docker/build-push-action@v4
45-
with:
46-
context: .
47-
platforms: linux/amd64,linux/arm64/v8
48-
push: true
49-
tags: wealdtech/ethdo:latest
50-
51-
- name: build and push on release
52-
uses: docker/build-push-action@v4
53-
if: ${{ github.event.release.tag_name != '' }}
38+
uses: docker/build-push-action@v5
5439
with:
5540
context: .
5641
platforms: linux/amd64,linux/arm64/v8
5742
push: true
58-
tags: wealdtech/ethdo:${{ github.event.release.tag_name }}
43+
tags: |
44+
wealdtech/ethdo:${{ steps.release_version.outputs.version }}
45+
wealdtech/ethdo:latest

0 commit comments

Comments
 (0)