-
Notifications
You must be signed in to change notification settings - Fork 1
105 lines (95 loc) · 3.36 KB
/
Copy pathrelease.yml
File metadata and controls
105 lines (95 loc) · 3.36 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
name: Release
on:
workflow_dispatch:
inputs:
version:
description: "Version override (e.g. v1.2.3). Leave empty to auto-detect via git-cliff."
required: false
default: ""
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
ref: main
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Ensure tags are available
run: git fetch --force --tags
- name: Configure git identity
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Run tests
run: go test ./...
- name: Determine version via git-cliff
id: cliff
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: --bumped-version
- name: Resolve release version
id: version
env:
CLIFF_OUTPUT: ${{ steps.cliff.outputs.content }}
INPUT_VERSION: ${{ inputs.version }}
run: |
DETECTED_VERSION="$(echo "$CLIFF_OUTPUT" | tr -d '[:space:]')"
VERSION="$INPUT_VERSION"
if [ -z "$VERSION" ]; then
VERSION="$DETECTED_VERSION"
fi
if [ -z "$VERSION" ]; then
echo "Error: could not determine version. Use the version override input." >&2
exit 1
fi
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: resolved version '$VERSION' is not semver (vX.Y.Z)." >&2
exit 1
fi
if git rev-parse -q --verify "refs/tags/$VERSION" >/dev/null; then
echo "Error: tag '$VERSION' already exists. Set workflow input 'version' to a new value." >&2
exit 1
fi
echo "Releasing $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Generate changelog
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: --tag ${{ steps.version.outputs.version }} -o CHANGELOG.md
- name: Re-render integrations with release version
env:
TAPPER_PLUGIN_VERSION: ${{ steps.version.outputs.version }}
run: go run ./cmd/render-integrations
- name: Commit and push release atomically
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
git add CHANGELOG.md integrations/rendered
if git diff --staged --quiet; then
echo "Error: no release artifacts staged. Expected CHANGELOG and rendered integrations to change." >&2
exit 1
fi
git commit -m "chore: release $VERSION"
git tag -a "$VERSION" -m "$VERSION"
git push origin main "refs/tags/$VERSION"
- name: Ensure clean tree for goreleaser
run: |
git clean -ffdx
test -z "$(git status --porcelain)" || { git status --porcelain; exit 1; }
- name: Run goreleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}