Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: modernize github actions #1287

Merged
merged 4 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 35 additions & 34 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:
workflow_dispatch:
inputs:
message:
description: "Message for build"
description: 'Message for build'
required: true
schedule:
- cron: '0 0 * * *' # every night at 12 am
Expand All @@ -34,8 +34,8 @@ env:

jobs:
check_updates:
runs-on: ubuntu-20.04
name: "Check latest commit: ${{ github.event.inputs.message }}"
runs-on: ubuntu-22.04
name: 'Check latest commit: ${{ github.event.inputs.message }}'
outputs:
should_run: ${{ steps.should_run.outputs.should_run }}
steps:
Expand All @@ -46,17 +46,18 @@ jobs:
ref: nightly
submodules: recursive
fetch-depth: 0 # Note: Needed to be able to pull the 'develop' branch as well for merging
- name: Install pnpm
uses: pnpm/action-setup@v2
if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]')) }}
- name: Use Node.js specified in the '.nvmrc' file
uses: actions/setup-node@v3
if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]')) }}
with:
node-version-file: ".nvmrc"
- name: Install pnpm
if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]')) }}
run: npm i -gf "pnpm@$(node -p 'require("./package.json").engines.pnpm')" && pnpm -v
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Install node dependencies
if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]')) }}
uses: nick-fields/[email protected].2
uses: nick-fields/[email protected].3
with:
command: pnpm i
timeout_minutes: 15
Expand Down Expand Up @@ -128,15 +129,14 @@ jobs:
fi

build_mac:
name: "macos ${{ github.event.inputs.message }}"
name: 'macos ${{ github.event.inputs.message }}'
needs: check_updates
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]'))))) }}
runs-on: macos-12
steps:
- name: Set env vars
run: |
echo "NPM_CACHE=$HOME/.npm" >> $GITHUB_ENV
echo "PNPM_CACHE=$HOME/.pnpm-store" >> $GITHUB_ENV
vraravam marked this conversation as resolved.
Show resolved Hide resolved
echo "ELECTRON_CACHE=$HOME/.cache/electron" >> $GITHUB_ENV
echo "ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder" >> $GITHUB_ENV
echo "MANUAL_REBUILD_ON_NIGHTLY=${{ github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]') }}" >> $GITHUB_ENV
Expand All @@ -161,23 +161,24 @@ jobs:
env:
cache-name: cache-electron-modules
with:
key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./package-lock.json') }}
key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./pnpm-lock.yaml') }}
path: ${{ env.ELECTRON_CACHE }}
- name: Cache electron-builder modules
uses: actions/cache@v3
env:
cache-name: cache-electron-builder-modules
with:
key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./package-lock.json') }}
key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./pnpm-lock.yaml') }}
path: ${{ env.ELECTRON_BUILDER_CACHE }}
- name: Install pnpm
uses: pnpm/action-setup@v2
- name: Use Node.js specified in the '.nvmrc' file
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- name: Install pnpm
run: npm i -gf "pnpm@$(node -p 'require("./package.json").engines.pnpm')" && pnpm -v
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Install node dependencies
uses: nick-fields/[email protected].2
uses: nick-fields/[email protected].3
with:
command: pnpm i
timeout_minutes: 15
Expand Down Expand Up @@ -207,15 +208,14 @@ jobs:
shell: bash

