Skip to content

Commit 8867720

Browse files
committed
fix terraform provider releases
1 parent 6c1e85f commit 8867720

File tree

3 files changed

+59
-40
lines changed

3 files changed

+59
-40
lines changed

.github/workflows/release.yml

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
echo "Timed out waiting for CI to complete."
6060
exit 1
6161
62-
release:
62+
goreleaser:
6363
runs-on: ubuntu-latest
6464
needs: wait_ci
6565
steps:
@@ -68,33 +68,18 @@ jobs:
6868
fetch-depth: 0
6969
- uses: actions/setup-go@v5
7070
with:
71-
go-version: '1.22'
72-
- name: Import GPG private key (for checksum signing)
73-
env:
74-
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
75-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
76-
run: |
77-
if [ -z "${GPG_PRIVATE_KEY:-}" ]; then
78-
echo "No GPG_PRIVATE_KEY secret set; skipping key import."
79-
exit 0
80-
fi
81-
mkdir -p ~/.gnupg
82-
chmod 700 ~/.gnupg
83-
echo "Importing GPG key"
84-
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
85-
if [ -n "${GPG_PASSPHRASE:-}" ]; then
86-
echo 'pinentry-mode loopback' >> ~/.gnupg/gpg.conf
87-
echo 'allow-loopback-pinentry' >> ~/.gnupg/gpg-agent.conf
88-
gpg-connect-agent reloadagent /bye
89-
fi
90-
gpg --list-secret-keys --keyid-format LONG || true
91-
- name: Build
92-
run: go build ./...
93-
- name: GoReleaser
71+
go-version-file: 'go.mod'
72+
cache: true
73+
- name: Import GPG key
74+
id: import_gpg
75+
uses: crazy-max/ghaction-import-gpg@v6
76+
with:
77+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
78+
passphrase: ${{ secrets.PASSPHRASE }}
79+
- name: Run GoReleaser
9480
uses: goreleaser/goreleaser-action@v5
9581
with:
96-
version: latest
9782
args: release --clean
9883
env:
9984
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100-
GPG_TTY: ${{ runner.env.SSH_AUTH_SOCK }}
85+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}

.goreleaser.yaml

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,56 @@
1+
version: 2
12
project_name: terraform-provider-logstruct
23
before:
34
hooks:
45
- go mod tidy
56
builds:
67
- id: provider
78
main: ./main.go
8-
# Binary inside the ZIP must be versioned for Terraform Registry ingestion
9-
binary: terraform-provider-logstruct_v{{ .Version }}
109
env:
1110
- CGO_ENABLED=0
12-
goos: [linux, darwin, windows]
13-
goarch: [amd64, arm64]
14-
flags: ["-trimpath"]
11+
mod_timestamp: '{{ .CommitTimestamp }}'
12+
flags:
13+
- -trimpath
1514
ldflags:
16-
- -s -w -X main.version={{.Version}}
15+
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
16+
goos:
17+
- freebsd
18+
- windows
19+
- linux
20+
- darwin
21+
goarch:
22+
- amd64
23+
- '386'
24+
- arm
25+
- arm64
26+
ignore:
27+
- goos: darwin
28+
goarch: '386'
29+
# Binary inside ZIP must be versioned: terraform-provider-<name>_v<version>
30+
binary: '{{ .ProjectName }}_v{{ .Version }}'
1731
archives:
18-
- id: archive
19-
name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}'
20-
builds: [provider]
21-
format: zip
32+
- format: zip
33+
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
2234
checksum:
23-
name_template: '{{ .ProjectName }}_v{{ .Version }}_SHA256SUMS'
35+
extra_files:
36+
- glob: 'terraform-registry-manifest.json'
37+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
38+
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
39+
algorithm: sha256
2440
signs:
2541
- artifacts: checksum
42+
args:
43+
- "--batch"
44+
- "--local-user"
45+
- "{{ .Env.GPG_FINGERPRINT }}"
46+
- "--output"
47+
- "${signature}"
48+
- "--detach-sign"
49+
- "${artifact}"
2650
release:
27-
draft: false
28-
prerelease: auto
29-
name_template: 'v{{ .Version }}'
51+
extra_files:
52+
- glob: 'terraform-registry-manifest.json'
53+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
54+
# draft: true # uncomment if you want to inspect before publishing
55+
changelog:
56+
disable: true

terraform-registry-manifest.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"version": 1,
3+
"metadata": {
4+
"protocol_versions": ["6.0"]
5+
}
6+
}
7+

0 commit comments

Comments
 (0)