-
Notifications
You must be signed in to change notification settings - Fork 21
113 lines (101 loc) · 3.15 KB
/
Copy pathrelease.yml
File metadata and controls
113 lines (101 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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