131 lines
3.4 KiB
YAML
131 lines
3.4 KiB
YAML
name: Release
|
|
|
|
env:
|
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: 'Tag to release (e.g. v0.1.0).'
|
|
required: true
|
|
type: string
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
resolve:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
ref: ${{ steps.ref.outputs.ref }}
|
|
tag: ${{ steps.ref.outputs.tag }}
|
|
steps:
|
|
- name: Resolve ref
|
|
id: ref
|
|
run: |
|
|
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
|
|
echo "ref=${{ github.ref }}" >> "$GITHUB_OUTPUT"
|
|
echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "ref=${{ github.ref }}" >> "$GITHUB_OUTPUT"
|
|
echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
build:
|
|
name: Build ${{ matrix.suffix }}
|
|
needs: resolve
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- goos: linux
|
|
goarch: amd64
|
|
suffix: linux-amd64
|
|
- goos: linux
|
|
goarch: arm64
|
|
suffix: linux-arm64
|
|
- goos: linux
|
|
goarch: arm
|
|
goarm: '6'
|
|
suffix: linux-armv6
|
|
- goos: darwin
|
|
goarch: amd64
|
|
suffix: darwin-amd64
|
|
- goos: darwin
|
|
goarch: arm64
|
|
suffix: darwin-arm64
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
ref: ${{ needs.resolve.outputs.ref }}
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version-file: go.mod
|
|
check-latest: true
|
|
|
|
- name: Build
|
|
env:
|
|
GOOS: ${{ matrix.goos }}
|
|
GOARCH: ${{ matrix.goarch }}
|
|
GOARM: ${{ matrix.goarm }}
|
|
CGO_ENABLED: '0'
|
|
run: |
|
|
mkdir -p dist
|
|
out="dist/bootstrap_environment-${{ matrix.suffix }}"
|
|
echo "==> Building $out (GOOS=$GOOS GOARCH=$GOARCH GOARM=${GOARM:-n/a})"
|
|
go build -trimpath -ldflags="-s -w" -o "$out" .
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: bootstrap_environment-${{ matrix.suffix }}
|
|
path: dist/bootstrap_environment-${{ matrix.suffix }}
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
|
|
release:
|
|
needs: [resolve, build]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
ref: ${{ needs.resolve.outputs.ref }}
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Download build artifacts
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
path: dist
|
|
pattern: bootstrap_environment-*
|
|
merge-multiple: true
|
|
|
|
- name: Generate SHA256SUMS
|
|
working-directory: dist
|
|
run: |
|
|
ls -l
|
|
sha256sum bootstrap_environment-* > SHA256SUMS
|
|
cat SHA256SUMS
|
|
|
|
- name: Create release
|
|
uses: softprops/action-gh-release@v3
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
tag_name: ${{ needs.resolve.outputs.tag }}
|
|
name: ${{ needs.resolve.outputs.tag }}
|
|
target_commitish: ${{ github.sha }}
|
|
generate_release_notes: true
|
|
fail_on_unmatched_files: true
|
|
files: |
|
|
dist/bootstrap_environment-*
|
|
dist/SHA256SUMS
|