Replace upstream build workflow #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: go:release | ||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*' | ||
| env: | ||
| PKG_NAME: "terraform-provider-azurerm" | ||
| jobs: | ||
| 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 | ||
| - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 | ||
| with: | ||
| go-version-file: 'go.mod' | ||
| - name: Detect Go version | ||
| id: get-go-version | ||
| run: | | ||
| version="$(go list -f {{.GoVersion}} -m)" | ||
| echo "go-version=$version" >> "$GITHUB_OUTPUT" | ||
| 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 | ||
| go-publish: | ||
| needs: [ get-go-version, set-product-version ] | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: true | ||
| matrix: | ||
| goarch: ["amd64", "arm64"] | ||
| steps: | ||
| - name: Checkout commit | ||
| uses: actions/checkout@v4 | ||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.23' | ||
| - name: Build terraform-provider-azurerm | ||
| 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}} | ||
| with: | ||
| # Protocol v6 providers should omit the `_x5` suffix. | ||
| 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: linux | ||
| 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" | ||
| run: |- | ||
| export GOBIN=$(go env GOBIN) | ||
| export GOPATH=$(go env GOPATH) | ||
| export PATH=$PATH:$GOBIN | ||
| go mod download | ||
| CGO_ENABLED=0 GOOS=$(go env GOOS) GOARCH=$(go env GOARCH) go build \ | ||
| -a \ | ||
| -v \ | ||
| -ldflags "$LD_FLAGS" \ | ||
| -o ${GITHUB_WORKSPACE}/terraform-provider-azurerm \ | ||
| main.go | ||
| - name: Store generated binary | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: terraform-provider-azurerm.bin | ||
| path: terraform-provider-azurerm | ||