|
1 | 1 | name: Docker |
2 | 2 |
|
| 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 |
3 | 5 | on: |
4 | 6 | push: |
| 7 | + tags: |
| 8 | + - 'v[0-9]+.[0-9]+.[0-9]+**' |
5 | 9 |
|
6 | 10 | 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: |
9 | 13 | runs-on: ubuntu-latest |
10 | | - outputs: |
11 | | - release_version: ${{ steps.release_version.outputs.release_version }} |
12 | | - binary: ${{ steps.binary.outputs.binary }} |
13 | 14 | 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 |
22 | 17 |
|
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 |
30 | 24 |
|
31 | 25 | - name: Set up QEMU |
32 | | - uses: docker/setup-qemu-action@v2 |
| 26 | + uses: docker/setup-qemu-action@v3 |
33 | 27 |
|
34 | 28 | - name: Set up Docker Buildx |
35 | | - uses: docker/setup-buildx-action@v2 |
| 29 | + uses: docker/setup-buildx-action@v3 |
36 | 30 |
|
37 | 31 | - name: Login to Docker Hub |
38 | | - uses: docker/login-action@v2 |
| 32 | + uses: docker/login-action@v3 |
39 | 33 | with: |
40 | 34 | username: ${{ secrets.DOCKERHUB_USERNAME }} |
41 | 35 | password: ${{ secrets.DOCKERHUB_TOKEN }} |
42 | 36 |
|
43 | 37 | - 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 |
54 | 39 | with: |
55 | 40 | context: . |
56 | 41 | platforms: linux/amd64,linux/arm64/v8 |
57 | 42 | 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