Skip to content

Merge pull request #608 from hashicorp/go-update-1.25.9 #63

Merge pull request #608 from hashicorp/go-update-1.25.9

Merge pull request #608 from hashicorp/go-update-1.25.9 #63

Workflow file for this run

#
# This GitHub action builds azure binaries, linux packages,
# and Azure images from source, and uploads them to GitHub artifacts.
# Note that artifacts available via GitHub Artifacts are not codesigned or notarized.
#
name: build
on:
workflow_dispatch:
workflow_call:
push:
branches:
- main
- release/**
env:
REPO_NAME: "packer-plugin-azure"
permissions:
contents: read
jobs:
get-go-version:
runs-on: ubuntu-latest
outputs:
go-version: ${{ steps.get-go-version.outputs.go-version }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: 'Determine 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
set-product-version:
runs-on: ubuntu-latest
outputs:
product-version: ${{ steps.set-product-version.outputs.product-version }}
base-product-version: ${{ steps.set-product-version.outputs.base-product-version }}
product-date: ${{ steps.set-product-version.outputs.product-date }}
product-prerelease-version: ${{ steps.set-product-version.outputs.prerelease-product-version }}
set-ld-flags: ${{ steps.set-ld-flags.outputs.set-ld-flags }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: set product version
id: set-product-version
uses: hashicorp/actions-set-product-version@v2
- name: set-ld-flags
id: set-ld-flags
run: |
T="github.com/hashicorp/packer-plugin-azure/version"
echo "set-ld-flags=-s -w -X ${T}.Version=${{ steps.set-product-version.outputs.base-product-version }} -X ${T}.VersionPrerelease=${{ steps.set-product-version.outputs.prerelease-product-version }}" >> $GITHUB_OUTPUT
- name: validate outputs
run: |
echo "Product Version: ${{ steps.set-product-version.outputs.product-version }}"
echo "Base Product Version: ${{ steps.set-product-version.outputs.base-product-version }}"
echo "Prerelease Version: ${{ steps.set-product-version.outputs.prerelease-product-version }}"
echo "ldflags: ${{ steps.set-ld-flags.outputs.set-ld-flags }}"
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Generate metadata file
id: generate-metadata-file
uses: hashicorp/actions-generate-metadata@main
with:
version: ${{ needs.set-product-version.outputs.product-version }}
product: ${{ env.REPO_NAME }}
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: metadata.json
path: ${{ steps.generate-metadata-file.outputs.filepath }}
plugin-check:
needs: get-go-version
runs-on: ubuntu-latest
outputs:
api_version: ${{ steps.plugin_describe.outputs.api_version }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}
- name: Describe plugin
id: plugin_describe
run: echo "api_version=$(go run . describe | jq -r '.api_version')" >> "$GITHUB_OUTPUT"
- name: Run test
run: go test ./...
- name: Make plugin-check
run: make plugin-check
build-other:
needs:
- set-product-version
- get-go-version
- plugin-check
runs-on: ubuntu-latest
strategy:
matrix:
goos: [ freebsd, windows, netbsd, openbsd, solaris ]
goarch: [ "386", "amd64", "arm"]
go: [ "${{ needs.get-go-version.outputs.go-version }}" ]
exclude:
- goos: solaris
goarch: 386
- goos: solaris
goarch: arm
- goos: windows
goarch: arm
fail-fast: true
name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Go Build
env:
PRODUCT_VERSION: ${{ needs.set-product-version.outputs.product-version }}
PRERELEASE_VERSION: ${{ needs.set-product-version.outputs.product-prerelease-version }}
LD_FLAGS: "${{ needs.set-product-version.outputs.set-ld-flags}}"
CGO_ENABLED: "0"
uses: hashicorp/actions-go-build@v1
with:
bin_name: ${{ env.REPO_NAME }}_v${{ needs.set-product-version.outputs.product-version }}_${{ needs.plugin-check.outputs.api_version }}_${{ matrix.goos }}_${{ matrix.goarch }}
product_name: ${{ env.REPO_NAME }}
product_version: ${{ needs.set-product-version.outputs.product-version }}
go_version: ${{ matrix.go }}
os: ${{ matrix.goos }}
arch: ${{ matrix.goarch }}
reproducible: report
instructions: |-
cp LICENSE "$TARGET_DIR/LICENSE.txt"
go build -o "$BIN_PATH" -ldflags="$LD_FLAGS" -trimpath -buildvcs=false
build-linux:
needs:
- set-product-version
- get-go-version
- plugin-check
runs-on: ubuntu-latest
strategy:
matrix:
goos: [ linux ]
goarch: [ "arm", "arm64", "386", "amd64"]
go: [ "${{ needs.get-go-version.outputs.go-version }}" ]
fail-fast: true
name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Go Build
env:
PRODUCT_VERSION: ${{ needs.set-product-version.outputs.product-version }}
PRERELEASE_VERSION: ${{ needs.set-product-version.outputs.product-prerelease-version }}
LD_FLAGS: "${{ needs.set-product-version.outputs.set-ld-flags}}"
CGO_ENABLED: "0"
uses: hashicorp/actions-go-build@v1
with:
bin_name: ${{ env.REPO_NAME }}_v${{ needs.set-product-version.outputs.product-version }}_${{ needs.plugin-check.outputs.api_version }}_${{ matrix.goos }}_${{ matrix.goarch }}
product_name: ${{ env.REPO_NAME }}
product_version: ${{ needs.set-product-version.outputs.product-version }}
go_version: ${{ matrix.go }}
os: ${{ matrix.goos }}
arch: ${{ matrix.goarch }}
reproducible: report
instructions: |-
cp LICENSE "$TARGET_DIR/LICENSE.txt"
go build -o "$BIN_PATH" -ldflags="$LD_FLAGS" -trimpath -buildvcs=false
build-darwin:
needs:
- set-product-version
- get-go-version
- plugin-check
runs-on: macos-latest
strategy:
matrix:
goos: [ darwin ]
goarch: [ "amd64", "arm64" ]
go: [ "${{ needs.get-go-version.outputs.go-version }}" ]
fail-fast: true
name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Go Build
env:
PRODUCT_VERSION: ${{ needs.set-product-version.outputs.product-version }}
PRERELEASE_VERSION: ${{ needs.set-product-version.outputs.product-prerelease-version }}
LD_FLAGS: "${{ needs.set-product-version.outputs.set-ld-flags}}"
CGO_ENABLED: "0"
uses: hashicorp/actions-go-build@v1
with:
bin_name: ${{ env.REPO_NAME }}_v${{ needs.set-product-version.outputs.product-version }}_${{ needs.plugin-check.outputs.api_version }}_${{ matrix.goos }}_${{ matrix.goarch }}
product_name: ${{ env.REPO_NAME }}
product_version: ${{ needs.set-product-version.outputs.product-version }}
go_version: ${{ matrix.go }}
os: ${{ matrix.goos }}
arch: ${{ matrix.goarch }}
reproducible: report
instructions: |-
cp LICENSE "$TARGET_DIR/LICENSE.txt"
go build -o "$BIN_PATH" -ldflags="$LD_FLAGS" -trimpath -buildvcs=false
upload-manifest-json:
needs:
- set-product-version
- plugin-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: create-manifest-json
id: create-manifest-json
run: |
API_VERSION="${{ needs.plugin-check.outputs.api_version }}"
CLEAN_API_VERSION="${API_VERSION#x}"
sed -e "s/PLACEHOLDER_PROTOCOL_VERSION/${CLEAN_API_VERSION}/g" \
manifest.json > ${{ env.REPO_NAME }}_${{ needs.set-product-version.outputs.product-version }}_manifest.json
- name: Upload manifest json
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: packer-plugin-manifest.json
path: ${{ env.REPO_NAME }}_${{ needs.set-product-version.outputs.product-version }}_manifest.json