Skip to content

Commit 5cae26a

Browse files
committed
chore(ci): manual release trigger
1 parent 865e0a5 commit 5cae26a

File tree

2 files changed

+100
-28
lines changed

2 files changed

+100
-28
lines changed

.github/workflows/release.yml

Lines changed: 100 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,122 @@
11
name: Release
2+
23
on:
3-
push:
4-
branches:
5-
- master
4+
workflow_dispatch:
5+
inputs:
6+
releaseType:
7+
description: 'Release type (patch, minor, major)'
8+
required: false
9+
default: 'auto'
10+
type: choice
11+
options:
12+
- auto
13+
- patch
14+
- minor
15+
- major
16+
dryRun:
17+
description: 'Dry run (no actual release)'
18+
required: false
19+
default: false
20+
type: boolean
21+
preRelease:
22+
description: 'Pre-release identifier (beta, alpha, rc, etc.)'
23+
required: false
24+
default: ''
25+
type: string
26+
repository_dispatch:
27+
types: [release-trigger]
28+
629
jobs:
730
release:
831
name: Release
932
runs-on: ubuntu-latest
33+
strategy:
34+
matrix:
35+
node-version: [22]
36+
outputs:
37+
released: ${{ steps.release.outputs.released }}
38+
version: ${{ steps.extract-version.outputs.version }}
1039
steps:
1140
- name: Checkout
12-
uses: actions/checkout@v2
41+
uses: actions/checkout@v4
1342
with:
1443
fetch-depth: 0
44+
token: ${{ secrets.GITHUB_TOKEN }}
45+
1546
- name: Setup Node
1647
uses: actions/setup-node@v4
1748
with:
18-
node-version: 22
19-
cache: 'npm'
49+
node-version: ${{ matrix.node-version }}
50+
cache: npm
51+
2052
- name: Setup Deno
2153
uses: denolib/setup-deno@v2
2254
with:
23-
deno-version: v1.x
24-
- name: Install dependencies
55+
deno-version: v1.x
56+
57+
- name: Validate trigger
58+
id: validate
2559
run: |
26-
npm install
27-
npm run build --if-present
60+
if [[ "${{ github.event_name }}" == "workflow_dispatch" || "${{ github.event_name }}" == "repository_dispatch" ]]; then
61+
echo "valid=true" >> "$GITHUB_OUTPUT"
62+
else
63+
echo "valid=false" >> "$GITHUB_OUTPUT"
64+
fi
65+
66+
- name: Install dependencies
67+
if: steps.validate.outputs.valid == 'true'
68+
run: npm install
69+
70+
- name: Build
71+
if: steps.validate.outputs.valid == 'true'
72+
run: npm run build --if-present
73+
2874
- name: Run tests
29-
run: |
30-
npm run test
75+
if: steps.validate.outputs.valid == 'true'
76+
run: npm run test
77+
3178
- name: Release
79+
id: release
80+
if: steps.validate.outputs.valid == 'true'
3281
env:
3382
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3483
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
35-
run: npx semantic-release
84+
RELEASE_TYPE: ${{ github.event.inputs.releaseType || 'auto' }}
85+
DRY_RUN: ${{ github.event.inputs.dryRun || 'false' }}
86+
PRE_RELEASE: ${{ github.event.inputs.preRelease || '' }}
87+
run: |
88+
EXTRA_ARGS=""
89+
90+
if [ "$DRY_RUN" = "true" ]; then
91+
echo "Running in dry-run mode"
92+
EXTRA_ARGS="--dry-run"
93+
fi
94+
95+
if [ -n "$PRE_RELEASE" ]; then
96+
echo "Running pre-release: $PRE_RELEASE"
97+
npx semantic-release --prerelease "$PRE_RELEASE" $EXTRA_ARGS
98+
EXIT_CODE=$?
99+
elif [ "$RELEASE_TYPE" = "auto" ]; then
100+
echo "Running auto release"
101+
npx semantic-release $EXTRA_ARGS
102+
EXIT_CODE=$?
103+
else
104+
echo "Running release with type: $RELEASE_TYPE"
105+
npx semantic-release --release-as "$RELEASE_TYPE" $EXTRA_ARGS
106+
EXIT_CODE=$?
107+
fi
108+
109+
if [ "$DRY_RUN" != "true" ] && [ $EXIT_CODE -eq 0 ]; then
110+
echo "released=true" >> "$GITHUB_OUTPUT"
111+
else
112+
echo "released=false" >> "$GITHUB_OUTPUT"
113+
fi
114+
115+
exit $EXIT_CODE
116+
117+
- name: Extract version
118+
id: extract-version
119+
if: steps.release.outputs.released == 'true'
120+
run: |
121+
VERSION=$(node -p "require('./package.json').version")
122+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

package-lock.json

Lines changed: 0 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)