-
-
Notifications
You must be signed in to change notification settings - Fork 40
133 lines (126 loc) · 4.84 KB
/
Copy pathrelease.yml
File metadata and controls
133 lines (126 loc) · 4.84 KB
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
# docs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: Release
run-name: Release ${{ inputs.newversion }} ${{ inputs.prerelease == 'true' && '(prerelease)' || '' }}
on:
workflow_dispatch:
inputs:
newversion:
# is param from `npm version`. therefore the description should reference all the options from there
description: 'one of: [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git]'
required: true
commitMessage:
description: 'Release/commit message (%s will be replaced with the resulting version number)'
default: '%s'
required: true
preid:
description: 'The "prerelease identifier" to use as a prefix for the "prerelease" part of a semver. Like the rc in `1.2.0-rc.8`.'
type: choice
options:
- rc
- beta
- alpha
default: rc
required: false
prerelease:
description: "This is a pre-release"
type: boolean
default: false
required: false
permissions: {}
env:
NODE_ACTIVE_LTS: "24" # https://nodejs.org/en/about/releases/
jobs:
bump:
name: bump and tag release
concurrency: release-bump
outputs:
version: ${{ steps.bump.outputs.version }}
version_plain: ${{ steps.bump.outputs.version_plain }}
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write # needed for git push
steps:
- name: Checkout code
# see https://github.com/actions/checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Configure Git
# needed for push back of changes
run: |
set -eux
git config --local user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --local user.name "${GITHUB_ACTOR}"
- name: Setup Node.js ${{ env.NODE_ACTIVE_LTS }}
# see https://github.com/actions/setup-node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ env.NODE_ACTIVE_LTS }}
package-manager-cache: false
## ! no npm build at the moment
- name: bump VERSION
id: bump
run: |
set -eux
COMMIT_SIG="Signed-off-by: $(git config user.name) <$(git config user.email)>"
VERSION="$(npm version "$NPMV_NEWVERSION" --message "$NPMV_MESSAGE"$'\n\n'"$COMMIT_SIG" --preid "$NPMV_PREID")"
echo "::debug::new version = $VERSION"
VERSION_PLAIN="${VERSION:1}" # remove 'v' prefix
echo "::debug::plain version = $VERSION_PLAIN"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "version_plain=$VERSION_PLAIN" >> $GITHUB_OUTPUT
env:
NPMV_NEWVERSION: ${{ github.event.inputs.newversion }}
NPMV_MESSAGE: ${{ github.event.inputs.commitMessage }}
NPMV_PREID: ${{ github.event.inputs.preid }}
- name: git push back
run: git push --follow-tags
publish-NPMJS:
needs:
- "bump"
name: publish NPMJS
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
id-token: write # Enables provenance signing via OIDC
env:
NPMJS_RELEASE_TAG: ${{ github.event.inputs.prerelease == 'true' && 'unstable-prerelease' || 'latest' }}
steps:
- name: Checkout code
# see https://github.com/actions/checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ needs.bump.outputs.version }}
- name: Setup Node.js ${{ env.NODE_ACTIVE_LTS }}
# see https://github.com/actions/setup-node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ env.NODE_ACTIVE_LTS }}
package-manager-cache: false
# no explicit npm build. if a build is required, it should be configured as prepublish/prepublishOnly script of npm.
- name: publish to NPMJS as "${{ env.NPMJS_RELEASE_TAG }}"
run: >
npm publish
--provenance
--access public
--tag "$NPMJS_RELEASE_TAG"
release-GH:
needs:
- "bump"
- "publish-NPMJS"
name: publish GitHub
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write # create a release
steps:
- name: Create Release
id: release
# see https://github.com/softprops/action-gh-release
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.bump.outputs.version }}
name: ${{ needs.bump.outputs.version_plain }}
prerelease: ${{ github.event.inputs.prerelease }}
target_commitish: ${{ github.head_ref || github.ref_name }}