Skip to content

Commit c033872

Browse files
fix: gh actions
1 parent e27a3d5 commit c033872

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

.github/workflows/release.yaml

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,75 @@ name: Release
22

33
permissions:
44
contents: write
5+
pull-requests: write
6+
id-token: write
57

68
on:
79
push:
8-
tags:
9-
- 'v*'
10+
branches:
11+
- main
1012

1113
jobs:
1214
release:
1315
runs-on: ubuntu-latest
16+
if: startsWith(github.event.head_commit.message, 'chore(release):')
1417
steps:
1518
- name: Checkout Code
1619
uses: actions/checkout@v4
1720
with:
1821
fetch-depth: 0
1922

23+
- name: Extract version from commit message
24+
id: version
25+
run: |
26+
VERSION=$(echo "${{ github.event.head_commit.message }}" | sed -E 's/^chore\(release\): //')
27+
echo "version=$VERSION" >> $GITHUB_OUTPUT
28+
29+
- name: Create and push tag
30+
if: steps.version.outputs.version != ''
31+
run: |
32+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
33+
git config --local user.name "github-actions[bot]"
34+
# Check if tag exists before creating
35+
if ! git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
36+
git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}"
37+
git push --tags
38+
else
39+
echo "Tag v${{ steps.version.outputs.version }} already exists, skipping creation"
40+
fi
41+
2042
- name: Setup Bun
2143
uses: oven-sh/setup-bun@v2
44+
if: steps.version.outputs.version != ''
2245
with:
2346
bun-version: latest
2447

2548
- name: Install Dependencies
49+
if: steps.version.outputs.version != ''
2650
run: bun install --frozen-lockfile
2751

2852
- name: Build CLI
53+
if: steps.version.outputs.version != ''
2954
run: bun run build:cli
3055
env:
3156
BTS_TELEMETRY: 1
3257
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
3358
POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }}
3459

35-
- name: Generate Changelog
36-
run: bun run release
60+
- name: Create GitHub Release
61+
if: steps.version.outputs.version != ''
62+
run: |
63+
# Check if release exists before creating
64+
if ! gh release view "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
65+
bunx changelogithub
66+
else
67+
echo "Release v${{ steps.version.outputs.version }} already exists, skipping creation"
68+
fi
3769
env:
3870
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3971

4072
- name: Publish CLI to NPM
73+
if: steps.version.outputs.version != ''
4174
run: cd apps/cli && bun publish --access public
4275
env:
4376
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}

scripts/bump-version.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ async function main(): Promise<void> {
8585
await $`bun run build:cli`;
8686
await $`git add apps/cli/package.json bun.lock`;
8787
await $`git commit -m "chore(release): ${newVersion}"`;
88-
await $`git tag v${newVersion}`;
89-
await $`git push origin v${newVersion}`;
88+
await $`git push origin main`;
9089

9190
console.log(`✅ Released v${newVersion}`);
9291
}

0 commit comments

Comments
 (0)