generated from LizardByte/template-base
-
-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (122 loc) · 4.07 KB
/
ci.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
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
---
# This workflow will run tests using node and then publish a package to GitHub Packages on push events to master.
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
name: CI
on:
pull_request:
branches: [master]
types: [opened, synchronize, reopened]
push:
branches: [master]
jobs:
setup_release:
name: Setup Release
outputs:
publish_release: ${{ steps.setup_release.outputs.publish_release }}
release_body: ${{ steps.setup_release.outputs.release_body }}
release_commit: ${{ steps.setup_release.outputs.release_commit }}
release_generate_release_notes: ${{ steps.setup_release.outputs.release_generate_release_notes }}
release_tag: ${{ steps.setup_release.outputs.release_tag }}
release_version: ${{ steps.setup_release.outputs.release_version }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Release
id: setup_release
uses: LizardByte/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: latest
- name: Install dependencies
run: npm install
- name: Test
id: test
env:
FORCE_COLOR: true
run: |
npm test
- name: Build
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: npm run build
- name: Upload test results to Codecov
# any except canceled or skipped
if: >-
always() &&
(steps.test.outcome == 'success' || steps.test.outcome == 'failure') &&
startsWith(github.repository, 'LizardByte/')
uses: codecov/test-results-action@v1
with:
fail_ci_if_error: true
files: ./junit.xml,!./cache
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
- name: Upload coverage
# any except canceled or skipped
if: >-
always() &&
(steps.test.outcome == 'success' || steps.test.outcome == 'failure') &&
startsWith(github.repository, 'LizardByte/')
uses: codecov/codecov-action@v4
with:
disable_search: true
fail_ci_if_error: true
files: ./coverage/coverage-final.json
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
publish-gpr:
if: ${{ needs.setup_release.outputs.publish_release == 'true' }}
needs:
- setup_release
- build
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # required for provenance
packages: write
strategy:
fail-fast: false
matrix:
include:
- registry-url: "https://npm.pkg.github.com"
extra-args: ""
- registry-url: "https://registry.npmjs.org"
extra-args: "--provenance --access public"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: latest
registry-url: ${{ matrix.registry-url }}
scope: '@lizardbyte'
- name: Update package.json
run: |
npm version ${{ needs.setup_release.outputs.release_version }} --no-git-tag-version
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Set token
id: token
run: |
# if github registry, use GITHUB_TOKEN
if [ "${{ matrix.registry-url }}" == "https://npm.pkg.github.com" ]; then
echo "NODE_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_OUTPUT
else
echo "NODE_AUTH_TOKEN=${{ secrets.NPM_TOKEN }}" >> $GITHUB_OUTPUT
fi
- name: Publish
run: npm publish ${{ matrix.extra-args }}
env:
NODE_AUTH_TOKEN: ${{ steps.token.outputs.NODE_AUTH_TOKEN }}