-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: build Terraform binaries action (#2684)
Co-authored-by: Moritz Sanft <[email protected]>
- Loading branch information
Showing
4 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Build Terraform provider | ||
description: | | ||
Builds Terraform provider binaries cross platform. | ||
inputs: | ||
targetOS: | ||
description: "Build for this OS. [linux, darwin, windows]" | ||
required: true | ||
default: "linux" | ||
targetArch: | ||
description: "Build for this architecture. [amd64, arm64]" | ||
required: true | ||
default: "amd64" | ||
outputPath: | ||
description: "Output path of the binary" | ||
required: false | ||
runs: | ||
using: "composite" | ||
steps: | ||
# https://github.blog/2022-04-12-git-security-vulnerability-announced/ | ||
- name: Mark repository safe | ||
shell: bash | ||
run: | | ||
git config --global --add safe.directory /__w/constellation/constellation | ||
- name: Build Binaries | ||
shell: bash | ||
env: | ||
TARGET_GOOS: ${{ inputs.targetOS }} | ||
TARGET_GOARCH: ${{ inputs.targetArch }} | ||
OUTPUT_PATH: ${{ inputs.outputPath || format('./build/terraform-provider-constellation-{0}-{1}', inputs.targetOS, inputs.targetArch) }}${{ inputs.targetOS == 'windows' && '.exe' || '' }} | ||
run: | | ||
echo "::group::Build Terraform provider" | ||
mkdir -p "$(dirname "${OUTPUT_PATH}")" | ||
label="//terraform-provider-constellation:tf_provider_${TARGET_GOOS}_${TARGET_GOARCH}" | ||
bazel build "${label}" | ||
repository_root=$(git rev-parse --show-toplevel) | ||
out_rel=$(bazel cquery --output=files "${label}") | ||
out_loc="$(realpath "${repository_root}/${out_rel}")" | ||
cp "${out_loc}" "${OUTPUT_PATH}" | ||
chmod +w "${OUTPUT_PATH}" | ||
export PATH="$PATH:$(realpath $(dirname "${OUTPUT_PATH}"))" | ||
echo "$(realpath $(dirname "${OUTPUT_PATH}"))" >> $GITHUB_PATH | ||
echo "::endgroup::" |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Build Terraform provider and prepare release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
ref: | ||
type: string | ||
description: "Git ref to checkout" | ||
required: false | ||
workflow_call: | ||
inputs: | ||
ref: | ||
type: string | ||
description: "Git ref to checkout" | ||
required: true | ||
|
||
jobs: | ||
build-tf-provider: | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- arch: amd64 | ||
os: linux | ||
|
||
- arch: amd64 | ||
os: darwin | ||
|
||
- arch: amd64 | ||
os: windows | ||
|
||
- arch: arm64 | ||
os: linux | ||
|
||
- arch: arm64 | ||
os: darwin | ||
steps: | ||
- name: Checkout | ||
id: checkout | ||
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 | ||
with: | ||
ref: ${{ inputs.ref || github.head_ref }} | ||
|
||
- name: Setup bazel | ||
uses: ./.github/actions/setup_bazel_nix | ||
with: | ||
useCache: "false" | ||
|
||
- name: Build Terraform Provider Binary | ||
uses: ./.github/actions/build_tf_provider | ||
with: | ||
targetOS: ${{ matrix.os }} | ||
targetArch: ${{ matrix.arch }} | ||
|
||
- name: Upload Terraform Provider Binary as artifact (unix) | ||
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 | ||
if : ${{ matrix.os != 'windows' }} | ||
with: | ||
name: terraform-provider-constellation-${{ matrix.os }}-${{ matrix.arch }} | ||
path: | | ||
build/terraform-provider-constellation-${{ matrix.os }}-${{ matrix.arch }} | ||
- name: Upload Terraform Provider Binary as artifact (windows) | ||
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 | ||
if : ${{ matrix.os == 'windows' }} | ||
with: | ||
name: terraform-provider-constellation-${{ matrix.os }}-${{ matrix.arch }} | ||
path: | | ||
build/terraform-provider-constellation-${{ matrix.os }}-${{ matrix.arch }}.exe |
This file contains 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