-
-
Notifications
You must be signed in to change notification settings - Fork 0
179 lines (147 loc) · 5.33 KB
/
ci.yaml
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: "build"
on:
pull_request:
paths-ignore:
- "docs/**"
push:
branches:
- "main"
tags:
- v*
schedule:
- cron: "0 8 * * 1" # At 08:00 on Monday
jobs:
build:
name: "Build code for distribution"
runs-on: "${{ matrix.operating-system }}"
strategy:
matrix:
node-version: [ "20" ]
operating-system: [ "ubuntu-latest" ]
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Install node"
uses: "actions/setup-node@v4"
with:
node-version: "${{ matrix.node-version }}"
registry-url: "https://registry.npmjs.org"
- name: "Install package dependencies"
run: "yarn install"
- name: "Build the project"
run: "yarn build"
- name: "Upload build result"
uses: "actions/upload-artifact@v4"
with:
name: js-dist
path: dist
publish-npmjs:
name: "Publish code distribution to NPM"
runs-on: "${{ matrix.operating-system }}"
needs: [ "build" ]
strategy:
matrix:
node-version: [ "20" ]
operating-system: [ "ubuntu-latest" ]
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Install node"
uses: "actions/setup-node@v4"
with:
node-version: "${{ matrix.node-version }}"
registry-url: "https://registry.npmjs.org"
- name: "Extract version"
uses: "battila7/get-version-action@v2"
id: "get_version"
- name: "Set up git since we will later push to the repo"
run: |
git config --global user.name "GitHub CD bot"
git config --global user.email "[email protected]"
- name: "Upgrade npm version in package.json to the tag used in the release"
if: contains(github.ref, 'refs/tags/')
run: npm version ${{ steps.get_version.outputs.version-without-v }} --allow-same-version
- name: "Download build result"
uses: "actions/download-artifact@v4"
with:
name: js-dist
path: dist
- name: "Publish to NPM"
uses: "JS-DevTools/npm-publish@v3"
id: "npm_publish"
if: contains(github.ref, 'refs/tags/')
with:
token: ${{ secrets.NPMJS_TOKEN }}
access: "public"
- name: "Publish to NPM result"
if: contains(github.ref, 'refs/tags/') && steps.npm_publish.outputs.type != 'none'
run: |
echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}"
- name: "Publish to NPM"
uses: "JS-DevTools/npm-publish@v3"
id: "npm_publish_dev"
if: contains(github.ref, 'refs/tags/') == false
with:
token: ${{ secrets.NPMJS_TOKEN }}
access: "public"
tag: "dev"
- name: "Publish to NPM result"
if: contains(github.ref, 'refs/tags/') == false && steps.npm_publish_dev.outputs.type != 'none'
run: |
echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}"
publish-github:
name: "Publish code distribution to Github packages"
runs-on: "${{ matrix.operating-system }}"
needs: [ "build" ]
strategy:
matrix:
node-version: [ "20" ]
operating-system: [ "ubuntu-latest" ]
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Install node"
uses: "actions/setup-node@v4"
with:
node-version: "${{ matrix.node-version }}"
registry-url: "https://npm.pkg.github.com"
- name: "Extract version"
uses: "battila7/get-version-action@v2"
id: "get_version"
- name: "Set up git since we will later push to the repo"
run: |
git config --global user.name "GitHub CD bot"
git config --global user.email "[email protected]"
- name: "Upgrade npm version in package.json to the tag used in the release"
if: contains(github.ref, 'refs/tags/')
run: npm version ${{ steps.get_version.outputs.version-without-v }} --allow-same-version
- name: "Download build result"
uses: "actions/download-artifact@v4"
with:
name: js-dist
path: dist
- name: "Publish to NPM"
uses: "JS-DevTools/npm-publish@v3"
id: "npm_publish"
if: contains(github.ref, 'refs/tags/')
with:
token: ${{ secrets.GITHUB_TOKEN }}
access: "public"
registry: "https://npm.pkg.github.com"
- name: "Publish to NPM result"
if: contains(github.ref, 'refs/tags/') && steps.npm_publish.outputs.type != 'none'
run: |
echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}"
- name: "Publish to NPM"
uses: "JS-DevTools/npm-publish@v3"
id: "npm_publish_dev"
if: contains(github.ref, 'refs/tags/') == false
with:
token: ${{ secrets.GITHUB_TOKEN }}
access: "public"
tag: "dev"
registry: "https://npm.pkg.github.com"
- name: "Publish to NPM result"
if: contains(github.ref, 'refs/tags/') == false && steps.npm_publish_dev.outputs.type != 'none'
run: |
echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}"