-
Notifications
You must be signed in to change notification settings - Fork 7
169 lines (144 loc) · 5.51 KB
/
build.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
name: Build
on:
push:
branches: [master, main]
tags: ['v*']
pull_request:
branches: [master, main]
env:
CARGO_TERM_COLOR: always
ext_release: ${{ (github.event_name == 'push' && contains(github.ref, 'refs/tags/v') && !(contains(github.ref, 'beta') || contains(github.ref, 'alpha'))) && '1' || '0' }}
ext_type: ${{ (github.event_name == 'push' && contains(github.ref, 'refs/tags/v') && !(contains(github.ref, 'beta') || contains(github.ref, 'alpha'))) && 'xpi' || 'zip' }}
jobs:
build:
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
name: 'Build on ${{matrix.os}}'
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
# ╭─────────────────────────────╮
# │ Build extension and overlay │
# ╰─────────────────────────────╯
- name: Install Node.js
uses: actions/setup-node@v4
with:
# https://github.com/parcel-bundler/parcel/issues/9926
# node-version: latest
node-version: 22.6
- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
version: latest
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: JS Build (no release)
run: pnpm run --if-present -r build
if: ${{ env.ext_release == '0' }}
- name: JS Build (release)
run: pnpm run --if-present -r release
if: ${{ env.ext_release == '1' }}
env:
WEB_EXT_API_KEY: ${{ secrets.WEB_EXT_API_KEY }}
WEB_EXT_API_SECRET: ${{ secrets.WEB_EXT_API_SECRET }}
- run: 7z a artifacts\client.zip .\js\client\dist\*
# ╭──────────────────╮
# │ Build executable │
# ╰──────────────────╯
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --release --locked
# ╭───────────────────╮
# │ Upload articfacts │
# ╰───────────────────╯
- uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'windows-latest' }}
with:
name: current-song2.exe
path: target/release/current-song2.exe
- uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'windows-latest' }}
with:
name: extension.${{ env.ext_type }}
path: js/extension/artifacts/*.${{ env.ext_type }}
- uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'windows-latest' }}
with:
name: client.zip
path: artifacts/client.zip
create-release:
needs: [build]
runs-on: ubuntu-latest
if: (github.event_name == 'push' && (contains(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'))
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
- run: ls -la artifacts
- name: Get changelog (release)
if: contains(github.ref, 'refs/tags/v')
run: |
cat CHANGELOG.md | perl -0777nle 'print for /\n## \[v[^\n]++\s+((?:\s+|(?:[^#]|#{3,})[^\n]*\s+)*)/' > body.txt
- name: Get changelog (nightly)
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
run: |
cat CHANGELOG.md | perl -0777nle 'print for /\n## \[Unreleased\]\s+((?:\s+|(?:[^#]|#{3,})[^\n]*\s+)*)/g' > body.txt
- name: Hash Files
run: |
echo "### Hashes" >> body.txt
echo "| File | Hash |" >> body.txt
echo "|---|---|" >> body.txt
for file in $(find artifacts);
do
if [ ! -d "$file" ]; then
echo "| $(basename -- "$file") | $(sha256sum "$file" | cut -d " " -f 1) |" >> body.txt;
fi;
done
shell: bash
- name: Regular release
uses: ncipollo/release-action@v1
if: contains(github.ref, 'refs/tags/v')
with:
artifacts: 'artifacts/**/*'
token: ${{ secrets.GITHUB_TOKEN }}
generateReleaseNotes: false
allowUpdates: true
draft: true
bodyFile: body.txt
prerelease: ${{ env.ext_release == '0' }}
- name: Nightly release
uses: ncipollo/release-action@v1
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
with:
artifacts: 'artifacts/**/*'
token: ${{ secrets.GITHUB_TOKEN }}
generateReleaseNotes: false
replacesArtifacts: true
allowUpdates: true
bodyFile: body.txt
prerelease: true
name: Nightly Release
tag: nightly-build
- name: Update nightly-build tag
run: |
git tag -f nightly-build
git push -f origin nightly-build