diff options
author | MCMXC <16797721+mcmxcdev@users.noreply.github.com> | 2023-07-26 12:19:56 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-26 23:49:56 +0530 |
commit | 11c319e98befda964ea04613650945feff1eaae0 (patch) | |
tree | c9d5ed0c1e3ee4e18f02bf6eee35f033d1f0590e /.github | |
parent | chore: silence deprecated version and unmet peer dependency warnings (diff) | |
download | ferdium-app-11c319e98befda964ea04613650945feff1eaae0.tar.gz ferdium-app-11c319e98befda964ea04613650945feff1eaae0.tar.zst ferdium-app-11c319e98befda964ea04613650945feff1eaae0.zip |
ci: modernize github actions (#1287)
- use `ubuntu-22.04` runner instead of `ubuntu-20.04`
- use `windows-2022` runner instead of `windows-2019`
- use `pnpm/action-setup` instead of handling `pnpm install` manually
- use pnpm-lock.yaml as caching key for actions/cache instead of inexistent package-lock.json
- define `packageManager` config option in `package.json` which is read by `pnpm/action-setup`
---------
Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/builds.yml | 73 |
1 files changed, 35 insertions, 38 deletions
diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 93dcca816..84feaa167 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml | |||
@@ -23,7 +23,7 @@ on: | |||
23 | workflow_dispatch: | 23 | workflow_dispatch: |
24 | inputs: | 24 | inputs: |
25 | message: | 25 | message: |
26 | description: "Message for build" | 26 | description: 'Message for build' |
27 | required: true | 27 | required: true |
28 | schedule: | 28 | schedule: |
29 | - cron: '0 0 * * *' # every night at 12 am | 29 | - cron: '0 0 * * *' # every night at 12 am |
@@ -34,8 +34,8 @@ env: | |||
34 | 34 | ||
35 | jobs: | 35 | jobs: |
36 | check_updates: | 36 | check_updates: |
37 | runs-on: ubuntu-20.04 | 37 | runs-on: ubuntu-22.04 |
38 | name: "Check latest commit: ${{ github.event.inputs.message }}" | 38 | name: 'Check latest commit: ${{ github.event.inputs.message }}' |
39 | outputs: | 39 | outputs: |
40 | should_run: ${{ steps.should_run.outputs.should_run }} | 40 | should_run: ${{ steps.should_run.outputs.should_run }} |
41 | steps: | 41 | steps: |
@@ -46,17 +46,18 @@ jobs: | |||
46 | ref: nightly | 46 | ref: nightly |
47 | submodules: recursive | 47 | submodules: recursive |
48 | fetch-depth: 0 # Note: Needed to be able to pull the 'develop' branch as well for merging | 48 | fetch-depth: 0 # Note: Needed to be able to pull the 'develop' branch as well for merging |
49 | - name: Install pnpm | ||
50 | uses: pnpm/action-setup@v2 | ||
51 | if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]')) }} | ||
49 | - name: Use Node.js specified in the '.nvmrc' file | 52 | - name: Use Node.js specified in the '.nvmrc' file |
50 | uses: actions/setup-node@v3 | 53 | uses: actions/setup-node@v3 |
51 | if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]')) }} | 54 | if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]')) }} |
52 | with: | 55 | with: |
53 | node-version-file: ".nvmrc" | 56 | node-version-file: '.nvmrc' |
54 | - name: Install pnpm | 57 | cache: 'pnpm' |
55 | if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]')) }} | ||
56 | run: npm i -gf "pnpm@$(node -p 'require("./package.json").engines.pnpm')" && pnpm -v | ||
57 | - name: Install node dependencies | 58 | - name: Install node dependencies |
58 | if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]')) }} | 59 | if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]')) }} |
59 | uses: nick-fields/retry@v2.8.2 | 60 | uses: nick-fields/retry@v2.8.3 |
60 | with: | 61 | with: |
61 | command: pnpm i | 62 | command: pnpm i |
62 | timeout_minutes: 15 | 63 | timeout_minutes: 15 |
@@ -128,7 +129,7 @@ jobs: | |||
128 | fi | 129 | fi |
129 | 130 | ||
130 | build_mac: | 131 | build_mac: |
131 | name: "macos ${{ github.event.inputs.message }}" | 132 | name: 'macos ${{ github.event.inputs.message }}' |
132 | needs: check_updates | 133 | needs: check_updates |
133 | if: ${{ (needs.check_updates.outputs.should_run != 'false') && (github.event_name != 'workflow_dispatch' || (github.event_name == 'workflow_dispatch' && (contains(github.event.inputs.message, '[macOS]') || (!contains(github.event.inputs.message, '[macOS]') && !contains(github.event.inputs.message, '[Linux]') && !contains(github.event.inputs.message, '[Windows]'))))) }} | 134 | if: ${{ (needs.check_updates.outputs.should_run != 'false') && (github.event_name != 'workflow_dispatch' || (github.event_name == 'workflow_dispatch' && (contains(github.event.inputs.message, '[macOS]') || (!contains(github.event.inputs.message, '[macOS]') && !contains(github.event.inputs.message, '[Linux]') && !contains(github.event.inputs.message, '[Windows]'))))) }} |
134 | runs-on: macos-12 | 135 | runs-on: macos-12 |
@@ -136,7 +137,6 @@ jobs: | |||
136 | - name: Set env vars | 137 | - name: Set env vars |
137 | run: | | 138 | run: | |
138 | echo "NPM_CACHE=$HOME/.npm" >> $GITHUB_ENV | 139 | echo "NPM_CACHE=$HOME/.npm" >> $GITHUB_ENV |
139 | echo "PNPM_CACHE=$HOME/.pnpm-store" >> $GITHUB_ENV | ||
140 | echo "ELECTRON_CACHE=$HOME/.cache/electron" >> $GITHUB_ENV | 140 | echo "ELECTRON_CACHE=$HOME/.cache/electron" >> $GITHUB_ENV |
141 | echo "ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder" >> $GITHUB_ENV | 141 | echo "ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder" >> $GITHUB_ENV |
142 | echo "MANUAL_REBUILD_ON_NIGHTLY=${{ github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]') }}" >> $GITHUB_ENV | 142 | echo "MANUAL_REBUILD_ON_NIGHTLY=${{ github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]') }}" >> $GITHUB_ENV |
@@ -161,23 +161,24 @@ jobs: | |||
161 | env: | 161 | env: |
162 | cache-name: cache-electron-modules | 162 | cache-name: cache-electron-modules |
163 | with: | 163 | with: |
164 | key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./package-lock.json') }} | 164 | key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./pnpm-lock.yaml') }} |
165 | path: ${{ env.ELECTRON_CACHE }} | 165 | path: ${{ env.ELECTRON_CACHE }} |
166 | - name: Cache electron-builder modules | 166 | - name: Cache electron-builder modules |
167 | uses: actions/cache@v3 | 167 | uses: actions/cache@v3 |
168 | env: | 168 | env: |
169 | cache-name: cache-electron-builder-modules | 169 | cache-name: cache-electron-builder-modules |
170 | with: | 170 | with: |
171 | key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./package-lock.json') }} | 171 | key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./pnpm-lock.yaml') }} |
172 | path: ${{ env.ELECTRON_BUILDER_CACHE }} | 172 | path: ${{ env.ELECTRON_BUILDER_CACHE }} |
173 | - name: Install pnpm | ||
174 | uses: pnpm/action-setup@v2 | ||
173 | - name: Use Node.js specified in the '.nvmrc' file | 175 | - name: Use Node.js specified in the '.nvmrc' file |
174 | uses: actions/setup-node@v3 | 176 | uses: actions/setup-node@v3 |
175 | with: | 177 | with: |
176 | node-version-file: ".nvmrc" | 178 | node-version-file: '.nvmrc' |
177 | - name: Install pnpm | 179 | cache: 'pnpm' |
178 | run: npm i -gf "pnpm@$(node -p 'require("./package.json").engines.pnpm')" && pnpm -v | ||
179 | - name: Install node dependencies | 180 | - name: Install node dependencies |
180 | uses: nick-fields/retry@v2.8.2 | 181 | uses: nick-fields/retry@v2.8.3 |
181 | with: | 182 | with: |
182 | command: pnpm i | 183 | command: pnpm i |
183 | timeout_minutes: 15 | 184 | timeout_minutes: 15 |
@@ -207,15 +208,14 @@ jobs: | |||
207 | shell: bash | 208 | shell: bash |
208 | 209 | ||
209 | build_linux: | 210 | build_linux: |
210 | name: "ubuntu ${{ github.event.inputs.message }}" | 211 | name: 'ubuntu ${{ github.event.inputs.message }}' |
211 | needs: check_updates | 212 | needs: check_updates |
212 | if: ${{ (needs.check_updates.outputs.should_run != 'false') && (github.event_name != 'workflow_dispatch' || (github.event_name == 'workflow_dispatch' && (contains(github.event.inputs.message, '[Linux]') || (!contains(github.event.inputs.message, '[macOS]') && !contains(github.event.inputs.message, '[Linux]') && !contains(github.event.inputs.message, '[Windows]'))))) }} | 213 | if: ${{ (needs.check_updates.outputs.should_run != 'false') && (github.event_name != 'workflow_dispatch' || (github.event_name == 'workflow_dispatch' && (contains(github.event.inputs.message, '[Linux]') || (!contains(github.event.inputs.message, '[macOS]') && !contains(github.event.inputs.message, '[Linux]') && !contains(github.event.inputs.message, '[Windows]'))))) }} |
213 | runs-on: ubuntu-20.04 | 214 | runs-on: ubuntu-22.04 |
214 | steps: | 215 | steps: |
215 | - name: Set env vars | 216 | - name: Set env vars |
216 | run: | | 217 | run: | |
217 | echo "NPM_CACHE=$HOME/.npm" >> $GITHUB_ENV | 218 | echo "NPM_CACHE=$HOME/.npm" >> $GITHUB_ENV |
218 | echo "PNPM_CACHE=$HOME/.pnpm-store" >> $GITHUB_ENV | ||
219 | echo "ELECTRON_CACHE=$HOME/.cache/electron" >> $GITHUB_ENV | 219 | echo "ELECTRON_CACHE=$HOME/.cache/electron" >> $GITHUB_ENV |
220 | echo "ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder" >> $GITHUB_ENV | 220 | echo "ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder" >> $GITHUB_ENV |
221 | echo "MANUAL_REBUILD_ON_NIGHTLY=${{ github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]') }}" >> $GITHUB_ENV | 221 | echo "MANUAL_REBUILD_ON_NIGHTLY=${{ github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]') }}" >> $GITHUB_ENV |
@@ -240,23 +240,24 @@ jobs: | |||
240 | env: | 240 | env: |
241 | cache-name: cache-electron-modules | 241 | cache-name: cache-electron-modules |
242 | with: | 242 | with: |
243 | key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./package-lock.json') }} | 243 | key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./pnpm-lock.yaml') }} |
244 | path: ${{ env.ELECTRON_CACHE }} | 244 | path: ${{ env.ELECTRON_CACHE }} |
245 | - name: Cache electron-builder modules | 245 | - name: Cache electron-builder modules |
246 | uses: actions/cache@v3 | 246 | uses: actions/cache@v3 |
247 | env: | 247 | env: |
248 | cache-name: cache-electron-builder-modules | 248 | cache-name: cache-electron-builder-modules |
249 | with: | 249 | with: |
250 | key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./package-lock.json') }} | 250 | key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./pnpm-lock.yaml') }} |
251 | path: ${{ env.ELECTRON_BUILDER_CACHE }} | 251 | path: ${{ env.ELECTRON_BUILDER_CACHE }} |
252 | - name: Install pnpm | ||
253 | uses: pnpm/action-setup@v2 | ||
252 | - name: Use Node.js specified in the '.nvmrc' file | 254 | - name: Use Node.js specified in the '.nvmrc' file |
253 | uses: actions/setup-node@v3 | 255 | uses: actions/setup-node@v3 |
254 | with: | 256 | with: |
255 | node-version-file: ".nvmrc" | 257 | node-version-file: '.nvmrc' |
256 | - name: Install pnpm | 258 | cache: 'pnpm' |
257 | run: npm i -gf "pnpm@$(node -p 'require("./package.json").engines.pnpm')" && pnpm -v | ||
258 | - name: Install node dependencies | 259 | - name: Install node dependencies |
259 | uses: nick-fields/retry@v2.8.2 | 260 | uses: nick-fields/retry@v2.8.3 |
260 | with: | 261 | with: |
261 | command: pnpm i | 262 | command: pnpm i |
262 | timeout_minutes: 15 | 263 | timeout_minutes: 15 |
@@ -305,16 +306,15 @@ jobs: | |||
305 | shell: bash | 306 | shell: bash |
306 | 307 | ||
307 | build_windows: | 308 | build_windows: |
308 | name: "windows ${{ github.event.inputs.message }}" | 309 | name: 'windows ${{ github.event.inputs.message }}' |
309 | needs: check_updates | 310 | needs: check_updates |
310 | if: ${{ (needs.check_updates.outputs.should_run != 'false') && (github.event_name != 'workflow_dispatch' || (github.event_name == 'workflow_dispatch' && (contains(github.event.inputs.message, '[Windows]') || (!contains(github.event.inputs.message, '[macOS]') && !contains(github.event.inputs.message, '[Linux]') && !contains(github.event.inputs.message, '[Windows]'))))) }} | 311 | if: ${{ (needs.check_updates.outputs.should_run != 'false') && (github.event_name != 'workflow_dispatch' || (github.event_name == 'workflow_dispatch' && (contains(github.event.inputs.message, '[Windows]') || (!contains(github.event.inputs.message, '[macOS]') && !contains(github.event.inputs.message, '[Linux]') && !contains(github.event.inputs.message, '[Windows]'))))) }} |
311 | runs-on: windows-2019 | 312 | runs-on: windows-2022 |
312 | steps: | 313 | steps: |
313 | - name: Set env vars | 314 | - name: Set env vars |
314 | run: | | 315 | run: | |
315 | echo "HOME=$USERPROFILE" >> $GITHUB_ENV | 316 | echo "HOME=$USERPROFILE" >> $GITHUB_ENV |
316 | echo "NPM_CACHE=$USERPROFILE/.npm" >> $GITHUB_ENV | 317 | echo "NPM_CACHE=$USERPROFILE/.npm" >> $GITHUB_ENV |
317 | echo "PNPM_CACHE=$USERPROFILE/.pnpm-store" >> $GITHUB_ENV | ||
318 | echo "ELECTRON_CACHE=$USERPROFILE/.cache/electron" >> $GITHUB_ENV | 318 | echo "ELECTRON_CACHE=$USERPROFILE/.cache/electron" >> $GITHUB_ENV |
319 | echo "ELECTRON_BUILDER_CACHE=$USERPROFILE/.cache/electron-builder" >> $GITHUB_ENV | 319 | echo "ELECTRON_BUILDER_CACHE=$USERPROFILE/.cache/electron-builder" >> $GITHUB_ENV |
320 | echo "MANUAL_REBUILD_ON_NIGHTLY=${{ github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]') }}" >> $GITHUB_ENV | 320 | echo "MANUAL_REBUILD_ON_NIGHTLY=${{ github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]') }}" >> $GITHUB_ENV |
@@ -340,27 +340,24 @@ jobs: | |||
340 | env: | 340 | env: |
341 | cache-name: cache-electron-modules | 341 | cache-name: cache-electron-modules |
342 | with: | 342 | with: |
343 | key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./package-lock.json') }} | 343 | key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./pnpm-lock.yaml') }} |
344 | path: ${{ env.ELECTRON_CACHE }} | 344 | path: ${{ env.ELECTRON_CACHE }} |
345 | - name: Cache electron-builder modules | 345 | - name: Cache electron-builder modules |
346 | uses: actions/cache@v3 | 346 | uses: actions/cache@v3 |
347 | env: | 347 | env: |
348 | cache-name: cache-electron-builder-modules | 348 | cache-name: cache-electron-builder-modules |
349 | with: | 349 | with: |
350 | key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./package-lock.json') }} | 350 | key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./pnpm-lock.yaml') }} |
351 | path: ${{ env.ELECTRON_BUILDER_CACHE }} | 351 | path: ${{ env.ELECTRON_BUILDER_CACHE }} |
352 | - name: Install pnpm | ||
353 | uses: pnpm/action-setup@v2 | ||
352 | - name: Use Node.js specified in the '.nvmrc' file | 354 | - name: Use Node.js specified in the '.nvmrc' file |
353 | uses: actions/setup-node@v3 | 355 | uses: actions/setup-node@v3 |
354 | with: | 356 | with: |
355 | node-version-file: ".nvmrc" | 357 | node-version-file: '.nvmrc' |
356 | - name: Install pnpm | 358 | cache: 'pnpm' |
357 | run: npm i -gf "pnpm@$(node -p 'require(\"./package.json\").engines.pnpm')" && pnpm -v | ||
358 | # TODO: Remove this once https://github.com/electron-userland/electron-builder/issues/6933#issuecomment-1213438889 is resolved | ||
359 | - name: Tweak pnpm.cjs | ||
360 | run: sed -i 's/\/usr\/bin\/env node/node/g' /c/npm/prefix/node_modules/pnpm/bin/pnpm.cjs | ||
361 | shell: bash | ||
362 | - name: Install node dependencies | 359 | - name: Install node dependencies |
363 | uses: nick-fields/retry@v2.8.2 | 360 | uses: nick-fields/retry@v2.8.3 |
364 | with: | 361 | with: |
365 | command: pnpm i | 362 | command: pnpm i |
366 | timeout_minutes: 15 | 363 | timeout_minutes: 15 |