|
9 | 9 | permissions: write-all # Necessary for the generate-build-provenance action with containers |
10 | 10 |
|
11 | 11 | jobs: |
12 | | - |
13 | | - build: |
14 | | - |
15 | | - |
16 | | - runs-on: ubuntu-latest |
17 | | - |
18 | | - steps: |
19 | | - - name: Set up latest stable Go |
20 | | - uses: actions/setup-go@v5 |
21 | | - with: |
22 | | - go-version: stable |
23 | | - - name: Set up QEMU |
24 | | - uses: docker/setup-qemu-action@v3 |
25 | | - - name: Docker Login |
26 | | - uses: docker/login-action@v3 |
27 | | - with: |
28 | | - registry: ghcr.io |
29 | | - username: ${{ github.actor }} |
30 | | - password: ${{ secrets.GITHUB_TOKEN }} |
31 | | - - name: Checkout |
32 | | - uses: actions/checkout@v4 |
33 | | - with: |
34 | | - fetch-tags: 1 |
35 | | - fetch-depth: 0 |
36 | | - # Set environment variables required by GoReleaser |
37 | | - - name: Set build environment variables |
38 | | - run: | |
39 | | - echo "GIT_STATE=$(if git diff-index --quiet HEAD --; then echo 'clean'; else echo 'dirty'; fi)" >> $GITHUB_ENV |
40 | | - echo "BUILD_HOST=$(hostname)" >> $GITHUB_ENV |
41 | | - echo "GO_VERSION=$(go version | awk '{print $3}')" >> $GITHUB_ENV |
42 | | - echo "BUILD_USER=$(whoami)" >> $GITHUB_ENV |
43 | | - echo "CGO_ENABLED=0" >> $GITHUB_ENV |
44 | | - |
45 | | - - name: Install Swag |
46 | | - run: go install github.com/swaggo/swag/cmd/swag@latest |
47 | | - |
48 | | - - name: Release with goreleaser |
49 | | - uses: goreleaser/goreleaser-action@v6 |
50 | | - env: |
51 | | - GITHUB_TOKEN: ${{ github.token }} |
52 | | - with: |
53 | | - version: latest |
54 | | - args: release --clean |
55 | | - id: goreleaser |
56 | | - - name: Process goreleaser output |
57 | | - id: process_goreleaser_output |
58 | | - run: | |
59 | | - echo "const fs = require('fs');" > process.js |
60 | | - echo 'const artifacts = ${{ steps.goreleaser.outputs.artifacts }}' >> process.js |
61 | | - echo "const firstNonNullDigest = artifacts.find(artifact => artifact.extra && artifact.extra.Digest != null)?.extra.Digest;" >> process.js |
62 | | - echo "console.log(firstNonNullDigest);" >> process.js |
63 | | - echo "fs.writeFileSync('digest.txt', firstNonNullDigest);" >> process.js |
64 | | - node process.js |
65 | | - echo "digest=$(cat digest.txt)" >> $GITHUB_OUTPUT |
66 | | - - name: Attest Binaries |
67 | | - uses: actions/attest-build-provenance@v1 |
68 | | - with: |
69 | | - subject-path: dist/cloud-init* |
70 | | - - name: generate build provenance |
71 | | - uses: actions/attest-build-provenance@v1 |
72 | | - with: |
73 | | - subject-name: ghcr.io/openchami/cloud-init |
74 | | - subject-digest: ${{ steps.process_goreleaser_output.outputs.digest }} |
75 | | - push-to-registry: true |
| 12 | + release: |
| 13 | + uses: OpenCHAMI/github-actions/.github/workflows/go-build-release.yml@v3.2 |
| 14 | + with: |
| 15 | + cgo-enabled: "1" |
| 16 | + pre-build-commands: | |
| 17 | + go install github.com/swaggo/swag/cmd/swag@latest |
| 18 | + attestation-binary-path: "dist/cloud-init*" |
| 19 | + registry-name: ghcr.io/openchami/cloud-init |
0 commit comments