-
Notifications
You must be signed in to change notification settings - Fork 6
141 lines (121 loc) · 4.41 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
name: Release & Deploy
on:
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: main
- name: Semver Info
id: semver
uses: cdrani/action-semantic-release-info@fix/current-branch
- name: Update Version
if: steps.semver.outputs.version != ''
run: |
# Package
jq --arg version "${{ steps.semver.outputs.version }}" \
'.version = $version' package.json > tmp && \
mv tmp package.json
# Chrome
jq --arg version "${{ steps.semver.outputs.version }}" \
'.version = $version' src/manifest.chrome.json > tmp && \
mv tmp src/manifest.chrome.json
# Firefox
jq --arg version "${{ steps.semver.outputs.version }}" \
'.version = $version' src/manifest.firefox.json > tmp && \
mv tmp src/manifest.firefox.json
- name: Commit Changes
if: steps.semver.outputs.version != ''
run: |
git config --local user.name "Github Action"
git config user.email "action@github.com"
git diff --quiet || git commit -a -m "docs: bump version to ${{ steps.semver.outputs.git_tag }}"
git tag ${{ steps.semver.outputs.git_tag }}
- name: Push Changes
if: steps.semver.outputs.version != ''
uses: ad-m/github-push-action@master
with:
branch: ${{ github.ref }}
tags: true
- name: Nightly Merge
if: steps.semver.outputs.version != ''
uses: robotology/gh-action-nightly-merge@v1.5.0
with:
allow_ff: true
ff_only: true
stable_branch: 'main'
development_branch: 'develop'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Build Distributable Package
run: pnpm build
- name: Archive Extension Files
if: steps.semver.outputs.version != ''
run: |
function create_zip {
# $1: target browser
if [ "$1" == "firefox" ]; then
jq '
.background = {
"type": "module",
"scripts": ["background.js"]
} |
.browser_specific_settings = {
"gecko": {
"id": "chorus@cdrani.dev",
"strict_min_version": "112.0"
}
}
' dist/manifest.json > dist/manifest.temp.json && mv dist/manifest.temp.json dist/manifest.json
fi
zip -r "chorus-$1.zip" dist/*
}
create_zip chrome
create_zip firefox
- name: Create Release Archive & Notes
if: steps.semver.outputs.version != ''
uses: ncipollo/release-action@v1.12.0
with:
tag: ${{ steps.semver.outputs.git_tag }}
name: ${{ steps.semver.outputs.git_tag }}
body: ${{ steps.semver.outputs.notes }}
artifacts: 'chorus-chrome.zip,chorus-firefox.zip'
- name: Chrome Upload & Publish
if: steps.semver.outputs.version != ''
uses: cdrani/chrome-extension-upload@ci/silent-update-fail
with:
silent-fail: true
file-path: chorus-chrome.zip
client-id: ${{ secrets.CLIENT_ID }}
extension-id: ${{ secrets.EXTENSION_ID }}
client-secret: ${{ secrets.CLIENT_SECRET }}
refresh-token: ${{ secrets.REFRESH_TOKEN }}
- name: FireFox Upload & Publish
if: steps.semver.outputs.version != ''
uses: yayuyokitano/firefox-addon@v0.0.3-alpha
with:
guid: 'chorus@cdrani.dev'
xpi_path: chorus-firefox.zip
api_key: ${{ secrets.AMO_ISSUER }}
api_secret: ${{ secrets.AMO_SECRET }}