Repository navigation
143 lines (138 loc) · 5 KB
/
Copy pathnode.yml
File metadata and controls
143 lines (138 loc) · 5 KB
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
# SPDX-FileCopyrightText: 2022-2026 Dawid Papiewski "SpacingBat3" <spacingbat3@gmail.com>
#
# SPDX-License-Identifier: ISC
# $schema: https://json.schemastore.org/github-workflow
name: Node.js CI/CD
on:
push:
branches: [ master ]
tags: [ appimage/v*, maker-types/v*, launcher/v* ]
pull_request:
branches: [ master ]
permissions: {}
jobs:
test:
strategy:
fail-fast: false
matrix:
node-version: [20.x, 22.x, 24.x, latest]
name: Build and run tests (${{ github.ref_name }}#${{ matrix.node-version }})
runs-on: ubuntu-latest
steps:
# Initialization
- name: Checkout
uses: actions/checkout@v7
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Install Node ${{ matrix.node-version }} types
# Skip on package @types/node
# FIXME: might require manual bumps & synchronization for now
# Also, is `if` even worth it there to just capture
# possibility of missing types?
if: ${{ matrix.node-version != '22.x' }}
run: npm i -D "@types/node@^$(node --version | cut -b 2- | sed 's/[.].*$//').0.0"
# Build
- name: Build project
run: npm run build
# Lint
- name: Lint project
run: npm run lint
# Test
- name: Run tests with coverage+test reporting
if: ${{ matrix.node-version != '20.x' }}
run: |
npm run test:coverage -- --experimental-test-coverage \
--test-reporter=spec --test-reporter-destination=stdout \
--test-reporter=junit --test-reporter-destination=junit.xml
- name: Upload coverage reports to Codecov
if: ${{ success() }}
uses: codecov/codecov-action@v7
with:
report_type: "coverage"
token: ${{ secrets.CODECOV_TOKEN }}
name: "${{ github.ref_name }}#${{ matrix.node-version }}"
- name: Upload test results to CodeCov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v7
with:
report_type: "test_results"
token: ${{ secrets.CODECOV_TOKEN }}
name: "${{ github.ref_name }}#${{ matrix.node-version }}"
package:
strategy:
matrix:
# FIXME: Consider some smarter scripting capabilities than if ... else
# tag to package mapping. Substring of tag to next slash could
# help a lot.
# At least I can do hacky expression splitting to have it stored
# as a rather "pretty, lengthy" value.
pkg: >-
${{ (startsWith(github.ref_name,'appimage/v') && fromJson('["maker-appimage"]') ||
startsWith(github.ref_name,'maker-types/v') && fromJson('["maker-types"]') ||
startsWith(github.ref_name,'launcher/v') && fromJson('["plugin-launcher"]') ||
fromJson('["maker-appimage","maker-types","plugin-launcher"]')
)}}
name: Package ${{ matrix.pkg }} as artifact
runs-on: ubuntu-latest
needs: test
steps:
# Initialization
- name: Checkout
uses: actions/checkout@v7
- name: Setup Node.js latest
uses: actions/setup-node@v6
with:
node-version: latest
- name: Install dependencies
run: npm ci
# Create package & publish it as artifact for inspection
- name: Create package tarball
id: pack
run: |
{
printf 'meta<<\0\n'
npm -w "@reforged/${{ matrix.pkg }}" pack --json
printf '\0\n'
} >> "$GITHUB_OUTPUT"
- name: Upload package as artifact
uses: actions/upload-artifact@v7
with:
archive: false
name: reforged-${{ matrix.pkg }}
path: ${{ fromJson(steps.pack.outputs.meta)[0].filename }}
publish-npm:
strategy:
matrix:
# Note: this is duplicate of `package` matrix
pkg: >-
${{ (startsWith(github.ref_name,'appimage/v') && fromJson('["maker-appimage"]') ||
startsWith(github.ref_name,'maker-types/v') && fromJson('["maker-types"]') ||
startsWith(github.ref_name,'launcher/v') && fromJson('["plugin-launcher"]') ||
fromJson('["maker-appimage","maker-types","plugin-launcher"]')
)}}
name: Distribute ${{ matrix.pkg }} to NPM
environment: npm
if: ${{ github.ref_type == 'tag' }}
runs-on: ubuntu-latest
needs: test
permissions:
contents: read
id-token: write
steps:
# Initialization
- name: Checkout
uses: actions/checkout@v7
- name: Setup Node.js latest
uses: actions/setup-node@v6
with:
node-version: latest
registry-url: https://registry.npmjs.org
- name: Install dependencies
run: npm ci
# Publish to NPM (for tags)
- name: Publish to NPM
run: npm -w "@reforged/${{ matrix.pkg }}" publish