Repository navigation
88 lines (77 loc) · 2.58 KB
/
Copy pathrelease.yaml
File metadata and controls
88 lines (77 loc) · 2.58 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
name: Release
run-name: ${{ github.workflow }} v${{ inputs.version }}
on:
workflow_dispatch:
inputs:
version:
description: 'Bump version (e.g., 4.0.0, 4.1.0-alpha.1, 5.0.0-beta.2)'
required: true
type: string
tag:
description: 'npm dist-tag to publish under (leave empty to fallback to preid, or "latest" for stable)'
required: false
type: string
skip_git_check:
description: Skip git checks when publishing (--no-git-checks)
required: false
type: boolean
default: false
skip_bump:
description: Skip version bump (bumpp) step
required: false
type: boolean
default: false
skip_changelog:
description: Skip changelog generation (changelogithub) step
required: false
type: boolean
default: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
env:
VERSION: ${{ inputs.version }}
steps:
- id: version
env:
TAG_INPUT: ${{ inputs.tag }}
run: |
if [[ ! $VERSION =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-([a-z]+)\.([1-9][0-9]*))?$ ]]; then
echo "INVALID VERSION FORMAT: $VERSION" >&2
exit 1
fi
PREID="${BASH_REMATCH[5]}"
if [[ $PREID == "latest" ]]; then
echo "INVALID VERSION FORMAT ('latest' is not allowed): $VERSION" >&2
exit 1
fi
TAG="${TAG_INPUT:-${PREID:-latest}}"
if [[ ! $TAG =~ ^[a-z][a-z0-9._-]*$ ]]; then
echo "INVALID TAG FORMAT: $TAG" >&2
exit 1
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: pnpm/action-setup@v6
- run: pnpm i
- run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- run: pnpm exec bumpp -r "$VERSION" --yes
if: ${{ !inputs.skip_bump }}
- run: pnpm exec changelogithub --draft
if: ${{ !inputs.skip_changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: pnpm --filter='./packages/*' publish -r --provenance --access=public --tag="$TAG" $NO_GIT_CHECKS
env:
TAG: ${{ steps.version.outputs.tag }}
NO_GIT_CHECKS: ${{ inputs.skip_git_check && '--no-git-checks' || '' }}