Skip to content

Commit 827a0f1

Browse files
committed
chore: fix workflows
1 parent 6fc9256 commit 827a0f1

4 files changed

Lines changed: 19695 additions & 20232 deletions

File tree

.github/workflows/ci.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,31 @@ jobs:
3131
- name: Install dependencies
3232
run: pnpm install --frozen-lockfile
3333

34-
- name: Lint and test
35-
run: just lint all
34+
- name: Check formatting
35+
run: pnpm format:check
36+
37+
- name: Lint
38+
run: pnpm lint
39+
40+
- name: Typecheck
41+
run: pnpm typecheck
42+
43+
- name: Test
44+
run: pnpm test
45+
46+
- name: Validate action metadata
47+
run: pnpm validate:action
3648

3749
- name: Build dist
3850
run: pnpm build
3951

4052
- name: Verify dist is current
4153
run: git diff --exit-code -- dist/index.js
4254

55+
- name: Download actionlint
56+
run: bash <(curl -fsSL https://raw.githubusercontent.com/rhysd/actionlint/v1.7.12/scripts/download-actionlint.bash) 1.7.12
57+
shell: bash
58+
4359
- name: Validate workflows
44-
uses: rhysd/actionlint@v1
60+
run: ./actionlint -color
61+
shell: bash

.github/workflows/release.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: Action release version to publish, for example v1.0.0
8+
required: true
9+
type: string
10+
prerelease:
11+
description: Mark the GitHub release as a prerelease and skip the major tag update
12+
required: false
13+
default: false
14+
type: boolean
15+
16+
permissions:
17+
contents: write
18+
19+
jobs:
20+
release:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v6
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Setup PNPM
30+
uses: pnpm/action-setup@v6
31+
with:
32+
run_install: false
33+
34+
- name: Setup Node.js
35+
uses: actions/setup-node@v6
36+
with:
37+
node-version: 24
38+
cache: pnpm
39+
40+
- name: Install dependencies
41+
run: pnpm install --frozen-lockfile
42+
43+
- name: Check formatting
44+
run: pnpm format:check
45+
46+
- name: Lint
47+
run: pnpm lint
48+
49+
- name: Typecheck
50+
run: pnpm typecheck
51+
52+
- name: Test
53+
run: pnpm test
54+
55+
- name: Validate action metadata
56+
run: pnpm validate:action
57+
58+
- name: Build dist
59+
run: pnpm build
60+
61+
- name: Verify dist is current
62+
run: git diff --exit-code -- dist/index.js
63+
64+
- name: Validate release version
65+
id: release
66+
env:
67+
RELEASE_VERSION: ${{ inputs.version }}
68+
run: |
69+
set -euo pipefail
70+
71+
if [[ ! "$RELEASE_VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
72+
echo "::error::Release version must look like v1.0.0"
73+
exit 1
74+
fi
75+
76+
if git rev-parse -q --verify "refs/tags/$RELEASE_VERSION" >/dev/null; then
77+
echo "::error::Tag $RELEASE_VERSION already exists"
78+
exit 1
79+
fi
80+
81+
version_without_prefix="${RELEASE_VERSION#v}"
82+
major_version="v${version_without_prefix%%.*}"
83+
84+
echo "version=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
85+
echo "major=$major_version" >> "$GITHUB_OUTPUT"
86+
shell: bash
87+
88+
- name: Create immutable version tag
89+
env:
90+
RELEASE_VERSION: ${{ steps.release.outputs.version }}
91+
run: |
92+
set -euo pipefail
93+
git tag "$RELEASE_VERSION" "$GITHUB_SHA"
94+
git push origin "refs/tags/$RELEASE_VERSION"
95+
shell: bash
96+
97+
- name: Update major version tag
98+
if: ${{ !inputs.prerelease }}
99+
env:
100+
MAJOR_VERSION: ${{ steps.release.outputs.major }}
101+
run: |
102+
set -euo pipefail
103+
git tag -f "$MAJOR_VERSION" "$GITHUB_SHA"
104+
git push --force origin "refs/tags/$MAJOR_VERSION"
105+
shell: bash
106+
107+
- name: Create GitHub release
108+
env:
109+
GH_TOKEN: ${{ github.token }}
110+
PRERELEASE: ${{ inputs.prerelease }}
111+
RELEASE_VERSION: ${{ steps.release.outputs.version }}
112+
run: |
113+
set -euo pipefail
114+
115+
args=(release create "$RELEASE_VERSION" --title "$RELEASE_VERSION" --generate-notes)
116+
117+
if [[ "$PRERELEASE" == "true" ]]; then
118+
args+=(--prerelease)
119+
fi
120+
121+
gh "${args[@]}"
122+
shell: bash

0 commit comments

Comments
 (0)