mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
fix: gh actions
This commit is contained in:
41
.github/workflows/release.yaml
vendored
41
.github/workflows/release.yaml
vendored
@@ -2,42 +2,75 @@ name: Release
|
|||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
branches:
|
||||||
- 'v*'
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
if: startsWith(github.event.head_commit.message, 'chore(release):')
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Extract version from commit message
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
VERSION=$(echo "${{ github.event.head_commit.message }}" | sed -E 's/^chore\(release\): //')
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Create and push tag
|
||||||
|
if: steps.version.outputs.version != ''
|
||||||
|
run: |
|
||||||
|
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
git config --local user.name "github-actions[bot]"
|
||||||
|
# Check if tag exists before creating
|
||||||
|
if ! git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
|
||||||
|
git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}"
|
||||||
|
git push --tags
|
||||||
|
else
|
||||||
|
echo "Tag v${{ steps.version.outputs.version }} already exists, skipping creation"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Setup Bun
|
- name: Setup Bun
|
||||||
uses: oven-sh/setup-bun@v2
|
uses: oven-sh/setup-bun@v2
|
||||||
|
if: steps.version.outputs.version != ''
|
||||||
with:
|
with:
|
||||||
bun-version: latest
|
bun-version: latest
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
|
if: steps.version.outputs.version != ''
|
||||||
run: bun install --frozen-lockfile
|
run: bun install --frozen-lockfile
|
||||||
|
|
||||||
- name: Build CLI
|
- name: Build CLI
|
||||||
|
if: steps.version.outputs.version != ''
|
||||||
run: bun run build:cli
|
run: bun run build:cli
|
||||||
env:
|
env:
|
||||||
BTS_TELEMETRY: 1
|
BTS_TELEMETRY: 1
|
||||||
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
|
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
|
||||||
POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }}
|
POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }}
|
||||||
|
|
||||||
- name: Generate Changelog
|
- name: Create GitHub Release
|
||||||
run: bun run release
|
if: steps.version.outputs.version != ''
|
||||||
|
run: |
|
||||||
|
# Check if release exists before creating
|
||||||
|
if ! gh release view "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
|
||||||
|
bunx changelogithub
|
||||||
|
else
|
||||||
|
echo "Release v${{ steps.version.outputs.version }} already exists, skipping creation"
|
||||||
|
fi
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Publish CLI to NPM
|
- name: Publish CLI to NPM
|
||||||
|
if: steps.version.outputs.version != ''
|
||||||
run: cd apps/cli && bun publish --access public
|
run: cd apps/cli && bun publish --access public
|
||||||
env:
|
env:
|
||||||
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
@@ -85,8 +85,7 @@ async function main(): Promise<void> {
|
|||||||
await $`bun run build:cli`;
|
await $`bun run build:cli`;
|
||||||
await $`git add apps/cli/package.json bun.lock`;
|
await $`git add apps/cli/package.json bun.lock`;
|
||||||
await $`git commit -m "chore(release): ${newVersion}"`;
|
await $`git commit -m "chore(release): ${newVersion}"`;
|
||||||
await $`git tag v${newVersion}`;
|
await $`git push origin main`;
|
||||||
await $`git push origin v${newVersion}`;
|
|
||||||
|
|
||||||
console.log(`✅ Released v${newVersion}`);
|
console.log(`✅ Released v${newVersion}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user