-
Notifications
You must be signed in to change notification settings - Fork 23
131 lines (115 loc) · 3.26 KB
/
publish-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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Publish release
on:
workflow_dispatch:
inputs:
version:
description: >-
Version to release (e.g. v1.2.3).
Uses latest version from changelog if unset.
default: ''
type: string
ref:
description: Git ref to release from.
required: true
type: string
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
token: ${{ secrets.PAT }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Query changie
if: inputs.version == ''
id: changie-latest
uses: miniscruff/changie-action@v2
with:
args: latest
- name: Set version (changie)
if: inputs.version == ''
run:
echo "VERSION=${CHANGIE_VERSION#v}" >> "$GITHUB_ENV"
env:
CHANGIE_VERSION: ${{ steps.changie-latest.outputs.output }}
- name: Set version (input)
if: inputs.version != ''
run:
echo "VERSION=${INPUT_VERSION#v}" >> "$GITHUB_ENV"
env:
INPUT_VERSION: ${{ inputs.version }}
- name: Verify version
run: |
if [[ -z "$VERSION" ]]; then
echo "No version set"
exit 1
fi
- name: Extract changelog
run: |
tail -n+2 .changes/v${{ env.VERSION }}.md \
| tee ${{ github.workspace }}-CHANGELOG.txt
- name: Tag a release
run: |
git tag "$TAG"
git push origin "$TAG"
env:
TAG: v${{ env.VERSION }}
- name: Release
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --clean --release-notes ${{ github.workspace }}-CHANGELOG.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AUR_KEY: ${{ secrets.AUR_KEY }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: v${{ env.VERSION }}
# Run only if the release was successful.
homebrew:
name: Bump Homebrew Formula
runs-on: ubuntu-latest
needs: [release]
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Query changie
if: inputs.version == ''
id: changie-latest
uses: miniscruff/changie-action@v2
with:
args: latest
- name: Set version (changie)
if: inputs.version == ''
run:
echo "VERSION=${CHANGIE_VERSION#v}" >> "$GITHUB_ENV"
env:
CHANGIE_VERSION: ${{ steps.changie-latest.outputs.output }}
- name: Set version (input)
if: inputs.version != ''
run:
echo "VERSION=${INPUT_VERSION#v}" >> "$GITHUB_ENV"
env:
INPUT_VERSION: ${{ inputs.version }}
- name: Verify version
run: |
if [[ -z "$VERSION" ]]; then
echo "No version set"
exit 1
fi
- name: Update Homebrew Formula
uses: dawidd6/[email protected]
with:
token: ${{ secrets.ROBOT_PAT }}
user_name: Abhinav Gupta
user_email: "[email protected]"
formula: git-spice
tag: v${{ env.VERSION }}