Skip to content

Commit dfe0209

Browse files
committed
Make automatic releases with semantic-release
1 parent c4b7d58 commit dfe0209

20 files changed

+225
-38
lines changed

.github/workflows/pre-commit.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v5
1616
- uses: actions/setup-python@v5
17+
- uses: actions/setup-node@v4
18+
19+
- run: npm install
20+
1721
- uses: pre-commit/[email protected]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: semantic-release-dry-run
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches-ignore:
7+
- main
8+
9+
jobs:
10+
semantic-release-dry-run:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os:
15+
- ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v5
18+
with:
19+
fetch-depth: 0
20+
- uses: actions/setup-node@v4
21+
22+
- run: npm install
23+
- run: npx semantic-release --dry-run
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
27+
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
28+
GOOGLE_REFRESH_TOKEN: ${{ secrets.GOOGLE_REFRESH_TOKEN }}
29+
WEB_EXT_API_KEY: UNSET
30+
WEB_EXT_API_SECRET: UNSET

.github/workflows/release.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: semantic-release
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_run:
6+
workflows:
7+
- pre-commit
8+
types:
9+
- completed
10+
branches:
11+
- main
12+
13+
permissions:
14+
contents: write
15+
issues: write
16+
pull-requests: write
17+
18+
jobs:
19+
semantic-release:
20+
runs-on: ${{ matrix.os }}
21+
strategy:
22+
matrix:
23+
os:
24+
- ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v5
27+
with:
28+
fetch-depth: 0
29+
- uses: actions/setup-node@v4
30+
31+
- run: npm install
32+
- run: npx semantic-release
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
36+
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
37+
GOOGLE_REFRESH_TOKEN: ${{ secrets.GOOGLE_REFRESH_TOKEN }}
38+
WEB_EXT_API_KEY: ${{ secrets.WEB_EXT_API_KEY }}
39+
WEB_EXT_API_SECRET: ${{ secrets.WEB_EXT_API_SECRET }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/*.xpi
12
/*.zip
23
/.claude/
4+
/dist-chrome/
5+
/dist-firefox/
36
/node_modules/

.pre-commit-config.yaml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,10 @@ repos:
55

66
- id: eslint
77
name: eslint
8-
entry: eslint
9-
language: node
8+
entry: npx eslint --no-warn-ignored
9+
language: system
1010
types_or:
1111
- javascript
12-
additional_dependencies:
13-
- "@eslint/[email protected]"
14-
- "@stylistic/[email protected]"
15-
16-
1712

1813
- id: translation-check
1914
name: translation-check
@@ -33,13 +28,11 @@ repos:
3328

3429
- id: web-ext lint
3530
name: web-ext lint
36-
entry: web-ext lint
37-
language: node
31+
entry: bash -c "./bin/prepare-chrome.sh 0.0.0 && ./bin/prepare-firefox.sh 0.0.0 && npx web-ext lint --source-dir dist-firefox/"
32+
language: system
3833
types_or:
3934
- javascript
4035
pass_filenames: false
41-
additional_dependencies:
42-
4336

4437
- repo: https://github.com/rhysd/actionlint
4538
rev: v1.7.7

.releaserc.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"branches": [
3+
"main"
4+
],
5+
"plugins": [
6+
"@semantic-release/commit-analyzer",
7+
"@semantic-release/release-notes-generator",
8+
[
9+
"@semantic-release/exec",
10+
{
11+
"prepareCmd": "./bin/prepare-firefox.sh ${nextRelease.version}"
12+
}
13+
],
14+
[
15+
"@semantic-release/exec",
16+
{
17+
"publishCmd": "npx web-ext sign --channel unlisted --source-dir dist-firefox --artifacts-dir ."
18+
}
19+
],
20+
[
21+
"@semantic-release/github",
22+
{
23+
"assets": [
24+
{
25+
"label": "Firefox Add-on",
26+
"path": "*.xpi"
27+
}
28+
],
29+
"draftRelease": true,
30+
"failCommentCondition": false,
31+
"releasedLabels": false,
32+
"successCommentCondition": "<% return issue.user.type !== 'Bot'; %>"
33+
}
34+
]
35+
],
36+
"tagFormat": "${version}"
37+
}

bin/prepare-chrome.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit -o nounset -o pipefail -o xtrace
4+
5+
SCRIPT_DIRECTORY=$(dirname "${BASH_SOURCE:-$0}" | xargs realpath)
6+
declare -r SCRIPT_DIRECTORY
7+
8+
ROOT_DIRECTORY=$(realpath "${SCRIPT_DIRECTORY}"/..)
9+
DIST_DIRECTORY="${ROOT_DIRECTORY}/dist-chrome"
10+
11+
rm -rf "${DIST_DIRECTORY}"
12+
mkdir "${DIST_DIRECTORY}"
13+
14+
VERSION=$1
15+
16+
cp "${ROOT_DIRECTORY}"/LICENSE "${DIST_DIRECTORY}"
17+
18+
jq --indent 4 ". | .version |= \"${VERSION}\" | del(.browser_specific_settings) | del(.browser_action.default_icon)" "${ROOT_DIRECTORY}"/manifest.json > "${DIST_DIRECTORY}"/manifest.json
19+
20+
# copy files
21+
cp "${ROOT_DIRECTORY}"/icons/*.{png,svg} "${DIST_DIRECTORY}"
22+
23+
if [ -d "${ROOT_DIRECTORY}"/_locales ]; then
24+
cp -r "${ROOT_DIRECTORY}"/_locales "${DIST_DIRECTORY}"/_locales
25+
fi
26+
if [ -d "${ROOT_DIRECTORY}"/content-scripts ]; then
27+
cp -r "${ROOT_DIRECTORY}"/content-scripts "${DIST_DIRECTORY}"/content-scripts
28+
fi
29+
if [ -d "${ROOT_DIRECTORY}"/options ]; then
30+
cp -r "${ROOT_DIRECTORY}"/options "${DIST_DIRECTORY}"/options
31+
fi
32+
cp "${ROOT_DIRECTORY}"/*.js "${DIST_DIRECTORY}"/
33+
rm "${DIST_DIRECTORY}"/eslint.config.js

bin/prepare-firefox.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit -o nounset -o pipefail -o xtrace
4+
5+
SCRIPT_DIRECTORY=$(dirname "${BASH_SOURCE:-$0}" | xargs realpath)
6+
declare -r SCRIPT_DIRECTORY
7+
8+
ROOT_DIRECTORY=$(realpath "${SCRIPT_DIRECTORY}"/..)
9+
DIST_DIRECTORY="${ROOT_DIRECTORY}/dist-firefox"
10+
11+
rm -rf "${DIST_DIRECTORY}"
12+
mkdir "${DIST_DIRECTORY}"
13+
14+
VERSION=$1
15+
16+
cp "${ROOT_DIRECTORY}"/LICENSE "${DIST_DIRECTORY}"
17+
18+
jq --indent 4 ". | .version |= \"$VERSION\" | .background.scripts |= map(select(. != \"browser-polyfill.js\")) | .icons |= {\"48\": \"icon.svg\"}" "${ROOT_DIRECTORY}"/manifest.json > "${DIST_DIRECTORY}"/manifest.json
19+
20+
# copy files
21+
cp "${ROOT_DIRECTORY}"/icons/*.svg "${DIST_DIRECTORY}"
22+
23+
if [ -d "${ROOT_DIRECTORY}"/_locales ]; then
24+
cp -r "${ROOT_DIRECTORY}"/_locales "${DIST_DIRECTORY}"/_locales
25+
fi
26+
if [ -d "${ROOT_DIRECTORY}"/content-scripts ]; then
27+
cp -r "${ROOT_DIRECTORY}"/content-scripts "${DIST_DIRECTORY}"/content-scripts
28+
fi
29+
if [ -d "${ROOT_DIRECTORY}"/options ]; then
30+
cp -r "${ROOT_DIRECTORY}"/options "${DIST_DIRECTORY}"/options
31+
fi
32+
cp "${ROOT_DIRECTORY}"/*.js "${DIST_DIRECTORY}"/
33+
rm "${DIST_DIRECTORY}"/eslint.config.js
34+
35+
if test -f rm "${DIST_DIRECTORY}"/browser-polyfill.js; then
36+
rm "${DIST_DIRECTORY}"/browser-polyfill.js
37+
fi
38+
39+
# shellcheck disable=2046
40+
sed --in-place --regexp-extended '/browser-polyfill.js/d' $(find "${DIST_DIRECTORY}" -name '*.js' -o -name '*.html')

bin/svg-to-png.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit -o nounset -o pipefail -o xtrace
4+
5+
SCRIPT_DIRECTORY=$(dirname "${BASH_SOURCE:-$0}" | xargs realpath)
6+
declare -r SCRIPT_DIRECTORY
7+
8+
ROOT_DIRECTORY=$(realpath "${SCRIPT_DIRECTORY}"/..)
9+
ICON_DIRECTORY="${ROOT_DIRECTORY}/icons"
10+
11+
for size in 16x16 32x32 48x48 64x64 128x128 440x280; do
12+
convert \
13+
-background none \
14+
-density 1000 \
15+
-resize ${size} \
16+
-extent ${size} \
17+
-gravity center \
18+
"${ICON_DIRECTORY}"/icon.svg \
19+
"${ICON_DIRECTORY}"/icon-${size}.png \
20+
;
21+
done
File renamed without changes.

0 commit comments

Comments
 (0)