-
-
Notifications
You must be signed in to change notification settings - Fork 5
75 lines (67 loc) · 2.42 KB
/
release.yml
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
name: goreleaser
on:
push:
tags:
# This is not a real version tag, its just used to trigger
# the release build. Glob pattern:
- "prepare-v[0-9]+.[0-9]+.[0-9]+*"
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.20"
- name: Import GPG Key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- name: Store Git Tag
id: "getTag"
run: |
echo ::set-output name=releaseTag::$(echo "${GITHUB_REF##*prepare-}")
echo ::set-output name=triggerTag::$(echo "${GITHUB_REF##*/}")
- name: "Tag release commit"
env:
RELEASE_TAG: ${{ steps.getTag.outputs.releaseTag }}
TRIGGER_TAG: ${{ steps.getTag.outputs.triggerTag }}
run: |
git config user.name 'githooks-bot'
git config user.email '[email protected]'
deref() { git for-each-ref "refs/tags/$TRIGGER_TAG" --format="%($1)" ; };
git tag "$RELEASE_TAG" -a -m "$(deref contents)"
git tag "githooks/$RELEASE_TAG"
- name: Safety Check
env:
RELEASE_TAG: ${{ steps.getTag.outputs.releaseTag }}
run: |
git fetch --depth 50 origin main
[ -n "$(git rev-list --first-parent --ancestry-path "$RELEASE_TAG^..origin/main")" ] || {
echo "Tag is not reachable from main (--first-parent) !" >&2
exit 1
}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
workdir: githooks
args: release --clean
env:
GORELEASER_CURRENT_TAG: ${{ steps.getTag.outputs.releaseTag }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
- name: "Push release tags and delete trigger tag"
env:
RELEASE_TAG: ${{ steps.getTag.outputs.releaseTag }}
TRIGGER_TAG: ${{ steps.getTag.outputs.triggerTag }}
run: |
# go releaser already pushed release tag
git push origin "githooks/$RELEASE_TAG"
git push -f origin ":$TRIGGER_TAG"