-
Notifications
You must be signed in to change notification settings - Fork 2
214 lines (208 loc) · 7.02 KB
/
release.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
name: Release
run-name: |
${{ (github.event_name == 'workflow_dispatch' && inputs.dryrun
&& 'Dry run')
|| (github.event_name == 'workflow_dispatch'
&& format('Release: {0}', (inputs.version == 'custom' && inputs.custom) || inputs.version))
|| format('Release: {0}', github.event.head_commit.message) }}
on:
# Event: A maintainer has pushed a new release tag for publication.
push:
tags:
- v*
# Event: A maintainer has used the GitHub Actions UI to initiate
# either tagging a new release for publication or doing a
# dry run.
workflow_dispatch:
inputs:
dryrun:
description: 'Dry run (no npm publish)'
required: false
type: boolean
default: true
version:
description: 'Version component to update (or "custom" to provide exact version)'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
- prepatch
- preminor
- premajor
- prerelease
- custom
custom:
description: 'Custom version'
required: false
default: ''
jobs:
setup:
name: Setup
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
dryrun: ${{ steps.dryrun.outputs.dryrun }}
publish: ${{ steps.publish.outputs.publish }}
ref: ${{ steps.tag.outputs.tag || github.event.repository.default_branch }}
tag: ${{ steps.tag.outputs.tag || steps.get-tag.outputs.tag || '' }}
steps:
- name: Validate Workflow Inputs
if: ${{ inputs.version == 'custom' && inputs.custom == '' }}
shell: bash
run: |
echo '::error::No custom version number provided'
exit 1
- id: dryrun
name: Validate Dry Run Event
if: ${{ github.event_name == 'workflow_dispatch' && inputs.dryrun }}
shell: bash
run: echo dryrun=true >> "$GITHUB_OUTPUT"
- id: publish
name: Validate Publish Event
if: ${{ github.event_name == 'push' || !inputs.dryrun }}
shell: bash
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
if [[ -z $NPM_TOKEN ]]; then
echo "::error::Secret NPM_TOKEN is not defined for this GitHub repo."
echo "::error::To publish to npm, this action requires:"
echo "::error:: • an npm access token;"
echo "::error:: • with Read-Write access to this project's npm packages;"
echo "::error:: • stored as a repo secret named NPM_TOKEN."
echo "::error::See https://docs.npmjs.com/about-access-tokens for info about creating npm tokens."
echo "::error::See https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions for info about how to store GitHub repo secrets."
exit 1
fi
echo publish=true >> "$GITHUB_OUTPUT"
- name: Checkout Code
uses: actions/checkout@v3
- name: Set Environment Variables
uses: falti/dotenv-action@v1
with:
path: ./.github/workflows/.env
export-variables: true
keys-case: bypass
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: ${{ env.NPM_REGISTRY }}
cache: npm
- name: Install Dependencies
shell: bash
run: npm ci
- name: Tag Release (manual only)
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.dryrun }}
id: tag
shell: bash
run: |
git config --global user.name $ACTIONS_USER
git config --global user.email $ACTIONS_EMAIL
npm run release -- '${{ (inputs.version == 'custom' && inputs.custom) || inputs.version }}'
echo tag=$(git describe --abbrev=0) >> "$GITHUB_OUTPUT"
- name: Get Tag (push only)
if: ${{ github.event_name == 'push' }}
id: get-tag
uses: olegtarasov/[email protected]
- name: Diagnostics
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.dryrun }}
shell: bash
run: git tag --sort=-taggerdate
build:
name: Build
needs: [setup]
permissions:
contents: write
uses: ./.github/workflows/build.yml
with:
ref: ${{ needs.setup.outputs.ref }}
tag: ${{ needs.setup.outputs.tag }}
update-version: ${{ !!needs.setup.outputs.dryrun }}
version: ${{ (inputs.version == 'custom' && inputs.custom) || inputs.version }}
github-release: ${{ !!needs.setup.outputs.publish }}
publish:
name: Publish
if: ${{ needs.setup.outputs.publish }}
needs: [setup, build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Diagnostics
shell: bash
run: git tag --sort=-taggerdate
- name: Set Environment Variables
uses: falti/dotenv-action@v1
with:
path: ./.github/workflows/.env
export-variables: true
keys-case: bypass
- name: Diagnostics
shell: bash
run: |
echo 'needs.setup.outputs.tag=${{ needs.setup.outputs.tag }}'
git log -10
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: ${{ env.NPM_REGISTRY }}
cache: npm
- name: Install Dependencies
shell: bash
run: npm ci
- name: Fetch (cargo-messages)
uses: robinraju/[email protected]
with:
tag: ${{ needs.setup.outputs.tag }}
fileName: "*.tgz"
out-file-path: ./pkgs/cargo-messages/dist
- name: Diagnostics
shell: bash
run: ls -al
working-directory: ./pkgs/cargo-messages/dist
- name: Publish (cargo-messages)
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
for p in ./pkgs/cargo-messages/dist/*.tgz ; do
echo "UNPACKING: $p"
ls -al ./pkgs/cargo-messages/dist/$p
mkdir -p tmp-unpack
cd tmp-unpack
cp ../$p ./
tar xzf $p
ls -al ./package
cat ./package/package.json
cd ..
rm -rf tmp-unpack
npm publish --access public ./pkgs/cargo-messages/dist/$p
echo "NEEEEEXT"
done
working-directory: ./pkgs/cargo-messages/dist
- name: Build (@neon-rs/load)
shell: bash
run: npm run build
working-directory: ./pkgs/load
- name: Publish (@neon-rs/load)
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public
working-directory: ./pkgs/load
- name: Publish (@neon-rs/cli)
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public
working-directory: ./dist/cli