Skip to content

Bump version to 0.0.3 #3

Bump version to 0.0.3

Bump version to 0.0.3 #3

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
permissions:
contents: read
jobs:
verify:
name: Verify tag
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.value }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Ensure tag points to main
shell: bash
run: |
git fetch origin main
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
echo "Tag ${GITHUB_REF_NAME} must reference a commit reachable from origin/main." >&2
exit 1
fi
- name: Run tests
run: go test ./...
- name: Extract version
id: version
shell: bash
run: echo "value=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
build:
name: Build ${{ matrix.archive_name }}
needs: verify
runs-on: ${{ matrix.runs-on }}
strategy:
matrix:
include:
- runs-on: windows-latest
goos: windows
goarch: amd64
binary_name: sbl.exe
archive_name: sbl-windows-x86_64
archive_ext: zip
- runs-on: ubuntu-latest
goos: linux
goarch: amd64
binary_name: sbl
archive_name: sbl-linux-x86_64
archive_ext: tar.gz
- runs-on: macos-latest
goos: darwin
goarch: arm64
binary_name: sbl
archive_name: sbl-macos-arm64
archive_ext: tar.gz
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Build release binary (Windows)
if: runner.os == 'Windows'
shell: pwsh
env:
CGO_ENABLED: 0
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
VERSION: ${{ needs.verify.outputs.version }}
run: |
New-Item -ItemType Directory -Force -Path dist | Out-Null
go build -trimpath -ldflags "-s -w -X main.version=$env:VERSION" -o "dist\${{ matrix.binary_name }}" ./cmd/sbl
- name: Build release binary (Unix)
if: runner.os != 'Windows'
shell: bash
env:
CGO_ENABLED: 0
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
VERSION: ${{ needs.verify.outputs.version }}
run: |
mkdir -p dist
go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o "dist/${{ matrix.binary_name }}" ./cmd/sbl
- name: Create archive (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$archive = "${{ matrix.archive_name }}-${{ github.ref_name }}.${{ matrix.archive_ext }}"
Compress-Archive -Path "dist\${{ matrix.binary_name }}" -DestinationPath "dist\$archive" -Force
- name: Create archive (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
archive="${{ matrix.archive_name }}-${{ github.ref_name }}.${{ matrix.archive_ext }}"
chmod +x "dist/${{ matrix.binary_name }}"
tar -C dist -czf "dist/$archive" "${{ matrix.binary_name }}"
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.archive_name }}-${{ github.ref_name }}
path: dist/${{ matrix.archive_name }}-${{ github.ref_name }}.${{ matrix.archive_ext }}
if-no-files-found: error
retention-days: 1
release:
name: Create GitHub release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download release artifacts
uses: actions/download-artifact@v8
with:
path: ./artifacts
pattern: sbl-*
merge-multiple: true
- name: Create or update release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}
generate_release_notes: true
files: |
./artifacts/sbl-windows-x86_64-${{ github.ref_name }}.zip
./artifacts/sbl-linux-x86_64-${{ github.ref_name }}.tar.gz
./artifacts/sbl-macos-arm64-${{ github.ref_name }}.tar.gz