|
1 | 1 | name: Release |
2 | 2 |
|
3 | | -on: |
4 | | - push: |
5 | | - tags: |
6 | | - # run only against tags that follow semver (https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string) |
7 | | - - 'v[0-9]+.[0-9]+.[0-9]+*' |
8 | | - - 'v[0-9]+.[0-9]+.[0-9]+*.[0-9]+' |
| 3 | +on: push |
| 4 | + |
| 5 | +concurrency: |
| 6 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 7 | + cancel-in-progress: true |
9 | 8 |
|
10 | 9 | permissions: |
11 | 10 | contents: write |
| 11 | + packages: write |
| 12 | + |
| 13 | +env: |
| 14 | + REGISTRY: ghcr.io |
| 15 | + REGISTRY_IMAGE: ghcr.io/0xpolygon/cdk-validium-node |
| 16 | + IMAGE_TAG: v0.6.4+cdk.9 |
12 | 17 |
|
13 | 18 | jobs: |
14 | | - goreleaser: |
| 19 | + build: |
15 | 20 | runs-on: ubuntu-latest |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + platform: |
| 25 | + - linux/amd64 |
| 26 | + - linux/arm64 |
16 | 27 | steps: |
| 28 | + - name: Prepare |
| 29 | + run: | |
| 30 | + platform=${{ matrix.platform }} |
| 31 | + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV |
| 32 | +
|
17 | 33 | - name: Checkout |
18 | 34 | uses: actions/checkout@v4 |
19 | | - with: |
20 | | - fetch-depth: 0 |
21 | | - |
22 | | - - name: Set up Go |
23 | | - uses: actions/setup-go@v5 |
24 | | - with: |
25 | | - go-version: 1.23.7 |
26 | 35 |
|
27 | 36 | - name: Set up QEMU |
28 | 37 | uses: docker/setup-qemu-action@v3 |
29 | 38 |
|
30 | | - - name: Login to DockerHub |
| 39 | + - name: Set up Docker Buildx |
| 40 | + uses: docker/setup-buildx-action@v3 |
| 41 | + |
| 42 | + - name: Login to GitHub Container Registry |
31 | 43 | uses: docker/login-action@v3 |
32 | 44 | with: |
33 | | - username: ${{ secrets.DOCKERHUB_USERNAME }} |
34 | | - password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 45 | + registry: ${{ env.REGISTRY }} |
| 46 | + username: ${{ github.actor }} |
| 47 | + password: ${{ secrets.GITHUB_TOKEN }} |
35 | 48 |
|
36 | | - - name: Run GoReleaser |
37 | | - uses: goreleaser/goreleaser-action@v5 |
| 49 | + - name: Build and push image |
| 50 | + uses: docker/build-push-action@v6 |
38 | 51 | with: |
39 | | - distribution: goreleaser |
40 | | - version: latest |
41 | | - args: release --clean --config=.goreleaser-cdk.yaml |
42 | | - env: |
43 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 52 | + context: . |
| 53 | + push: true |
| 54 | + platforms: ${{ matrix.platform }} |
| 55 | + tags: ${{ env.REGISTRY_IMAGE }}:${{ env.IMAGE_TAG }} |
| 56 | + cache-from: type=gha |
| 57 | + cache-to: type=gha,mode=max |
| 58 | + |
| 59 | + merge: |
| 60 | + runs-on: ubuntu-latest |
| 61 | + needs: |
| 62 | + - build |
| 63 | + steps: |
| 64 | + - name: Set up Docker Buildx |
| 65 | + uses: docker/setup-buildx-action@v3 |
| 66 | + |
| 67 | + - name: Login to GitHub Container Registry |
| 68 | + uses: docker/login-action@v3 |
| 69 | + with: |
| 70 | + registry: ${{ env.REGISTRY }} |
| 71 | + username: ${{ github.actor }} |
| 72 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + |
| 74 | + - name: Create and push manifest |
| 75 | + run: | |
| 76 | + docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:${{ env.IMAGE_TAG }} \ |
| 77 | + ${{ env.REGISTRY_IMAGE }}:${{ env.IMAGE_TAG }}-linux-amd64 \ |
| 78 | + ${{ env.REGISTRY_IMAGE }}:${{ env.IMAGE_TAG }}-linux-arm64 |
| 79 | +
|
| 80 | + - name: Inspect image |
| 81 | + run: | |
| 82 | + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ env.IMAGE_TAG }} |
0 commit comments