Use latest scanning approach #86
Workflow file for this run
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
name: Build | |
on: | |
push: | |
branches: | |
- "main" | |
pull_request: | |
branches: | |
- "main" | |
types: [ opened, synchronize ] | |
jobs: | |
build-artifact: | |
name: Build and verify artifact | |
runs-on: ${{ matrix.runner }} | |
outputs: | |
module_name: ${{ steps.prepare-release.outputs.module_name }} | |
version: ${{ steps.prepare-release.outputs.version }} | |
strategy: | |
matrix: | |
os: [ ubuntu-22.04, darwin, windows ] | |
arch: [ amd64, arm64 ] | |
include: | |
- os: ubuntu-22.04 | |
arch: amd64 | |
runner: ubuntu-22.04 | |
build_target: build-linux-amd64 | |
verify_target: verify-binary-linux | |
dependencies: musl-tools | |
- os: ubuntu-22.04 | |
arch: arm64 | |
# According to linter: warning Workflow => .github/workflows/build.yml:38:21: label "Terraform-provider-bitwarden-sm-linux" is unknown. | |
runner: Terraform-provider-bitwarden-sm-linux | |
build_target: build-linux-arm64 | |
verify-target: verify-binary-linux | |
dependencies: musl-tools | |
- os: darwin | |
arch: amd64 | |
# According to linter: label "macos-14" is unknown | |
runner: macos-14 | |
build_target: build-darwin-amd64 | |
verify_target: verify-binary-darwin-amd64 | |
- os: darwin | |
arch: arm64 | |
runner: macos-14 | |
build_target: build-darwin-arm64 | |
verify_target: verify-binary-darwin-arm64 | |
- os: windows | |
arch: amd64 | |
runner: ubuntu-22.04 | |
build_target: build-windows-amd64 | |
verify_target: verify-binary-windows-amd64 | |
dependencies: mingw-w64 | |
exclude: | |
- os: windows | |
arch: arm64 | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Setup Go | |
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- name: Install dependencies (Linux only) | |
if: matrix.os == 'ubuntu-22.04' | |
run: sudo apt update && sudo apt install -y ${{ matrix.dependencies }} | |
- name: Install dependencies (Windows cross-compile only) | |
if: matrix.os == 'windows' | |
run: sudo apt update && sudo apt install -y ${{ matrix.dependencies }} | |
- name: Install Go dependencies | |
run: go mod tidy | |
- name: Get current version | |
id: current-version | |
run: | | |
CURRENT_VERSION=$(grep 'ProviderVersion string =' version/version.go | sed -E 's/.*"([0-9]+\.[0-9]+\.[0-9]+(-pre)?)".*/\1/') | |
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
- name: Build binary | |
run: make ${{ matrix.build_target }} BINARY_VERSION="_${{ steps.current-version.outputs.version }}" | |
- name: Verify binary | |
run: make ${{ matrix.verify_target }} BINARY_VERSION="_${{ steps.current-version.outputs.version }}" | |
- name: Prepare release artifacts | |
id: prepare-release | |
run: | | |
MODULE_NAME=$(grep "^module" go.mod | awk -F'/' '{print $NF}') | |
BINARY_VERSION=$(echo ${{ steps.current-version.outputs.version }}) | |
ARCHIVE="${MODULE_NAME}_${BINARY_VERSION}_${{ matrix.os }}_${{ matrix.arch }}.zip" | |
# Conditionally set the binary name with or without .exe extension | |
BINARY="${MODULE_NAME}_${BINARY_VERSION}" | |
if [ "${{ matrix.os }}" = "windows" ]; then | |
BINARY="${BINARY}.exe" | |
fi | |
# Create ZIP archive | |
zip ${ARCHIVE} ${BINARY} | |
echo "module_name=${MODULE_NAME}" >> "$GITHUB_OUTPUT" | |
echo "version=${BINARY_VERSION}" >> "$GITHUB_OUTPUT" | |
echo "binary_version=${BINARY_VERSION}" >> "$GITHUB_OUTPUT" | |
echo "archive=${ARCHIVE}" >> "$GITHUB_OUTPUT" | |
- name: Upload artifacts | |
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 | |
with: | |
name: ${{ steps.prepare-release.outputs.module_name }}_${{ steps.prepare-release.outputs.binary_version }}_${{ matrix.os }}_${{ matrix.arch }} | |
retention-days: 5 | |
path: | | |
${{ steps.prepare-release.outputs.archive }} |