-
Notifications
You must be signed in to change notification settings - Fork 6
57 lines (47 loc) · 1.45 KB
/
test.yml
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
name: Test
on: [push, pull_request]
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2.1.2
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm test
# Rudimentary release process to avoid manual work of bundling & tagging
# whenever changes are made that effects the `dist/index.js` bundle.
release:
needs: tests
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
env:
TAG: v1
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: npm install and build
run: |
npm ci
npm run build
- name: Check if dist/ has changed after build
id: changedTest
run: git diff --quiet HEAD -- dist/ || echo "::set-output name=hasChanged::true"
- name: Commit and update tag
if: ${{ steps.changedTest.outputs.hasChanged == 'true' }}
run: |
git config --global user.name 'via-github-actions'
git config --global user.email 'github-actions@noreply.github.com'
git add dist/
git commit -m "🚀 Update dist/ and $TAG-tag"
git tag -f $TAG
git push origin :refs/tags/$TAG
git push origin main --tags