-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (107 loc) · 3.47 KB
/
release.yml
File metadata and controls
132 lines (107 loc) · 3.47 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
name: Release
on:
workflow_dispatch:
inputs:
version:
description: Action release version to publish, for example v1.0.0
required: true
type: string
prerelease:
description: Mark the GitHub release as a prerelease and skip moving action tag updates
required: false
default: false
type: boolean
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup PNPM
uses: pnpm/action-setup@v6
with:
run_install: false
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Check formatting
run: pnpm format:check
- name: Lint
run: pnpm lint
- name: Typecheck
run: pnpm typecheck
- name: Test
run: pnpm test
- name: Validate action metadata
run: pnpm validate:action
- name: Build dist
run: pnpm build
- name: Verify dist is current
run: git diff --exit-code -- dist/index.js
- name: Validate release version
id: release
env:
RELEASE_VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
if [[ ! "$RELEASE_VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "::error::Release version must look like v1.0.0"
exit 1
fi
if git rev-parse -q --verify "refs/tags/$RELEASE_VERSION" >/dev/null; then
echo "::error::Tag $RELEASE_VERSION already exists"
exit 1
fi
version_without_prefix="${RELEASE_VERSION#v}"
major="${version_without_prefix%%.*}"
remaining="${version_without_prefix#*.}"
minor="${remaining%%.*}"
major_version="v$major"
minor_version="v$major.$minor"
{
echo "version=$RELEASE_VERSION"
echo "major=$major_version"
echo "minor=$minor_version"
} >> "$GITHUB_OUTPUT"
shell: bash
- name: Create immutable version tag
env:
RELEASE_VERSION: ${{ steps.release.outputs.version }}
run: |
set -euo pipefail
git tag "$RELEASE_VERSION" "$GITHUB_SHA"
git push origin "refs/tags/$RELEASE_VERSION"
shell: bash
- name: Update moving action tags
if: ${{ !inputs.prerelease }}
env:
MAJOR_VERSION: ${{ steps.release.outputs.major }}
MINOR_VERSION: ${{ steps.release.outputs.minor }}
run: |
set -euo pipefail
git tag -f "$MINOR_VERSION" "$GITHUB_SHA"
git push --force origin "refs/tags/$MINOR_VERSION"
git tag -f "$MAJOR_VERSION" "$GITHUB_SHA"
git push --force origin "refs/tags/$MAJOR_VERSION"
shell: bash
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
PRERELEASE: ${{ inputs.prerelease }}
RELEASE_VERSION: ${{ steps.release.outputs.version }}
run: |
set -euo pipefail
args=(release create "$RELEASE_VERSION" --title "$RELEASE_VERSION" --generate-notes)
if [[ "$PRERELEASE" == "true" ]]; then
args+=(--prerelease)
fi
gh "${args[@]}"
shell: bash