build_linux:
name: "ubuntu ${{ github.event.inputs.message }}"
name: 'ubuntu ${{ github.event.inputs.message }}'
needs: check_updates
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]'))))) }}
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Set env vars
run: |
echo "NPM_CACHE=$HOME/.npm" >> $GITHUB_ENV
echo "PNPM_CACHE=$HOME/.pnpm-store" >> $GITHUB_ENV
echo "ELECTRON_CACHE=$HOME/.cache/electron" >> $GITHUB_ENV
echo "ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder" >> $GITHUB_ENV
echo "MANUAL_REBUILD_ON_NIGHTLY=${{ github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]') }}" >> $GITHUB_ENV
Expand All @@ -240,23 +240,24 @@ jobs:
env:
cache-name: cache-electron-modules
with:
key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./package-lock.json') }}
key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./pnpm-lock.yaml') }}
path: ${{ env.ELECTRON_CACHE }}
- name: Cache electron-builder modules
uses: actions/cache@v3
env:
cache-name: cache-electron-builder-modules
with:
key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./package-lock.json') }}
key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./pnpm-lock.yaml') }}
path: ${{ env.ELECTRON_BUILDER_CACHE }}
- name: Install pnpm
vraravam marked this conversation as resolved.
Show resolved Hide resolved
uses: pnpm/action-setup@v2
- name: Use Node.js specified in the '.nvmrc' file
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- name: Install pnpm
run: npm i -gf "pnpm@$(node -p 'require("./package.json").engines.pnpm')" && pnpm -v
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Install node dependencies
uses: nick-fields/[email protected].2
uses: nick-fields/[email protected].3
with:
command: pnpm i
timeout_minutes: 15
Expand Down Expand Up @@ -305,16 +306,15 @@ jobs:
shell: bash

build_windows:
name: "windows ${{ github.event.inputs.message }}"
name: 'windows ${{ github.event.inputs.message }}'
needs: check_updates
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]'))))) }}
runs-on: windows-2019
runs-on: windows-2022
vraravam marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Set env vars
run: |
echo "HOME=$USERPROFILE" >> $GITHUB_ENV
echo "NPM_CACHE=$USERPROFILE/.npm" >> $GITHUB_ENV
echo "PNPM_CACHE=$USERPROFILE/.pnpm-store" >> $GITHUB_ENV
vraravam marked this conversation as resolved.
Show resolved Hide resolved
echo "ELECTRON_CACHE=$USERPROFILE/.cache/electron" >> $GITHUB_ENV
echo "ELECTRON_BUILDER_CACHE=$USERPROFILE/.cache/electron-builder" >> $GITHUB_ENV
echo "MANUAL_REBUILD_ON_NIGHTLY=${{ github.event_name == 'workflow_dispatch' && contains(github.event.inputs.message, '[nightly branch]') }}" >> $GITHUB_ENV
Expand All @@ -340,27 +340,28 @@ jobs:
env:
cache-name: cache-electron-modules
with:
key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./package-lock.json') }}
key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./pnpm-lock.yaml') }}
path: ${{ env.ELECTRON_CACHE }}
- name: Cache electron-builder modules
uses: actions/cache@v3
env:
cache-name: cache-electron-builder-modules
with:
key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./package-lock.json') }}
key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('./pnpm-lock.yaml') }}
path: ${{ env.ELECTRON_BUILDER_CACHE }}
- name: Install pnpm
uses: pnpm/action-setup@v2
- name: Use Node.js specified in the '.nvmrc' file
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- name: Install pnpm
vraravam marked this conversation as resolved.
Show resolved Hide resolved
run: npm i -gf "pnpm@$(node -p 'require(\"./package.json\").engines.pnpm')" && pnpm -v
node-version-file: '.nvmrc'
cache: 'pnpm'
# TODO: Remove this once https://github.com/electron-userland/electron-builder/issues/6933#issuecomment-1213438889 is resolved
- name: Tweak pnpm.cjs
run: sed -i 's/\/usr\/bin\/env node/node/g' /c/npm/prefix/node_modules/pnpm/bin/pnpm.cjs
shell: bash
- name: Install node dependencies
uses: nick-fields/[email protected].2
uses: nick-fields/[email protected].3
with:
command: pnpm i
timeout_minutes: 15
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"node": "18.15.0",
"pnpm": "8.6.2"
},
"packageManager": "[email protected]",
"scripts": {
"prepare": "is-ci || husky install",
"start": "electron ./build",
Expand Down
Loading