-
Notifications
You must be signed in to change notification settings - Fork 13
201 lines (169 loc) · 7.95 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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: Publish Release
on:
push:
tags:
- "v*"
jobs:
Github:
name: Github Release (Draft)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "20"
- name: Install standard-version npm package
run: npm install -g standard-version
- name: Generate changelog notes
run: |
curr_release=$(git describe --tags)
prev_release=$(git describe --tags --abbrev=0 $(git rev-list --tags --skip=1 --max-count=1) 2>/dev/null || echo "")
echo ">> ${prev_release}..${curr_release} <<"
git log ${prev_release}..${curr_release} --pretty=format:"%s" > commits.txt
git tag -d "$curr_release"
standard-version --release-as "$curr_release" --skip.commit --skip.tag --dry-run | tail -n +5 | awk '/---/{exit} {print}' > changelog.txt
echo "$curr_release" > release_tag.txt
echo "CHANGELOGS: "
cat changelog.txt
- name: Generate release notes
run: |
cat changelog.txt | tail -n +3 > release_notes.txt
echo "RELEASE NOTES: "
cat release_notes.txt
- name: Install GitHub CLI - gh
run: |
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
- name: Configure GitHub CLI - gh
run: gh auth login --with-token <<< "${{ secrets.GH_PAT }}"
- name: Draft Release
run: |
curr_release=$(cat release_tag.txt)
gh release create --draft "$curr_release" --title "$curr_release" --notes-file release_notes.txt
- name: Configure SSH keys
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_PUBLIC_KEY: ${{ secrets.SSH_PUBLIC_KEY }}
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/proffapt
echo "$SSH_PUBLIC_KEY" > ~/.ssh/proffapt.pub
chmod 600 ~/.ssh/proffapt
chmod 600 ~/.ssh/proffapt.pub
- name: Clean repository
run: |
rm commits.txt release_notes.txt
git checkout -b main
git pull origin main
git fetch --tags
- name: Update changelog file
run: |
changelog_file=".github/CHANGELOG.md"
logs=$(cat changelog.txt)
if [ -s "$changelog_file" ]; then
old_logs=$(tail -n +2 "$changelog_file")
latest_tag=$(cat release_tag.txt)
if grep -q "${latest_tag}" "$changelog_file"; then
echo "Changelog already up-to-date"
else
echo -e "# CHANGELOG\n\n $logs\n\n $old_logs" > "$changelog_file"
echo "Changelog updated successfully"
fi
else
echo -e "# CHANGELOG\n\n $logs" > "$changelog_file"
echo "Changelog generated successfully"
fi
- name: Update version in manifest files
run: |
latest_tag=$(cat release_tag.txt)
latest_release=${latest_tag#v}
sed -i "s/\"version\": .*/\"version\": \"${latest_release}\",/" extension-src/chrome/manifest.json
sed -i "s/\"version\": .*/\"version\": \"${latest_release}\",/" extension-src/firefox/manifest.json
- name: Configure git
run: |
git config user.email "[email protected]"
git config user.name "proffapt"
git config gpg.format ssh
git config user.signingkey ~/.ssh/proffapt.pub
- name: Commit & push changes
run: |
rm changelog.txt
files=(".github/CHANGELOG.md" "extension-src/")
for file in "${files[@]}"; do
if [ -n "$(git status --porcelain $file)" ]; then
git add $file
if [ "$file" == ".github/CHANGELOG.md" ]; then
git commit -S -m "docs(changelog): update $(basename $file)"
else
git commit -S -m "chore(release): bump version in manifest files"
fi
else
echo "No changes in $file."
fi
done
git push origin $(git rev-parse --abbrev-ref HEAD)
Chrome:
name: Chrome Web Store Release (Publish)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "20"
- name: Install chrome-webstore-upload-cli npm package
run: npm install -g chrome-webstore-upload-cli
- name: Update version in manifest file
working-directory: extension-src/chrome
run: |
latest_tag=$(git describe --tags)
latest_release=${latest_tag#v}
sed -i "s/\"version\": .*/\"version\": \"${latest_release}\",/" manifest.json
- name: Release to Chrome Web Store
working-directory: extension-src/chrome
run: chrome-webstore-upload upload --auto-publish
env:
EXTENSION_ID: ${{ secrets.GOOGLE_EXTENSION_ID }}
CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
REFRESH_TOKEN: ${{ secrets.GOOGLE_REFRESH_TOKEN }}
Firefox:
name: Mozilla Add-On Store Release (Publish)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "20"
- name: Install web-ext npm package
run: npm install -g web-ext
- name: Update version in manifest file
working-directory: extension-src/firefox
run: |
latest_tag=$(git describe --tags)
latest_release=${latest_tag#v}
sed -i "s/\"version\": .*/\"version\": \"${latest_release}\",/" manifest.json
- name: Build the extension
working-directory: extension-src/firefox
run: web-ext build
- name: Release to Mozilla Add-On Store
working-directory: extension-src/firefox
run: web-ext sign --use-submission-api --channel listed
env:
WEB_EXT_API_KEY: ${{ secrets.WEB_EXT_API_KEY }}
WEB_EXT_API_SECRET: ${{ secrets.WEB_EXT_API_SECRET }}