Skip to content

Commit 17b96ef

Browse files
committed
feat(ci): auto-create github releases and add workflow permissions
1 parent 56bc809 commit 17b96ef

File tree

8 files changed

+69
-0
lines changed

8 files changed

+69
-0
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ concurrency:
1010
group: ci-${{ github.ref }}
1111
cancel-in-progress: false
1212

13+
permissions:
14+
contents: read
15+
1316
jobs:
1417
test-build:
1518
name: Test and Build
@@ -278,3 +281,30 @@ jobs:
278281
if: needs.check-docs-changes.outputs.docs_changed == 'true'
279282
uses: ./.github/workflows/docs-embeddings.yml
280283
secrets: inherit
284+
285+
# Create GitHub Release (only for version commits on main, after all builds complete)
286+
create-release:
287+
name: Create GitHub Release
288+
runs-on: blacksmith-4vcpu-ubuntu-2404
289+
needs: [create-ghcr-manifests, detect-version]
290+
if: needs.detect-version.outputs.is_release == 'true'
291+
permissions:
292+
contents: write
293+
steps:
294+
- name: Checkout code
295+
uses: actions/checkout@v4
296+
with:
297+
fetch-depth: 0
298+
299+
- name: Setup Bun
300+
uses: oven-sh/setup-bun@v2
301+
with:
302+
bun-version: latest
303+
304+
- name: Install dependencies
305+
run: bun install --frozen-lockfile
306+
307+
- name: Create release
308+
env:
309+
GH_PAT: ${{ secrets.GITHUB_TOKEN }}
310+
run: bun run scripts/create-single-release.ts ${{ needs.detect-version.outputs.version }}

.github/workflows/docs-embeddings.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
workflow_call:
55
workflow_dispatch: # Allow manual triggering
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
process-docs-embeddings:
912
name: Process Documentation Embeddings

.github/workflows/migrations.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
workflow_call:
55
workflow_dispatch:
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
migrate:
912
name: Apply Database Migrations

.github/workflows/publish-cli.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
paths:
77
- 'packages/cli/**'
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
publish-npm:
1114
runs-on: blacksmith-4vcpu-ubuntu-2404

.github/workflows/publish-python-sdk.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
paths:
77
- 'packages/python-sdk/**'
88

9+
permissions:
10+
contents: write
11+
912
jobs:
1013
publish-pypi:
1114
runs-on: blacksmith-4vcpu-ubuntu-2404

.github/workflows/publish-ts-sdk.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
paths:
77
- 'packages/ts-sdk/**'
88

9+
permissions:
10+
contents: write
11+
912
jobs:
1013
publish-npm:
1114
runs-on: blacksmith-4vcpu-ubuntu-2404

.github/workflows/test-build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
workflow_call:
55
workflow_dispatch:
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
test-build:
912
name: Test and Build

scripts/create-single-release.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,27 @@ async function main() {
369369
console.log(`ℹ️ No previous version found (this might be the first release)`)
370370
}
371371

372+
// Check if release already exists
373+
try {
374+
const existingRelease = await octokit.rest.repos.getReleaseByTag({
375+
owner: REPO_OWNER,
376+
repo: REPO_NAME,
377+
tag: targetVersion,
378+
})
379+
if (existingRelease.data) {
380+
console.log(`ℹ️ Release ${targetVersion} already exists, skipping creation`)
381+
console.log(
382+
`🔗 View release: https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/tag/${targetVersion}`
383+
)
384+
return
385+
}
386+
} catch (error: any) {
387+
// 404 means release doesn't exist, which is expected
388+
if (error.status !== 404) {
389+
throw error
390+
}
391+
}
392+
372393
const releaseBody = await generateReleaseBody(versionCommit, previousCommit || undefined)
373394

374395
console.log(`🚀 Creating GitHub release for ${targetVersion}...`)

0 commit comments

Comments
 (0)