99permissions :
1010 contents : write
1111jobs :
12- test :
13- runs-on : ubuntu-latest
14- steps :
15- - uses : actions/checkout@v5
16- with :
17- ref : main
18- - uses : actions/setup-go@v6
19- with :
20- go-version-file : go.mod
21- - run : go test ./...
22-
2312 release :
24- needs : test
2513 runs-on : ubuntu-latest
2614 steps :
2715 - uses : actions/checkout@v5
4129 git config user.name "github-actions[bot]"
4230 git config user.email "github-actions[bot]@users.noreply.github.com"
4331
32+ - name : Run tests
33+ run : go test ./...
34+
4435 - name : Determine version via git-cliff
4536 id : cliff
46- continue-on-error : true
4737 uses : orhun/git-cliff-action@v4
4838 with :
4939 config : cliff.toml
@@ -56,29 +46,12 @@ jobs:
5646 INPUT_VERSION : ${{ inputs.version }}
5747 run : |
5848 DETECTED_VERSION="$(echo "$CLIFF_OUTPUT" | tr -d '[:space:]')"
59- if [ -z "$DETECTED_VERSION" ]; then
60- LAST_TAG="$(git tag --list 'v*' --sort=-version:refname | head -n1)"
61- if [[ -z "$LAST_TAG" ]]; then
62- DETECTED_VERSION="v0.1.0"
63- echo "git-cliff returned empty; no prior tags found. Falling back to $DETECTED_VERSION"
64- elif [[ "$LAST_TAG" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
65- MAJOR="${BASH_REMATCH[1]}"
66- MINOR="${BASH_REMATCH[2]}"
67- PATCH="${BASH_REMATCH[3]}"
68- DETECTED_VERSION="v${MAJOR}.${MINOR}.$((PATCH + 1))"
69- echo "git-cliff returned empty; falling back to patch bump from $LAST_TAG -> $DETECTED_VERSION"
70- else
71- echo "Error: latest tag '$LAST_TAG' is not semver (vX.Y.Z). Set workflow input 'version'." >&2
72- exit 1
73- fi
74- fi
75-
7649 VERSION="$INPUT_VERSION"
7750 if [ -z "$VERSION" ]; then
7851 VERSION="$DETECTED_VERSION"
7952 fi
8053 if [ -z "$VERSION" ]; then
81- echo "Error: could not determine version. git-cliff returned nothing (no prior tags?). Use the version override input." >&2
54+ echo "Error: could not determine version. Use the version override input." >&2
8255 exit 1
8356 fi
8457 if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
8962 echo "Error: tag '$VERSION' already exists. Set workflow input 'version' to a new value." >&2
9063 exit 1
9164 fi
92-
9365 echo "Releasing $VERSION"
9466 echo "version=$VERSION" >> "$GITHUB_OUTPUT"
9567
10476 TAPPER_PLUGIN_VERSION : ${{ steps.version.outputs.version }}
10577 run : go run ./cmd/render-integrations
10678
107- - name : Commit release on main
79+ - name : Commit and push release atomically
10880 env :
10981 VERSION : ${{ steps.version.outputs.version }}
11082 run : |
@@ -114,11 +86,20 @@ jobs:
11486 exit 1
11587 fi
11688 git commit -m "chore: release $VERSION"
117- git push origin main
89+ git tag -a "$VERSION" -m "$VERSION"
90+ git push origin main "refs/tags/$VERSION"
11891
119- - name : Tag and push
120- env :
121- VERSION : ${{ steps.version.outputs.version }}
92+ - name : Ensure clean tree for goreleaser
12293 run : |
123- git tag -a "$VERSION" -m "$VERSION"
124- git push origin "refs/tags/$VERSION"
94+ git clean -ffdx
95+ test -z "$(git status --porcelain)" || { git status --porcelain; exit 1; }
96+
97+ - name : Run goreleaser
98+ uses : goreleaser/goreleaser-action@v6
99+ with :
100+ distribution : goreleaser
101+ version : " ~> v2"
102+ args : release --clean
103+ env :
104+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
105+ HOMEBREW_TAP_GITHUB_TOKEN : ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
0 commit comments