-
Notifications
You must be signed in to change notification settings - Fork 2
176 lines (171 loc) · 5.48 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
name: Release
run-name: |
${{ (inputs.dryrun && 'Dry run')
|| format('Release: {0}', (inputs.version == 'custom' && inputs.custom) || inputs.version) }}
on:
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:
- 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: ${{ inputs.dryrun }}
shell: bash
run: echo dryrun=true >> "$GITHUB_OUTPUT"
- id: publish
name: Validate Publish Event
if: ${{ !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: Diagnostics
shell: bash
run: |
git log -10
- name: Setup Neon Environment
uses: ./.github/actions/setup-neon
with:
use-rust: false
- name: Install Dependencies
shell: bash
run: npm ci
- name: Tag Release
if: ${{ !inputs.dryrun }}
id: tag
shell: bash
run: |
git config --global user.name $ACTIONS_USER
git config --global user.email $ACTIONS_EMAIL
npm version -m 'v%s' '${{ (inputs.version == 'custom' && inputs.custom) || inputs.version }}'
git push --follow-tags
echo tag=$(git describe --abbrev=0) >> "$GITHUB_OUTPUT"
- name: Diagnostics
if: ${{ !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:
ref: ${{ needs.setup.outputs.ref }}
- name: Diagnostics
shell: bash
run: git tag --sort=-taggerdate
- name: Diagnostics
shell: bash
run: |
echo 'needs.setup.outputs.tag=${{ needs.setup.outputs.tag }}'
git log -10
- name: Setup Neon Environment
uses: ./.github/actions/setup-neon
with:
use-rust: false
- 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
npm publish --access public $p
done
- 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