Skip to content

Commit fb28d23

Browse files
authored
Change release tooling to release with HashiCorp CRT (#516)
* add files for CRT (original files) * change CRT files to match this provider * ignore some invalid osx archs as the build did fail without them and goreleaser seemed to have ignored them automatically * remove -X flag that wasn't needed * remove probably uneccessary env vars
1 parent 3bcb679 commit fb28d23

File tree

6 files changed

+309
-2
lines changed

6 files changed

+309
-2
lines changed

.github/workflows/build.yml

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
# This workflow builds the product for all supported platforms and uploads the resulting
2+
# binaries as Actions artifacts. The workflow also uploads a build metadata file
3+
# (metadata.json) -- and a Terraform Registry manifest file (terraform-registry-manifest.json).
4+
#
5+
# Reference: https://github.com/hashicorp/terraform-provider-crt-example/blob/main/.github/workflows/README.md
6+
#
7+
8+
name: build
9+
10+
# We default to running this workflow on every push to every branch.
11+
# This provides fast feedback when build issues occur, so they can be
12+
# fixed prior to being merged to the main branch.
13+
#
14+
# If you want to opt out of this, and only run the build on certain branches
15+
# please refer to the documentation on branch filtering here:
16+
#
17+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpushbranchestagsbranches-ignoretags-ignore
18+
#
19+
on: [workflow_dispatch, push]
20+
21+
env:
22+
PKG_NAME: "terraform-provider-http"
23+
24+
jobs:
25+
# Detects the Go toolchain version to use for product builds.
26+
#
27+
# The implementation is inspired by envconsul -- https://go.hashi.co/get-go-version-example
28+
get-go-version:
29+
name: "Detect Go toolchain version"
30+
runs-on: ubuntu-latest
31+
outputs:
32+
go-version: ${{ steps.get-go-version.outputs.go-version }}
33+
steps:
34+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
35+
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
36+
with:
37+
go-version-file: 'go.mod'
38+
- name: Detect Go version
39+
id: get-go-version
40+
run: |
41+
version="$(go list -f {{.GoVersion}} -m)"
42+
echo "go-version=$version" >> "$GITHUB_OUTPUT"
43+
44+
# Parses the version/VERSION file. Reference: https://github.com/hashicorp/actions-set-product-version/blob/main/README.md
45+
#
46+
# > This action should be implemented in product repo `build.yml` files. The action is intended to grab the version
47+
# > from the version file at the beginning of the build, then passes those versions (along with metadata, where
48+
# > necessary) to any workflow jobs that need version information.
49+
set-product-version:
50+
name: "Parse version file"
51+
runs-on: ubuntu-latest
52+
outputs:
53+
product-version: ${{ steps.set-product-version.outputs.product-version }}
54+
product-base-version: ${{ steps.set-product-version.outputs.base-product-version }}
55+
product-prerelease-version: ${{ steps.set-product-version.outputs.prerelease-product-version }}
56+
product-minor-version: ${{ steps.set-product-version.outputs.minor-product-version }}
57+
steps:
58+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
59+
- name: Set variables
60+
id: set-product-version
61+
uses: hashicorp/actions-set-product-version@v2
62+
63+
# Creates metadata.json file containing build metadata for consumption by CRT workflows.
64+
#
65+
# Reference: https://github.com/hashicorp/actions-generate-metadata/blob/main/README.md
66+
generate-metadata-file:
67+
needs: set-product-version
68+
runs-on: ubuntu-latest
69+
outputs:
70+
filepath: ${{ steps.generate-metadata-file.outputs.filepath }}
71+
steps:
72+
- name: "Checkout directory"
73+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
74+
- name: Generate metadata file
75+
id: generate-metadata-file
76+
uses: hashicorp/actions-generate-metadata@v1
77+
with:
78+
version: ${{ needs.set-product-version.outputs.product-version }}
79+
product: ${{ env.PKG_NAME }}
80+
repositoryOwner: "hashicorp"
81+
repository: ${{ github.event.repository.name }}
82+
- uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
83+
with:
84+
name: metadata.json
85+
path: ${{ steps.generate-metadata-file.outputs.filepath }}
86+
87+
# Uploads an Actions artifact named terraform-registry-manifest.json.zip.
88+
#
89+
# The artifact contains a single file with a filename that Terraform Registry expects
90+
# (example: terraform-provider-crt-example_2.3.6-alpha1_manifest.json). The file contents
91+
# are identical to the terraform-registry-manifest.json file in the source repository.
92+
upload-terraform-registry-manifest-artifact:
93+
needs: set-product-version
94+
runs-on: ubuntu-latest
95+
steps:
96+
- name: "Checkout directory"
97+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
98+
with:
99+
path: ${{ env.PKG_NAME }}
100+
- name: "Copy manifest from checkout directory to a file with the desired name"
101+
id: terraform-registry-manifest
102+
run: |
103+
name="${{ env.PKG_NAME }}"
104+
version="${{ needs.set-product-version.outputs.product-version }}"
105+
106+
source="${name}/terraform-registry-manifest.json"
107+
destination="${name}_${version}_manifest.json"
108+
109+
cp "$source" "$destination"
110+
echo "filename=$destination" >> "$GITHUB_OUTPUT"
111+
- uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
112+
with:
113+
name: terraform-registry-manifest.json
114+
path: ${{ steps.terraform-registry-manifest.outputs.filename }}
115+
if-no-files-found: error
116+
117+
# Builds the product for all platforms except macOS.
118+
#
119+
# With `reproducible: report`, this job also reports whether the build is reproducible,
120+
# but does not enforce it.
121+
#
122+
# Reference: https://github.com/hashicorp/actions-go-build/blob/main/README.md
123+
build:
124+
needs:
125+
- get-go-version
126+
- set-product-version
127+
runs-on: ubuntu-latest
128+
strategy:
129+
fail-fast: true
130+
matrix:
131+
goos: [freebsd, windows, linux, darwin]
132+
goarch: ["386", "amd64", "arm", "arm64"]
133+
exclude:
134+
- goos: freebsd
135+
goarch: arm64
136+
- goos: windows
137+
goarch: arm64
138+
- goos: windows
139+
goarch: arm
140+
- goos: darwin
141+
goarch: 386
142+
- goos: darwin
143+
goarch: arm
144+
145+
name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build
146+
steps:
147+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
148+
- uses: hashicorp/actions-go-build@v1
149+
env:
150+
CGO_ENABLED: 0
151+
with:
152+
bin_name: "${{ env.PKG_NAME }}_v${{ needs.set-product-version.outputs.product-version }}_x5"
153+
product_name: ${{ env.PKG_NAME }}
154+
product_version: ${{ needs.set-product-version.outputs.product-version }}
155+
go_version: ${{ needs.get-go-version.outputs.go-version }}
156+
os: ${{ matrix.goos }}
157+
arch: ${{ matrix.goarch }}
158+
reproducible: report
159+
instructions: |
160+
go build \
161+
-o "$BIN_PATH" \
162+
-trimpath \
163+
-buildvcs=false \
164+
-ldflags "-s -w"
165+
cp LICENSE "$TARGET_DIR/LICENSE.txt"
166+
167+
whats-next:
168+
needs:
169+
- build
170+
- generate-metadata-file
171+
- upload-terraform-registry-manifest-artifact
172+
runs-on: ubuntu-latest
173+
name: "What's next?"
174+
steps:
175+
- name: "Write a helpful summary"
176+
run: |
177+
github_dot_com="${{ github.server_url }}"
178+
owner_with_name="${{ github.repository }}"
179+
ref="${{ github.ref }}"
180+
181+
echo "### What's next?" >> "$GITHUB_STEP_SUMMARY"
182+
echo "#### For a release branch (see \`.release/ci.hcl\`)" >> $GITHUB_STEP_SUMMARY
183+
echo "After this \`build\` workflow run completes succesfully, you can expect the CRT \`prepare\` workflow to begin momentarily." >> "$GITHUB_STEP_SUMMARY"
184+
echo "To find the \`prepare\` workflow run, [view the checks for this commit]($github_dot_com/$owner_with_name/commits/$ref)" >> "$GITHUB_STEP_SUMMARY"

.release/ci.hcl

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// Reference: https://github.com/hashicorp/crt-core-helloworld/blob/main/.release/ci.hcl (private repository)
2+
//
3+
// One way to validate this file, with a local build of the orchestrator (an internal repo):
4+
//
5+
// $ GITHUB_TOKEN="not-used" orchestrator parse config -use-v2 -local-config=.release/ci.hcl
6+
7+
schema = "2"
8+
9+
project "terraform-provider-http" {
10+
// team is currently unused and has no meaning
11+
// but is required to be non-empty by CRT orchestator
12+
team = "_UNUSED_"
13+
14+
slack {
15+
notification_channel = "C02BASDVCDT" // #feed-terraform-sdk
16+
}
17+
18+
github {
19+
organization = "hashicorp"
20+
repository = "terraform-provider-http"
21+
release_branches = ["main", "release/**"]
22+
}
23+
}
24+
25+
event "merge" {
26+
}
27+
28+
event "build" {
29+
action "build" {
30+
depends = ["merge"]
31+
32+
organization = "hashicorp"
33+
repository = "terraform-provider-http"
34+
workflow = "build"
35+
}
36+
}
37+
38+
event "prepare" {
39+
# `prepare` is the Common Release Tooling (CRT) artifact processing workflow.
40+
# It prepares artifacts for potential promotion to staging and production.
41+
# For example, it scans and signs artifacts.
42+
43+
depends = ["build"]
44+
45+
action "prepare" {
46+
organization = "hashicorp"
47+
repository = "crt-workflows-common"
48+
workflow = "prepare"
49+
depends = ["build"]
50+
}
51+
52+
notification {
53+
on = "fail"
54+
}
55+
}
56+
57+
event "trigger-staging" {
58+
}
59+
60+
event "promote-staging" {
61+
action "promote-staging" {
62+
organization = "hashicorp"
63+
repository = "crt-workflows-common"
64+
workflow = "promote-staging"
65+
depends = null
66+
config = "release-metadata.hcl"
67+
}
68+
69+
depends = ["trigger-staging"]
70+
71+
notification {
72+
on = "always"
73+
}
74+
}
75+
76+
event "trigger-production" {
77+
}
78+
79+
event "promote-production" {
80+
action "promote-production" {
81+
organization = "hashicorp"
82+
repository = "crt-workflows-common"
83+
workflow = "promote-production"
84+
depends = null
85+
config = ""
86+
}
87+
88+
depends = ["trigger-production"]
89+
90+
notification {
91+
on = "always"
92+
}
93+
}

.release/release-metadata.hcl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
url_source_repository = "https://github.com/hashicorp/terraform-provider-http"
2-
url_license = "https://github.com/hashicorp/terraform-provider-http/blob/main/LICENSE"
1+
url_source_repository = "https://github.com/hashicorp/terraform-provider-http"
2+
url_project_website = "https://registry.terraform.io/providers/hashicorp/http"
3+
url_license = "https://github.com/hashicorp/terraform-provider-http/blob/main/LICENSE"
4+
url_release_notes = "https://github.com/hashicorp/terraform-provider-http/blob/main/CHANGELOG.md"

.release/security-scan.hcl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Reference: https://github.com/hashicorp/security-scanner/blob/main/CONFIG.md#binary (private repository)
2+
3+
binary {
4+
secrets {
5+
all = true
6+
}
7+
go_modules = true
8+
osv = true
9+
oss_index = false
10+
nvd = false
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
schema = 1
2+
artifacts {
3+
zip = [
4+
"terraform-provider-http_${version}_darwin_amd64.zip",
5+
"terraform-provider-http_${version}_darwin_arm64.zip",
6+
"terraform-provider-http_${version}_freebsd_386.zip",
7+
"terraform-provider-http_${version}_freebsd_amd64.zip",
8+
"terraform-provider-http_${version}_freebsd_arm.zip",
9+
"terraform-provider-http_${version}_linux_386.zip",
10+
"terraform-provider-http_${version}_linux_amd64.zip",
11+
"terraform-provider-http_${version}_linux_arm.zip",
12+
"terraform-provider-http_${version}_linux_arm64.zip",
13+
"terraform-provider-http_${version}_windows_386.zip",
14+
"terraform-provider-http_${version}_windows_amd64.zip",
15+
]
16+
}

version/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.5.0

0 commit comments

Comments
 (0)