Skip to content

Commit 13c75ae

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

File tree

8 files changed

+68
-1
lines changed

8 files changed

+68
-1
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: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ async function getCommitsBetweenVersions(
197197
const commitEntries = gitLog.split('\n').filter((line) => line.trim())
198198

199199
const nonVersionCommits = commitEntries.filter((line) => {
200-
const [hash, message] = line.split('|')
200+
const [, message] = line.split('|')
201201
const isVersionCommit = message.match(/^v\d+\.\d+/)
202202
if (isVersionCommit) {
203203
console.log(`⏭️ Skipping version commit: ${message.substring(0, 50)}...`)
@@ -369,6 +369,25 @@ async function main() {
369369
console.log(`ℹ️ No previous version found (this might be the first release)`)
370370
}
371371

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

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

0 commit comments

Comments
 (0)