Repository navigation
59 lines (50 loc) · 1.73 KB
/
Copy pathpublish.yml
File metadata and controls
59 lines (50 loc) · 1.73 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
name: Local Binding Publish
on:
workflow_dispatch:
inputs:
version_type:
description: Version Type
required: true
default: patch
type: choice
options:
- patch
- minor
- major
- prerelease
permissions:
contents: read
jobs:
publish:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
env:
VERSION_TYPE: ${{ inputs.version_type }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
# No registry-url: setup-node would write an .npmrc token line that shadows OIDC.
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 24
- run: npm install -g npm@11.21.0
- name: Upgrade version
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
npm version "$VERSION_TYPE" --preid tp
- name: Publish
run: npm publish --access public --tag "$([ "$VERSION_TYPE" = prerelease ] && echo next || echo latest)"
- name: Push tag
if: inputs.version_type == 'prerelease'
run: git push origin "$(git describe --exact-match)"
- name: Push tag and version bump branch
if: inputs.version_type != 'prerelease'
run: |
branch="release-$(date +%s)"
git push --follow-tags origin "HEAD:refs/heads/$branch"
echo "Open the version bump PR: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/compare/master...$branch?expand=1" | tee -a "$GITHUB_STEP_SUMMARY"