forked from boidushya/better-lyrics
-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (119 loc) · 4.1 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
name: Release & Publish
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
RELEASE_EXISTS: ${{ steps.release_exists.outputs.RELEASE_EXISTS }}
steps:
- uses: actions/checkout@v3
- name: "Install and setup jq"
uses: dcarbone/install-jq-action@v2
- name: Read version from manifest.json
id: read_version
run: |
VERSION=$(jq -r '.version' manifest.json)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "TAG=v$VERSION" >> $GITHUB_OUTPUT
- name: Check if release exists
id: release_exists
run: |
TAG_NAME="${{ steps.read_version.outputs.tag }}"
API_URL="${{ github.api_url }}/repos/${{ github.repository }}/releases/tags/${TAG_NAME}"
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "$API_URL")
if [[ $RESPONSE -eq 200 ]]; then
echo "RELEASE_EXISTS=true" >> $GITHUB_OUTPUT
echo "Release exists, skipping build and publish steps"
else
echo "RELEASE_EXISTS=false" >> $GITHUB_OUTPUT
echo "Release does not exist, continuing with build and publish steps"
fi
- name: Run build script
if: steps.release_exists.outputs.RELEASE_EXISTS == 'false'
run: |
npm install -g postcss postcss-cli autoprefixer cssnano
bash scripts/build.sh
shell: bash
- name: Upload artifact
if: steps.release_exists.outputs.RELEASE_EXISTS == 'false'
uses: actions/upload-artifact@v4
with:
name: better-lyrics
path: dist/
- name: Create GitHub Release
if: steps.release_exists.outputs.RELEASE_EXISTS == 'false'
uses: ncipollo/release-action@v1
with:
artifacts: "dist/better-lyrics-chrome.zip,dist/better-lyrics-edge.zip,dist/better-lyrics-firefox.zip"
tag: ${{ steps.read_version.outputs.tag }}
generateReleaseNotes: true
skipIfReleaseExists: true
publish-chrome:
name: Publish to Chrome Web Store
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.RELEASE_EXISTS == 'false'
env:
EXTENSION_ID: effdbpeggelllpfkjppbokhmmiinhlmg
CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
REFRESH_TOKEN: ${{ secrets.GOOGLE_REFRESH_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: better-lyrics
path: dist/
- name: Publish to Chrome Web Store
run: |
bash scripts/publish-chrome.sh
publish-firefox:
name: Publish to Firefox Add-ons
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.RELEASE_EXISTS == 'false'
env:
FIREFOX_JWT_ISSUER: ${{ secrets.FIREFOX_CLIENT_ID }}
FIREFOX_JWT_SECRET: ${{ secrets.FIREFOX_CLIENT_SECRET }}
FIREFOX_EXTENSION_ID: [email protected]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: better-lyrics
path: dist/
- name: Create zip file of source code
run: |
zip -r dist/better-lyrics-src.zip . -x "*www*" "*api*"
- name: Publish to Firefox
run: |
bash scripts/publish-firefox.sh
publish-edge:
name: Publish to Edge Add-ons
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.RELEASE_EXISTS == 'false'
env:
CLIENT_ID: ${{ secrets.EDGE_CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.EDGE_CLIENT_SECRET }}
PRODUCT_ID: ${{ secrets.EDGE_PRODUCT_ID }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: better-lyrics
path: dist/
- name: Publish to Edge
run: |
bash scripts/publish-edge.sh