|
1 | 1 | name: release |
2 | 2 |
|
3 | 3 | on: |
| 4 | + workflow_dispatch: |
4 | 5 | push: |
5 | 6 | tags: |
6 | 7 | - 'v[0-9]+.[0-9]+.[0-9]+*' |
7 | 8 |
|
8 | 9 | permissions: |
9 | 10 | contents: write |
10 | | - id-token: write |
| 11 | + packages: write |
11 | 12 |
|
12 | 13 | jobs: |
13 | | - build-push-images: |
14 | | - name: Build and push images |
15 | | - runs-on: ${{ matrix.runs-on }} |
16 | | - strategy: |
17 | | - matrix: |
18 | | - include: |
19 | | - - dockerfile: Dockerfile |
20 | | - repo: amazonaws.com/cofide/spiffe-enable |
21 | | - platform: linux/amd64 |
22 | | - runs-on: ubuntu-latest |
23 | | - arch: amd64 |
24 | | - - dockerfile: Dockerfile |
25 | | - repo: amazonaws.com/cofide/spiffe-enable |
26 | | - platform: linux/arm64 |
27 | | - runs-on: connect-ci-runner-arm |
28 | | - arch: arm64 |
29 | | - steps: |
30 | | - - name: Checkout |
31 | | - uses: actions/checkout@v4 |
32 | | - - name: Set up Docker Buildx |
33 | | - uses: docker/setup-buildx-action@v3 |
34 | | - - name: Configure AWS credentials |
35 | | - uses: aws-actions/configure-aws-credentials@v4 |
36 | | - with: |
37 | | - role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/connect-ecr-gh-actions-access |
38 | | - role-session-name: connect-ecr-gh-actions-access |
39 | | - aws-region: ${{ secrets.AWS_REGION }} |
40 | | - - name: Login to Amazon ECR |
41 | | - uses: aws-actions/amazon-ecr-login@v2 |
42 | | - - name: Build and push |
43 | | - uses: docker/build-push-action@v6 |
44 | | - with: |
45 | | - context: . |
46 | | - file: ${{ matrix.dockerfile }} |
47 | | - provenance: false # this is a fix needed to be able to merge the images in a new manifest list later on |
48 | | - push: true |
49 | | - platforms: ${{ matrix.platform }} |
50 | | - cache-from: type=gha |
51 | | - cache-to: type=gha,mode=max |
52 | | - tags: ${{format('{0}.dkr.ecr.{1}.{2}:{3}-{4}', secrets.AWS_ACCOUNT_ID, secrets.AWS_REGION, matrix.repo, matrix.arch, github.ref_name)}} |
| 14 | + goreleaser: |
| 15 | + name: Build and Release with GoReleaser |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + fetch-depth: 0 # Required for GoReleaser to generate changelogs |
| 22 | + |
| 23 | + - name: Setup Go |
| 24 | + uses: actions/setup-go@v5 |
| 25 | + with: |
| 26 | + go-version-file: go.mod |
| 27 | + cache: true |
53 | 28 |
|
54 | | - build-merge-arch-images: |
55 | | - runs-on: ubuntu-latest |
56 | | - needs: build-push-images |
57 | | - strategy: |
58 | | - matrix: |
59 | | - include: |
60 | | - - repo: amazonaws.com/cofide/spiffe-enable |
61 | | - steps: |
62 | | - - name: Checkout |
63 | | - uses: actions/checkout@v4 |
64 | | - - name: Set up Docker Buildx |
65 | | - uses: docker/setup-buildx-action@v3 |
66 | | - - name: Configure AWS credentials |
67 | | - uses: aws-actions/configure-aws-credentials@v4 |
68 | | - with: |
69 | | - role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/connect-ecr-gh-actions-access |
70 | | - role-session-name: connect-ecr-gh-actions-access |
71 | | - aws-region: ${{ secrets.AWS_REGION }} |
72 | | - - name: Login to Amazon ECR |
73 | | - uses: aws-actions/amazon-ecr-login@v2 |
74 | | - - name: pull images |
75 | | - run: | |
76 | | - docker pull --platform linux/amd64 ${{format('{0}.dkr.ecr.{1}.{2}:amd64-{3}', secrets.AWS_ACCOUNT_ID, secrets.AWS_REGION, matrix.repo, github.ref_name)}} |
77 | | - docker pull --platform linux/arm64 ${{format('{0}.dkr.ecr.{1}.{2}:arm64-{3}', secrets.AWS_ACCOUNT_ID, secrets.AWS_REGION, matrix.repo, github.ref_name)}} |
78 | | - - name: Merge images |
79 | | - run: | |
80 | | - docker manifest create $IMAGE --amend $IMAGE_AMD64 --amend $IMAGE_ARM64 |
81 | | - docker manifest annotate $IMAGE $IMAGE_AMD64 --os linux --arch amd64 |
82 | | - docker manifest annotate $IMAGE $IMAGE_ARM64 --os linux --arch arm64 |
83 | | - docker manifest push $IMAGE |
84 | | - env: |
85 | | - IMAGE_AMD64: ${{format('{0}.dkr.ecr.{1}.{2}:amd64-{3}', secrets.AWS_ACCOUNT_ID, secrets.AWS_REGION, matrix.repo, github.ref_name)}} |
86 | | - IMAGE_ARM64: ${{format('{0}.dkr.ecr.{1}.{2}:arm64-{3}', secrets.AWS_ACCOUNT_ID, secrets.AWS_REGION, matrix.repo, github.ref_name)}} |
87 | | - IMAGE: ${{format('{0}.dkr.ecr.{1}.{2}:{3}', secrets.AWS_ACCOUNT_ID, secrets.AWS_REGION, matrix.repo, github.ref_name)}} |
| 29 | + - uses: ko-build/[email protected] |
| 30 | + |
| 31 | + - name: Log in to GitHub Container Registry |
| 32 | + uses: docker/login-action@v3 |
| 33 | + with: |
| 34 | + registry: ghcr.io |
| 35 | + username: ${{ github.actor }} |
| 36 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + |
| 38 | + - name: Set up Docker Buildx |
| 39 | + uses: docker/setup-buildx-action@v3 |
| 40 | + |
| 41 | + - name: Run GoReleaser |
| 42 | + uses: goreleaser/goreleaser-action@v6 |
| 43 | + with: |
| 44 | + distribution: goreleaser |
| 45 | + version: '~> v2' |
| 46 | + args: release --clean |
| 47 | + env: |
| 48 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments