Skip to content

Commit 8d4f610

Browse files
committed
modify gorelease.yaml and release.yml
1 parent 9467bf2 commit 8d4f610

File tree

2 files changed

+63
-84
lines changed

2 files changed

+63
-84
lines changed

.github/workflows/release.yml

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,41 @@
1-
name: release
1+
# Terraform Provider release workflow.
2+
name: Release
23

4+
# This GitHub action creates a release when a tag that matches the pattern
5+
# "v*" (e.g. v0.1.0) is created.
36
on:
47
push:
58
tags:
69
- 'v*'
710

11+
# Releases need permissions to read and write the repository contents.
12+
# GitHub considers creating releases and uploading assets as writing contents.
13+
permissions:
14+
contents: write
15+
816
jobs:
917
goreleaser:
10-
runs-on: ubuntu-24.04
11-
18+
runs-on: ubuntu-latest
1219
steps:
13-
# Step 1: Checkout the repository code
14-
- name: Checkout Code
15-
uses: actions/checkout@v3
16-
17-
# Step 2: Fetch the full Git history (required for GoReleaser to properly handle versions)
18-
- name: Fetch Git History
19-
run: git fetch --prune --unshallow
20-
21-
# Step 3: Set up the Go environment (GoReleaser needs Go to build)
22-
- name: Set up Go Environment
23-
uses: actions/setup-go@v4
20+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2421
with:
25-
go-version: "1.22.0"
26-
27-
# Step 4: Import GPG Key (for signing releases)
28-
- name: Import GPG Key
22+
# Allow goreleaser to access older tag information.
23+
fetch-depth: 0
24+
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
25+
with:
26+
go-version-file: 'go.mod'
27+
cache: true
28+
- name: Import GPG key
29+
uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0
2930
id: import_gpg
30-
uses: crazy-max/ghaction-import-gpg@v5
3131
with:
3232
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
3333
passphrase: ${{ secrets.PASSPHRASE }}
34-
35-
# Step 5: Run GoReleaser to build and release the project
3634
- name: Run GoReleaser
37-
uses: goreleaser/goreleaser-action@v4
35+
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0
3836
with:
39-
version: latest
4037
args: release --clean
4138
env:
42-
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
39+
# GitHub sets the GITHUB_TOKEN secret automatically.
4340
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}

.goreleaser.yaml

Lines changed: 41 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,48 @@
1+
# Visit https://goreleaser.com for documentation on how to customize this
2+
# behavior.
13
version: 2
2-
3-
# Archives section for creating the distribution files
4-
archives:
5-
- files:
6-
- src: 'LICENSE'
7-
dst: 'LICENSE.txt'
8-
format: zip
9-
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
10-
11-
# Before build hooks (optional, used to download dependencies and prepare environment)
124
before:
135
hooks:
14-
- 'go mod download'
15-
16-
# Build configuration for various OS and architecture targets
6+
# this is just an example and not a requirement for provider building/publishing
7+
- go mod tidy
178
builds:
18-
- binary: '{{ .ProjectName }}_v{{ .Version }}_x5' # Binary name format
19-
env:
20-
- CGO_ENABLED=0 # Disable CGo for cross-platform compatibility
21-
flags:
22-
- -trimpath # Remove the file system paths from the final binary
23-
goos:
24-
- darwin
25-
- freebsd
26-
- linux
27-
- windows
28-
goarch:
29-
- '386'
30-
- amd64
31-
- arm
32-
- arm64
33-
ignore:
34-
- goarch: arm
35-
goos: windows
36-
- goarch: arm64
37-
goos: freebsd
38-
- goarch: arm64
39-
goos: windows
40-
ldflags:
41-
- -s -w -X main.Version={{.Version}} # Set the version in the binary
42-
mod_timestamp: '{{ .CommitTimestamp }}' # Timestamp of commit for builds
43-
44-
# Release section moved inside builds (if required in specific GoReleaser version)
45-
release:
46-
extra_files:
47-
- glob: 'terraform-registry-manifest.json'
48-
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
49-
ids:
50-
- none # Disable auto-ids for releases
51-
52-
# Checksum generation configuration
9+
- env:
10+
# goreleaser does not work with CGO, it could also complicate
11+
# usage by users in CI/CD systems like HCP Terraform where
12+
# they are unable to install libraries.
13+
- CGO_ENABLED=0
14+
mod_timestamp: '{{ .CommitTimestamp }}'
15+
flags:
16+
- -trimpath
17+
ldflags:
18+
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
19+
goos:
20+
- freebsd
21+
- windows
22+
- linux
23+
- darwin
24+
goarch:
25+
- amd64
26+
- '386'
27+
- arm
28+
- arm64
29+
ignore:
30+
- goos: darwin
31+
goarch: '386'
32+
binary: '{{ .ProjectName }}_v{{ .Version }}'
33+
archives:
34+
- format: zip
35+
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
5336
checksum:
54-
algorithm: sha256
5537
extra_files:
5638
- glob: 'terraform-registry-manifest.json'
5739
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
5840
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
59-
60-
# Milestone to close issues or PRs after release
61-
milestones:
62-
- close: true
63-
64-
# Signing configuration for checksums and the release artifacts
41+
algorithm: sha256
6542
signs:
6643
- artifacts: checksum
6744
args:
68-
# if you are using this is a GitHub action or some other automated pipeline, you
45+
# if you are using this in a GitHub action or some other automated pipeline, you
6946
# need to pass the batch flag to indicate its not interactive.
7047
- "--batch"
7148
- "--local-user"
@@ -74,7 +51,11 @@ signs:
7451
- "${signature}"
7552
- "--detach-sign"
7653
- "${artifact}"
77-
78-
# Snapshot naming template for pre-release builds
79-
snapshot:
80-
name_template: "{{ .Tag }}-next"
54+
release:
55+
extra_files:
56+
- glob: 'terraform-registry-manifest.json'
57+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
58+
# If you want to manually examine the release before its live, uncomment this line:
59+
# draft: true
60+
changelog:
61+
disable: true

0 commit comments

Comments
 (0)