Skip to content

Commit b6bfb5b

Browse files
authored
[Tech] Deduplicate our Workflows (#3198)
* Deduplicate our Workflows - The "install-deps" action is used to have one place to declare (common) dependencies for building - The build-base workflow is used for a generic "build Heroic for all platforms and upload the results" step (since we do that multiple times as well) - Job strategies were used wherever possible to not repeat (nearly) the same steps for 3 OSs * Use npm instead of yarn
1 parent 09ad669 commit b6bfb5b

18 files changed

+130
-369
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: 'Prerequisite setup'
2+
description: 'Installs dependencies (Node itself, node_modules, node-gyp)'
3+
runs:
4+
using: 'composite'
5+
steps:
6+
- uses: actions/setup-node@v3
7+
with:
8+
node-version: '20'
9+
- name: Install node-gyp
10+
run: npm install --global node-gyp
11+
shell: bash
12+
- name: Install modules
13+
run: npm install --legacy-peer-deps
14+
shell: bash
15+
env:
16+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'

.github/workflows/build-base.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Build Heroic, upload artifacts
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
publish-snap:
7+
required: false
8+
type: boolean
9+
secrets:
10+
workflowToken:
11+
required: true
12+
snapcraftIdEdge:
13+
required: false
14+
15+
jobs:
16+
build:
17+
strategy:
18+
matrix:
19+
os: [windows-2022, ubuntu-22.04, macos-12]
20+
runs-on: ${{ matrix.os }}
21+
steps:
22+
- uses: actions/checkout@v3
23+
- uses: ./.github/actions/install-deps
24+
- name: Build Windows Portable version
25+
run: yarn dist:win portable
26+
if: runner.os == 'Windows'
27+
- name: Build macOS x64 & arm64 versions
28+
run: yarn dist:mac --x64 --arm64 --publish=never
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.workflowToken }}
31+
GH_TOKEN: ${{ secrets.workflowToken }}
32+
CSC_IDENTITY_AUTO_DISCOVERY: false
33+
if: runner.os == 'macOS'
34+
- name: Build and publish Snap version
35+
run: |
36+
sudo apt-get install --no-install-recommends -y snapcraft
37+
yarn dist:linux Snap --publish=always
38+
env:
39+
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.snapcraftEdgeId }}
40+
if: runner.os == 'Linux' && inputs.publish-snap
41+
- name: Build AppImage version
42+
run: yarn dist:linux AppImage
43+
if: runner.os == 'Linux'
44+
- name: Upload built version
45+
uses: actions/upload-artifact@v3
46+
with:
47+
name: ${{ (matrix.os == 'windows-2022' && 'win-portable' ) ||
48+
(matrix.os == 'macos-12' && 'mac-x64' ) ||
49+
(matrix.os == 'ubuntu-22.04' && 'linux-AppImage') }}
50+
path: ${{ (matrix.os == 'windows-2022' && 'dist/Heroic*.exe' ) ||
51+
(matrix.os == 'macos-12' && 'dist/Heroic*x64.dmg' ) ||
52+
(matrix.os == 'ubuntu-22.04' && 'dist/Heroic-*.AppImage') }}
53+
retention-days: 14
54+
- name: Upload macOS ARM version
55+
uses: actions/upload-artifact@v3
56+
with:
57+
name: mac-arm64
58+
path: dist/Heroic*arm64.dmg
59+
retention-days: 14
60+
if: runner.os == 'macOS'

.github/workflows/build-main.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Build on main/stable push
2+
3+
on:
4+
push:
5+
branches: [main, stable]
6+
tags:
7+
- '!v*'
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
uses: ./.github/workflows/build-base.yml
13+
with:
14+
publish-snap: true
15+
secrets:
16+
snapcraftIdEdge: ${{ secrets.SNAPCRAFT_ID_EDGE }}
17+
workflowToken: ${{ secrets.WORKFLOW_TOKEN }}

.github/workflows/build-prs-linux.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/build-prs-mac.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.github/workflows/build-prs-windows.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/build-prs.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Build on PR
2+
3+
on:
4+
pull_request:
5+
branches: [main, stable]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
uses: ./.github/workflows/build-base.yml
11+
with:
12+
publish-snap: false
13+
secrets:
14+
workflowToken: ${{ secrets.WORKFLOW_TOKEN }}

.github/workflows/build.yml

Lines changed: 0 additions & 92 deletions
This file was deleted.

.github/workflows/codecheck.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v3
13-
- uses: actions/setup-node@v3
14-
with:
15-
node-version: '18'
16-
cache: 'yarn'
17-
- name: Install node-gyp.
18-
run: yarn global add node-gyp
19-
- name: Install modules.
20-
run: yarn install --frozen-lockfile
13+
- uses: ./.github/actions/install-deps
2114
- name: Check Typescript syntax
2215
run: yarn codecheck

.github/workflows/draft-release-linux.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ jobs:
1212
steps:
1313
- run: sudo apt-get install --no-install-recommends -y libarchive-tools libopenjp2-tools rpm snapcraft
1414
- uses: actions/checkout@v3
15-
- uses: actions/setup-node@v3
16-
with:
17-
node-version: '20'
18-
- name: install node-gyp
19-
run: npm install -g node-gyp
20-
- run: npm i --legacy-peer-deps
15+
- uses: ./.github/actions/install-deps
2116
- run: npm run release:linux
2217
env:
2318
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}

0 commit comments

Comments
 (0)