diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 00000000..7fe7889a --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,194 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 +# +# This workflow builds the product for all supported platforms and uploads the resulting +# binaries as Actions artifacts. The workflow also uploads a build metadata file +# (metadata.json) -- and a Terraform Registry manifest file (terraform-registry-manifest.json). +# +# Reference: https://github.com/hashicorp/terraform-provider-crt-example/blob/main/.github/workflows/README.md +# + +name: build + +# We default to running this workflow on every push to every branch. +# This provides fast feedback when build issues occur, so they can be +# fixed prior to being merged to the main branch. +# +# If you want to opt out of this, and only run the build on certain branches +# please refer to the documentation on branch filtering here: +# +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpushbranchestagsbranches-ignoretags-ignore +# +on: [workflow_dispatch, push] + +env: + PKG_NAME: "terraform-provider-boundary" + +jobs: + # Detects the Go version to use for builds. + get-go-version: + name: "Detect Go toolchain version" + runs-on: ubuntu-latest + outputs: + go-version: ${{ steps.get-go-version.outputs.go-version }} + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Detect Go version + id: get-go-version + # We use .go-version as our source of truth for current Go version, + # because "goenv" can react to it automatically. + run: | + echo "Building with Go $(cat .go-version)" + echo "go-version=$(cat .go-version)" >> "$GITHUB_OUTPUT" + - name: Set up Go + uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 + with: + go-version: "${{ steps.get-go-version.outputs.go-version }}" + cache: false + + # Parses the version/VERSION file. Reference: https://github.com/hashicorp/actions-set-product-version/blob/main/README.md + # + # > This action should be implemented in product repo `build.yml` files. The action is intended to grab the version + # > from the version file at the beginning of the build, then passes those versions (along with metadata, where + # > necessary) to any workflow jobs that need version information. + set-product-version: + name: "Parse version file" + runs-on: ubuntu-latest + outputs: + product-version: ${{ steps.set-product-version.outputs.product-version }} + product-base-version: ${{ steps.set-product-version.outputs.base-product-version }} + product-prerelease-version: ${{ steps.set-product-version.outputs.prerelease-product-version }} + product-minor-version: ${{ steps.set-product-version.outputs.minor-product-version }} + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Set variables + id: set-product-version + uses: hashicorp/actions-set-product-version@v2 + + # Creates metadata.json file containing build metadata for consumption by CRT workflows. + # + # Reference: https://github.com/hashicorp/actions-generate-metadata/blob/main/README.md + generate-metadata-file: + needs: set-product-version + runs-on: ubuntu-latest + outputs: + filepath: ${{ steps.generate-metadata-file.outputs.filepath }} + steps: + - name: "Checkout directory" + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Generate metadata file + id: generate-metadata-file + uses: hashicorp/actions-generate-metadata@v1 + with: + version: ${{ needs.set-product-version.outputs.product-version }} + product: ${{ env.PKG_NAME }} + repositoryOwner: "hashicorp" + - uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 + with: + name: metadata.json + path: ${{ steps.generate-metadata-file.outputs.filepath }} + + # Uploads an Actions artifact named terraform-registry-manifest.json.zip. + # + # The artifact contains a single file with a filename that Terraform Registry expects + # (example: terraform-provider-crt-example_2.3.6-alpha1_manifest.json). The file contents + # are identical to the terraform-registry-manifest.json file in the source repository. + upload-terraform-registry-manifest-artifact: + needs: set-product-version + runs-on: ubuntu-latest + steps: + - name: "Checkout directory" + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + path: ${{ env.PKG_NAME }} + - name: "Copy manifest from checkout directory to a file with the desired name" + id: terraform-registry-manifest + run: | + name="${{ env.PKG_NAME }}" + version="${{ needs.set-product-version.outputs.product-version }}" + + source="${name}/terraform-registry-manifest.json" + destination="${name}_${version}_manifest.json" + + cp "$source" "$destination" + echo "filename=$destination" >> "$GITHUB_OUTPUT" + - uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 + with: + name: terraform-registry-manifest.json + path: ${{ steps.terraform-registry-manifest.outputs.filename }} + if-no-files-found: error + + # Builds the product for supported platforms. + # + # With `reproducible: report`, this job also reports whether the build is reproducible, + # but does not enforce it. + # + # Reference: https://github.com/hashicorp/actions-go-build/blob/main/README.md + build: + needs: + - get-go-version + - set-product-version + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + goos: [freebsd, windows, linux, darwin] + goarch: ["386", "amd64", "arm", "arm64"] + exclude: + - goos: freebsd + goarch: arm64 + - goos: windows + goarch: arm64 + - goos: windows + goarch: arm + - goos: darwin + goarch: 386 + - goos: darwin + goarch: arm + + name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: hashicorp/actions-go-build@v1 + env: + CGO_ENABLED: 0 + BASE_VERSION: ${{ needs.set-product-version.outputs.product-base-version }} + PRERELEASE_VERSION: ${{ needs.set-product-version.outputs.product-prerelease-version}} + METADATA_VERSION: ${{ env.METADATA }} + with: + bin_name: "${{ env.PKG_NAME }}_v${{ needs.set-product-version.outputs.product-version }}_x5" + product_name: ${{ env.PKG_NAME }} + product_version: ${{ needs.set-product-version.outputs.product-version }} + go_version: ${{ needs.get-go-version.outputs.go-version }} + os: ${{ matrix.goos }} + arch: ${{ matrix.goarch }} + reproducible: report + instructions: | + go build \ + -o "$BIN_PATH" \ + -trimpath \ + -buildvcs=false \ + -ldflags "-s -w -X 'main.version=${{ needs.set-product-version.outputs.product-version }}'" + cp LICENSE "$TARGET_DIR/LICENSE.txt" + + whats-next: + needs: + - build + - generate-metadata-file + - upload-terraform-registry-manifest-artifact + runs-on: ubuntu-latest + name: "What's next?" + steps: + - name: "Write a helpful summary" + run: | + github_dot_com="${{ github.server_url }}" + owner_with_name="${{ github.repository }}" + ref="${{ github.ref }}" + + { + echo "### What's next?" + echo "#### For a release branch (see \`.release/ci.hcl\`)" + echo "After this \`build\` workflow run completes succesfully, you can expect the CRT \`prepare\` workflow to begin momentarily." + echo "To find the \`prepare\` workflow run, [view the checks for this commit]($github_dot_com/$owner_with_name/commits/$ref)" + } >> "$GITHUB_STEP_SUMMARY" + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 62a91fa8..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Release - -on: - push: - tags: - - 'v[0-9]+.[0-9]+.[0-9]+*' - -permissions: - contents: write - -jobs: - go-version: - runs-on: ubuntu-latest - outputs: - version: ${{ steps.go-version.outputs.go-version }} - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - id: go-version - # We use .go-version as our source of truth for current Go - # version, because "goenv" can react to it automatically. - run: | - echo "Building with Go $(cat .go-version)" - echo "go-version=$(cat .go-version)" >> "$GITHUB_OUTPUT" - release-notes: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - fetch-depth: 0 - - name: Generate Release Notes - run: sed -n -e "1{/# /d;}" -e "2{/^$/d;}" -e "/# $(git describe --abbrev=0 --exclude="$(git describe --abbrev=0 --match='v*.*.*' --tags)" --match='v*.*.*' --tags | tr -d v)/q;p" CHANGELOG.md > release-notes.txt - - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - with: - name: release-notes - path: release-notes.txt - retention-days: 1 - terraform-provider-release: - name: 'Terraform Provider Release' - needs: [go-version, release-notes] - uses: hashicorp/ghaction-terraform-provider-release/.github/workflows/hashicorp.yml@v5 - secrets: - hc-releases-github-token: '${{ secrets.HASHI_RELEASES_GITHUB_TOKEN }}' - hc-releases-host-staging: '${{ secrets.HC_RELEASES_HOST_STAGING }}' - hc-releases-host-prod: '${{ secrets.HC_RELEASES_HOST_PROD }}' - hc-releases-key-prod: '${{ secrets.HC_RELEASES_KEY_PROD }}' - hc-releases-key-staging: '${{ secrets.HC_RELEASES_KEY_STAGING }}' - hc-releases-terraform-registry-sync-token: '${{ secrets.TF_PROVIDER_RELEASE_TERRAFORM_REGISTRY_SYNC_TOKEN }}' - setup-signore-github-token: '${{ secrets.HASHI_SIGNORE_GITHUB_TOKEN }}' - signore-client-id: '${{ secrets.SIGNORE_CLIENT_ID }}' - signore-client-secret: '${{ secrets.SIGNORE_CLIENT_SECRET }}' - with: - release-notes: true - setup-go-version: '${{ needs.go-version.outputs.version }}' - # Product Version (e.g. v1.2.3 or github.ref_name) - product-version: '${{ github.ref_name }}' diff --git a/.goreleaser.yml b/.goreleaser.yml deleted file mode 100644 index 25791b13..00000000 --- a/.goreleaser.yml +++ /dev/null @@ -1,78 +0,0 @@ -# Copyright (c) HashiCorp, Inc. -# SPDX-License-Identifier: MPL-2.0 - -archives: - - files: - # Ensure only built binary is archived - - 'none*' - format: zip - name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' -before: - hooks: - - 'go mod download' - - './scripts/plugins-all.sh' -builds: - - # Binary naming only required for Terraform CLI 0.12 - binary: '{{ .ProjectName }}_v{{ .Version }}_x5' - env: - - CGO_ENABLED=0 - flags: - - -trimpath - goos: - - darwin - - freebsd - - linux - - windows - goarch: - - '386' - - amd64 - - arm - - arm64 - ignore: - - goarch: arm - goos: windows - - goarch: arm64 - goos: freebsd - - goarch: arm64 - goos: windows - ldflags: - - -s -w -X main.Version={{.Version}} - mod_timestamp: '{{ .CommitTimestamp }}' -checksum: - algorithm: sha256 - extra_files: - - glob: 'terraform-registry-manifest.json' - name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json' - name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS' -publishers: - - checksum: true - # Terraform CLI 0.10 - 0.11 perform discovery via HTTP headers on releases.hashicorp.com - # For providers which have existed since those CLI versions, exclude - # discovery by setting the protocol version headers to 5. - cmd: hc-releases upload -product {{ .ProjectName }} -version {{ .Version }} -file={{ .ArtifactPath }}={{ .ArtifactName }} -header=x-terraform-protocol-version=5 -header=x-terraform-protocol-versions=5.0 - env: - - HC_RELEASES_HOST={{ .Env.HC_RELEASES_HOST }} - - HC_RELEASES_KEY={{ .Env.HC_RELEASES_KEY }} - extra_files: - - glob: 'terraform-registry-manifest.json' - name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json' - name: upload - signature: true -release: - extra_files: - - glob: 'terraform-registry-manifest.json' - name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json' - ids: - - none -signs: - - args: ["sign", "--dearmor", "--file", "${artifact}", "--out", "${signature}"] - artifacts: checksum - cmd: signore - signature: ${artifact}.sig - - args: ["sign", "--dearmor", "--file", "${artifact}", "--out", "${signature}"] - artifacts: checksum - cmd: signore - id: key-id - signature: ${artifact}.72D7468F.sig -snapshot: - name_template: "{{ .Tag }}-next" diff --git a/.release/ci.hcl b/.release/ci.hcl new file mode 100644 index 00000000..95d548c4 --- /dev/null +++ b/.release/ci.hcl @@ -0,0 +1,96 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 +# +# Reference: https://github.com/hashicorp/crt-core-helloworld/blob/main/.release/ci.hcl (private repository) +# +# One way to validate this file, with a local build of the orchestrator (an internal repo): +# +# $ GITHUB_TOKEN="not-used" orchestrator parse config -use-v2 -local-config=.release/ci.hcl + +schema = "2" + +project "terraform-provider-boundary" { + // team is currently unused and has no meaning + // but is required to be non-empty by CRT orchestator + team = "_UNUSED_" + + slack { + notification_channel = "C01BWLSMJ03" // #proj-boundary-release-engineering + } + + github { + organization = "hashicorp" + repository = "terraform-provider-boundary" + release_branches = ["main", "release/**"] + } +} + +event "merge" { +} + +event "build" { + action "build" { + depends = ["merge"] + + organization = "hashicorp" + repository = "terraform-provider-boundary" + workflow = "build" + } +} + +event "prepare" { + # `prepare` is the Common Release Tooling (CRT) artifact processing workflow. + # It prepares artifacts for potential promotion to staging and production. + # For example, it scans and signs artifacts. + + depends = ["build"] + + action "prepare" { + organization = "hashicorp" + repository = "crt-workflows-common" + workflow = "prepare" + depends = ["build"] + } + + notification { + on = "fail" + } +} + +event "trigger-staging" { +} + +event "promote-staging" { + action "promote-staging" { + organization = "hashicorp" + repository = "crt-workflows-common" + workflow = "promote-staging" + depends = null + config = "release-metadata.hcl" + } + + depends = ["trigger-staging"] + + notification { + on = "always" + } +} + +event "trigger-production" { +} + +event "promote-production" { + action "promote-production" { + organization = "hashicorp" + repository = "crt-workflows-common" + workflow = "promote-production" + depends = null + config = "" + } + + depends = ["trigger-production"] + + notification { + on = "always" + } +} diff --git a/.release/release-metadata.hcl b/.release/release-metadata.hcl index 414e221c..abb532f8 100644 --- a/.release/release-metadata.hcl +++ b/.release/release-metadata.hcl @@ -2,4 +2,6 @@ # SPDX-License-Identifier: MPL-2.0 url_source_repository = "https://github.com/hashicorp/terraform-provider-boundary" +url_project_website = "https://registry.terraform.io/providers/hashicorp/boundary" url_license = "https://github.com/hashicorp/terraform-provider-boundary/blob/main/LICENSE" +url_release_notes = "https://github.com/hashicorp/terraform-provider-boundary/blob/main/CHANGELOG.md" diff --git a/.release/security-scan.hcl b/.release/security-scan.hcl new file mode 100644 index 00000000..1b243c8c --- /dev/null +++ b/.release/security-scan.hcl @@ -0,0 +1,14 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 +# +# Reference: https://github.com/hashicorp/security-scanner/blob/main/CONFIG.md#binary (private repository) + +binary { + secrets { + all = true + } + go_modules = true + osv = true + oss_index = false + nvd = false +} diff --git a/.release/terraform-provider-boundary-artifacts.hcl b/.release/terraform-provider-boundary-artifacts.hcl new file mode 100644 index 00000000..7098aec0 --- /dev/null +++ b/.release/terraform-provider-boundary-artifacts.hcl @@ -0,0 +1,20 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +schema = 1 +artifacts { + # This should match the `matrix` in .github/workflows/build.yml + zip = [ + "terraform-provider-boundary_${version}_darwin_amd64.zip", + "terraform-provider-boundary_${version}_darwin_arm64.zip", + "terraform-provider-boundary_${version}_freebsd_386.zip", + "terraform-provider-boundary_${version}_freebsd_amd64.zip", + "terraform-provider-boundary_${version}_freebsd_arm.zip", + "terraform-provider-boundary_${version}_linux_386.zip", + "terraform-provider-boundary_${version}_linux_amd64.zip", + "terraform-provider-boundary_${version}_linux_arm.zip", + "terraform-provider-boundary_${version}_linux_arm64.zip", + "terraform-provider-boundary_${version}_windows_386.zip", + "terraform-provider-boundary_${version}_windows_amd64.zip", + ] +} diff --git a/version/VERSION b/version/VERSION new file mode 100644 index 00000000..f0bb29e7 --- /dev/null +++ b/version/VERSION @@ -0,0 +1 @@ +1.3.0