Skip to content

Commit ab8dce9

Browse files
committed
Add GitHub workflows
1 parent dcddfbe commit ab8dce9

File tree

5 files changed

+161
-1
lines changed

5 files changed

+161
-1
lines changed

.github/workflows/build.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build
2+
on:
3+
push:
4+
branches:
5+
- '*'
6+
workflow_call:
7+
8+
jobs:
9+
get-vars:
10+
uses: ./.github/workflows/nodevars.yml
11+
12+
main:
13+
needs: get-vars
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
- name: Setup node
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: ${{ needs.get-vars.outputs.node-version }}
22+
cache: npm
23+
- name: Setup npm
24+
run: npm i -g npm@${{ needs.get-vars.outputs.npm-version }}
25+
- name: Cache node modules
26+
id: node_modules_cache
27+
uses: actions/cache@v3
28+
env:
29+
cache-name: cache-node-modules
30+
with:
31+
path: node_modules
32+
key: ${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
33+
- name: Install
34+
if: steps.node_modules_cache.outputs.cache-hit != 'true'
35+
run: npm ci
36+
37+
- name: Build dev
38+
run: npm run build
39+
- name: Build minified
40+
run: npm run build:minified
41+
- name: Archive artifacts
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: dist
45+
path: dist
46+
retention-days: 7
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Create GitHub Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
call-build:
10+
uses: ./.github/workflows/build.yml
11+
12+
release:
13+
needs: call-build
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Extract release notes from CHANGELOG.md
23+
id: changelog
24+
run: |
25+
TAG_NAME="${GITHUB_REF#refs/tags/}"
26+
BODY=$(awk -v tag="## ${TAG_NAME}" '
27+
$0 ~ tag {found=1; next}
28+
found && /^## / {exit}
29+
found {print}
30+
' CHANGELOG.md 2>/dev/null || true)
31+
echo "TAG_NAME=${TAG_NAME}" >> "$GITHUB_ENV"
32+
if [ -n "$BODY" ]; then
33+
echo "RELEASE_BODY<<EOF" >> "$GITHUB_ENV"
34+
echo "$BODY" >> "$GITHUB_ENV"
35+
echo "EOF" >> "$GITHUB_ENV"
36+
fi
37+
38+
- name: Retrieve artifacts
39+
uses: actions/download-artifact@v4
40+
with:
41+
name: dist
42+
path: dist
43+
44+
- name: Create GitHub Release
45+
uses: softprops/action-gh-release@v2
46+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
47+
with:
48+
tag_name: ${{ env.TAG_NAME }}
49+
name: ${{ env.TAG_NAME }}
50+
body: ${{ env.RELEASE_BODY }}
51+
files: dist/*

.github/workflows/linting.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Linting
2+
on:
3+
- push
4+
5+
jobs:
6+
get-vars:
7+
uses: ./.github/workflows/nodevars.yml
8+
9+
main:
10+
needs: get-vars
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
- name: Setup node
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: ${{ needs.get-vars.outputs.node-version }}
19+
cache: npm
20+
- name: Setup npm
21+
run: npm i -g npm@${{ needs.get-vars.outputs.npm-version }}
22+
- name: Cache node modules
23+
id: node_modules_cache
24+
uses: actions/cache@v3
25+
env:
26+
cache-name: cache-node-modules
27+
with:
28+
path: node_modules
29+
key: ${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
30+
- name: Install
31+
if: steps.node_modules_cache.outputs.cache-hit != 'true'
32+
run: npm ci
33+
34+
- name: Typecheck
35+
run: npm run typecheck
36+
- name: Lint
37+
run: npm run lint

.github/workflows/nodevars.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Setup Node.js versions
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
node-version:
7+
description: 'Common Node.js version'
8+
value: ${{ jobs.export.outputs.node-version }}
9+
npm-version:
10+
description: 'Common NPM version'
11+
value: ${{ jobs.export.outputs.npm-version }}
12+
13+
env:
14+
NODE_VERSION: 22.19
15+
NPM_VERSION: 11
16+
17+
jobs:
18+
export:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
node-version: ${{ steps.setver.outputs.node_version }}
22+
npm-version: ${{ steps.setver.outputs.npm_version }}
23+
steps:
24+
- id: setver
25+
run: |
26+
echo "node_version=${{ env.NODE_VERSION }}" >> $GITHUB_OUTPUT
27+
echo "npm_version=${{ env.NPM_VERSION }}" >> $GITHUB_OUTPUT

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
/.work/
33
/dist/
44
/node_modules/
5-
.github
65
npm-debug.log
76
yarn-error.log

0 commit comments

Comments
 (0)