-
Notifications
You must be signed in to change notification settings - Fork 20
118 lines (103 loc) · 2.97 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
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 }}
- uses: jdx/mise-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set version (changie)
if: inputs.version == ''
run: |
CHANGIE_VERSION=$(changie latest)
echo "VERSION=${CHANGIE_VERSION#v}" >> "$GITHUB_ENV"
- 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 }}
- uses: jdx/mise-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set version (changie)
if: inputs.version == ''
run: |
CHANGIE_VERSION=$(changie latest)
echo "VERSION=${CHANGIE_VERSION#v}" >> "$GITHUB_ENV"
- 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 }}