-
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (82 loc) · 2.5 KB
/
publish.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
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
name: publish
on:
push:
branches:
- 'main'
paths:
- 'src/**'
- 'config.schema.json'
- 'package.json'
- 'package-lock.json'
- 'tsconfig.json'
- 'tsconfig.release.json'
release:
types: [published]
env:
# See LTS versions supported: https://nodejs.org/en/about/releases/
NODE_VERSION: 18
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- run: npm ci
- run: npm run release
- name: Upload dist
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
publish-preview:
needs: build
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
steps:
- uses: actions/checkout@v3
- name: Download dist
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org/'
- run: npm version preminor --preid preview.${GITHUB_RUN_NUMBER}+${GITHUB_SHA::7} --no-git-tag-version
- run: npm publish --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
publish-release:
needs: build
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' }}
steps:
- uses: actions/checkout@v3
- name: Download dist
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org/'
- name: Set environment variables
uses: FranzDiebold/github-env-vars-action@v2
- run: npm version ${{ env.CI_ACTION_REF_NAME }} --no-git-tag-version
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
# Updates the version that was used for the release.
- name: Bump version
run: |
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git commit -am "Bumping version"
git push origin HEAD:main