-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (130 loc) · 4.42 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
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
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 | tee -a $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:: 💡 The simplest method is to create a Classic npm token of type Automation."
echo "::error:: 💡 For greater security, consider using a Granual access token."
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 | tee -a $GITHUB_OUTPUT
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Neon Environment
uses: ./.github/actions/setup
with:
use-rust: false
- 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) | tee -a $GITHUB_OUTPUT
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@v4
with:
ref: ${{ needs.setup.outputs.ref }}
- name: Setup Neon Environment
uses: ./.github/actions/setup
with:
use-rust: false
- name: Fetch
uses: robinraju/release-downloader@c39a3b234af58f0cf85888573d361fb6fa281534 # v1.10
with:
tag: ${{ needs.setup.outputs.tag }}
fileName: "*.tgz"
out-file-path: ./dist
- name: Publish
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
for p in ./dist/*.tgz ; do
npm publish --access public $p
done