|
| 1 | +# Terraform Provider release workflow. |
1 | 2 | name: Release |
2 | 3 |
|
| 4 | +# This GitHub action creates a release when a tag that matches the pattern |
| 5 | +# "v*" (e.g. v0.1.0) is created. |
3 | 6 | on: |
4 | 7 | push: |
5 | 8 | tags: |
6 | 9 | - 'v*' |
7 | 10 |
|
| 11 | +# Releases need permissions to read and write the repository contents. |
| 12 | +# GitHub considers creating releases and uploading assets as writing contents. |
8 | 13 | permissions: |
9 | 14 | contents: write |
10 | 15 |
|
11 | 16 | jobs: |
12 | | - build: |
13 | | - name: Build |
| 17 | + goreleaser: |
14 | 18 | runs-on: ubuntu-latest |
15 | | - strategy: |
16 | | - matrix: |
17 | | - include: |
18 | | - - goos: linux |
19 | | - goarch: amd64 |
20 | | - - goos: linux |
21 | | - goarch: arm64 |
22 | | - - goos: darwin |
23 | | - goarch: amd64 |
24 | | - - goos: darwin |
25 | | - goarch: arm64 |
26 | | - - goos: windows |
27 | | - goarch: amd64 |
28 | | - |
29 | 19 | steps: |
30 | | - - name: Checkout code |
31 | | - uses: actions/checkout@v4 |
32 | | - |
33 | | - - name: Set up Go |
34 | | - uses: actions/setup-go@v5 |
| 20 | + - uses: actions/checkout@v4 |
35 | 21 | with: |
36 | | - go-version: '1.23' |
37 | | - |
38 | | - - name: Get version from tag |
39 | | - id: version |
40 | | - run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT |
41 | | - |
42 | | - - name: Build binary |
43 | | - env: |
44 | | - GOOS: ${{ matrix.goos }} |
45 | | - GOARCH: ${{ matrix.goarch }} |
46 | | - run: | |
47 | | - BINARY_NAME="terraform-provider-axonops_v${{ steps.version.outputs.VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}" |
48 | | - if [ "${{ matrix.goos }}" = "windows" ]; then |
49 | | - BINARY_NAME="${BINARY_NAME}.exe" |
50 | | - fi |
51 | | - go build -o "${BINARY_NAME}" -ldflags="-s -w" |
52 | | - zip "${BINARY_NAME}.zip" "${BINARY_NAME}" |
53 | | -
|
54 | | - - name: Upload artifact |
55 | | - uses: actions/upload-artifact@v4 |
| 22 | + # Allow goreleaser to access older tag information. |
| 23 | + fetch-depth: 0 |
| 24 | + - uses: actions/setup-go@v5 |
56 | 25 | with: |
57 | | - name: terraform-provider-axonops_${{ matrix.goos }}_${{ matrix.goarch }} |
58 | | - path: "*.zip" |
59 | | - |
60 | | - release: |
61 | | - name: Create Release |
62 | | - needs: build |
63 | | - runs-on: ubuntu-latest |
64 | | - steps: |
65 | | - - name: Checkout code |
66 | | - uses: actions/checkout@v4 |
67 | | - |
68 | | - - name: Download all artifacts |
69 | | - uses: actions/download-artifact@v4 |
| 26 | + go-version-file: 'go.mod' |
| 27 | + cache: true |
| 28 | + - name: Import GPG key |
| 29 | + uses: crazy-max/ghaction-import-gpg@v6 |
| 30 | + id: import_gpg |
70 | 31 | with: |
71 | | - path: artifacts |
72 | | - merge-multiple: true |
73 | | - |
74 | | - - name: Generate checksums |
75 | | - run: | |
76 | | - cd artifacts |
77 | | - sha256sum *.zip > checksums.txt |
78 | | -
|
79 | | - - name: Create Release |
80 | | - uses: softprops/action-gh-release@v1 |
| 32 | + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} |
| 33 | + passphrase: ${{ secrets.PASSPHRASE }} |
| 34 | + - name: Run GoReleaser |
| 35 | + uses: goreleaser/goreleaser-action@v6 |
81 | 36 | with: |
82 | | - files: | |
83 | | - artifacts/*.zip |
84 | | - artifacts/checksums.txt |
85 | | - generate_release_notes: true |
86 | | - draft: false |
87 | | - prerelease: false |
| 37 | + args: release --clean |
| 38 | + env: |
| 39 | + # GitHub sets the GITHUB_TOKEN secret automatically. |
| 40 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 41 | + GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} |
0 commit comments