-
Notifications
You must be signed in to change notification settings - Fork 1
217 lines (212 loc) · 7.18 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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: publish
on:
workflow_dispatch:
inputs:
sha:
description: "The git SHA to use for release. Only set if needing to publish"
required: true
default: ""
type: string
version:
description: "The Release version. Allowed format: x.y.z"
required: false
default: ""
type: string
publish_dryrun:
description: "Set to true to in order to do a npm publish dry run."
required: false
default: true
type: boolean
npm_tag:
description: "The tag value to use to publish to npm."
required: false
default: ""
type: choice
options:
- ''
- dev
- beta
- rc
prebuilds_workflow_id:
description: "The workflow run ID of a prebuilds workflow run. Set if wanting to use prebuilds from an already completed run."
required: false
default: ""
type: string
jobs:
validate-input:
runs-on: ubuntu-22.04
steps:
- name: If release, verify SHA is provided
if: ${{ inputs.sha == '' || inputs.sha.length != 40 }}
run: |
echo "::error Must provide a SHA."
exit 1
- name: If release version, npm tag also provided
if: ${{ inputs.version != '' && inputs.npm_tag == '' }}
run: |
echo "::error If releasing by setting a release version, must provide a npm tag."
exit 1
build-prebuilds:
if: ${{ inputs.prebuilds_workflow_id == '' }}
needs: validate-input
uses: ./.github/workflows/prebuilds.yml
with:
is_release: true
sha: ${{ inputs.sha }}
version: ${{ inputs.version }}
upload-api-docs:
name: Upload to API docs
needs: build-prebuilds
if: ${{ always() }}
runs-on: ubuntu-22.04
steps:
- name: Checkout
if: inputs.sha != ''
uses: actions/checkout@v4
with:
ref: ${{ inputs.sha }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.DEFAULT_NODE }}
- name: Confirm Node version
run: |
node --version
node -p "process.arch"
- name: Install dependencies
run: |
npm ci --ignore-scripts
mkdir -p build/Release
- uses: actions/download-artifact@v4
if: ${{ inputs.prebuilds_workflow_id == '' }}
with:
name: ncbcc-artifact-linux-x86_64-prebuild
path: build/Release
run-id: ${{ needs.build-prebuilds.outputs.workflow_run_id }}
github-token: ${{ github.token }}
- uses: actions/download-artifact@v4
if: ${{ inputs.prebuilds_workflow_id != '' }}
with:
name: ncbcc-artifact-linux-x86_64-prebuild
path: build/Release
run-id: ${{ inputs.prebuilds_workflow_id }}
github-token: ${{ github.token }}
- name: Build docs
run: |
ls -alh
ls -alh build/Release
npm run build-docs
ls -alh docs
- name: Upload Node.js API docs as artifact
uses: actions/upload-artifact@v4
with:
retention-days: 1
name: ncbcc-api-docs
path: docs/
upload-npm:
name: Upload to npm (prebuilds already built)
needs: build-prebuilds
if: ${{ always() }}
runs-on: ubuntu-22.04
steps:
- uses: actions/download-artifact@v4
if: ${{ inputs.prebuilds_workflow_id == '' }}
with:
name: ncbcc-sdist
run-id: ${{ needs.build-prebuilds.outputs.workflow_run_id }}
github-token: ${{ github.token }}
- uses: actions/download-artifact@v4
if: ${{ inputs.prebuilds_workflow_id != '' }}
with:
name: ncbcc-sdist
run-id: ${{ inputs.prebuilds_workflow_id }}
github-token: ${{ github.token }}
- name: Extract sdist source
run: |
ls -alh
SDIST=$(find . -name '*.tgz' | cut -c 3-)
tar -xvzf $SDIST
cp -r package/** .
rm -rf package
- uses: actions/download-artifact@v4
if: ${{ inputs.prebuilds_workflow_id == '' }}
with:
name: ncbcc-lib
run-id: ${{ needs.build-prebuilds.outputs.workflow_run_id }}
github-token: ${{ github.token }}
- uses: actions/download-artifact@v4
if: ${{ inputs.prebuilds_workflow_id != '' }}
with:
name: ncbcc-lib
run-id: ${{ inputs.prebuilds_workflow_id }}
github-token: ${{ github.token }}
- uses: actions/download-artifact@v4
if: ${{ inputs.prebuilds_workflow_id == '' }}
with:
pattern: ncbcc-artifact-*
path: prebuilds
merge-multiple: true
run-id: ${{ needs.build-prebuilds.outputs.workflow_run_id }}
github-token: ${{ github.token }}
- uses: actions/download-artifact@v4
if: ${{ inputs.prebuilds_workflow_id != '' }}
with:
pattern: ncbcc-artifact-*
path: prebuilds
merge-multiple: true
run-id: ${{ inputs.prebuilds_workflow_id }}
github-token: ${{ github.token }}
- uses: actions/download-artifact@v4
if: ${{ inputs.prebuilds_workflow_id == '' }}
with:
name: ncbcc-platform-packagejson
run-id: ${{ needs.build-prebuilds.outputs.workflow_run_id }}
github-token: ${{ github.token }}
- uses: actions/download-artifact@v4
if: ${{ inputs.prebuilds_workflow_id != '' }}
with:
name: ncbcc-platform-packagejson
run-id: ${{ inputs.prebuilds_workflow_id }}
github-token: ${{ github.token }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.DEFAULT_NODE }}
- name: Confirm Node version
run: |
node --version
node -p "process.arch"
- name: Build platform packages
run: |
ls -alh prebuilds
curl -o platformPackages.js ${CI_SCRIPTS_URL}/ci_scripts/platformPackages.js
node platformPackages.js --build-platform-packages --d ${{ github.workspace }}/prebuilds
rm platPkg.json
ls -alh prebuilds
cat package.json
env:
CI_SCRIPTS_URL: "https://raw.githubusercontent.com/couchbaselabs/sdkbuild-jenkinsfiles/master/couchnode"
- name: Create sdist artifact
run: |
npm install --ignore-scripts
mkdir sdist
npm pack --pack-destination sdist
- name: Upload Node.js sdist as artifact
uses: actions/upload-artifact@v4
with:
retention-days: 1
name: ncbcc-artifact-sdist
path: |
./sdist/*.tgz
- name: Publish to npm
run: |
env
rm -rf sdist
curl -o publish_to_npm.sh ${CI_SCRIPTS_URL}/ci_scripts/publish_to_npm.sh
chmod 755 publish_to_npm.sh
./publish_to_npm.sh ${{ github.workspace }} ${{ github.workspace }}/prebuilds
env:
CI_SCRIPTS_URL: "https://raw.githubusercontent.com/couchbaselabs/sdkbuild-jenkinsfiles/master/couchnode"
PUBLISH_DRY_RUN: "${{ inputs.publish_dryrun }}"
NPM_TAG: ${{ inputs.npm_tag }}