Skip to content

Release

Release #8

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
tag:
description: "Release tag (e.g. v2.0.0). Must match v<major>.<minor>.<patch>[-suffix]."
required: true
type: string
release_notes:
description: "Release notes body (markdown). Optional."
required: false
type: string
permissions:
contents: write
concurrency:
group: release-${{ inputs.tag }}
cancel-in-progress: false
jobs:
validate:
name: Validate inputs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check tag format
run: |
echo "${{ inputs.tag }}" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9.]+)?$' \
|| { echo "Invalid tag: ${{ inputs.tag }}"; exit 1; }
- name: Ensure tag does not already exist
run: |
if git rev-parse "refs/tags/${{ inputs.tag }}" >/dev/null 2>&1; then
echo "Tag ${{ inputs.tag }} already exists — pick a new one."
exit 1
fi
build:
name: Build ${{ matrix.goos }}/${{ matrix.goarch }}
needs: validate
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- { goos: linux, goarch: amd64, ext: "" }
- { goos: linux, goarch: arm64, ext: "" }
- { goos: windows, goarch: amd64, ext: ".exe" }
- { goos: windows, goarch: arm64, ext: ".exe" }
- { goos: darwin, goarch: amd64, ext: "" }
- { goos: darwin, goarch: arm64, ext: "" }
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: true
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "0"
run: |
set -euo pipefail
VERSION="${{ inputs.tag }}"
VERSION_NO_V="${VERSION#v}"
OUT="mssqlhound-${VERSION}-${GOOS}-${GOARCH}${{ matrix.ext }}"
mkdir -p dist
go build -trimpath \
-ldflags "-s -w -X main.version=${VERSION_NO_V}" \
-o "dist/${OUT}" ./cmd/mssqlhound
ls -lh dist/
- uses: actions/upload-artifact@v4
with:
name: mssqlhound-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/*
if-no-files-found: error
retention-days: 7
release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Generate SHA256 checksums
working-directory: dist
run: |
sha256sum * > checksums.txt
echo "--- checksums.txt ---"
cat checksums.txt
- name: Create release and upload assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.tag }}
name: ${{ inputs.tag }}
body: ${{ inputs.release_notes }}
target_commitish: ${{ github.sha }}
draft: false
prerelease: false
files: dist/*
fail_on_unmatched_files: true