Skip to content

Commit 37043db

Browse files
committed
freebuff: Add ability to deploy from a specific commit
1 parent 2ac662d commit 37043db

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

.github/workflows/freebuff-release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ on:
1212
- patch
1313
- minor
1414
- major
15+
checkout_ref:
16+
description: 'Git ref to build from (commit SHA, branch, or tag). Defaults to latest main.'
17+
required: false
18+
default: ''
19+
type: string
1520

1621
concurrency:
1722
group: freebuff-release
@@ -78,7 +83,7 @@ jobs:
7883
binary-name: freebuff
7984
new-version: ${{ needs.prepare-and-commit.outputs.new_version }}
8085
artifact-name: freebuff-updated-package
81-
checkout-ref: ${{ github.sha }}
86+
checkout-ref: ${{ inputs.checkout_ref || github.sha }}
8287
env-overrides: '{"FREEBUFF_MODE": "true", "NEXT_PUBLIC_CB_ENVIRONMENT": "prod"}'
8388
secrets: inherit
8489

freebuff/cli/release.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* to build, publish, and release the Freebuff CLI to npm.
88
*
99
* Usage:
10-
* bun freebuff/cli/release.ts [patch|minor|major]
10+
* bun freebuff/cli/release.ts [patch|minor|major] [--ref <commit-sha>]
1111
*
1212
* Requires:
1313
* CODEBUFF_GITHUB_TOKEN environment variable
@@ -16,7 +16,18 @@
1616
import { execSync } from 'child_process'
1717

1818
const args = process.argv.slice(2)
19-
const versionType = args[0] || 'patch'
19+
20+
let versionType = 'patch'
21+
let checkoutRef = ''
22+
23+
for (let i = 0; i < args.length; i++) {
24+
if (args[i] === '--ref' && args[i + 1]) {
25+
checkoutRef = args[i + 1]
26+
i++
27+
} else if (!args[i].startsWith('--')) {
28+
versionType = args[i]
29+
}
30+
}
2031

2132
function log(message: string) {
2233
console.log(`${message}`)
@@ -53,18 +64,24 @@ function checkGitHubToken() {
5364
return token
5465
}
5566

56-
async function triggerWorkflow(versionType: string) {
67+
async function triggerWorkflow(versionType: string, checkoutRef: string) {
5768
if (!process.env.GITHUB_TOKEN) {
5869
error('GITHUB_TOKEN environment variable is required but not set')
5970
}
6071

6172
try {
73+
const inputs: Record<string, string> = { version_type: versionType }
74+
if (checkoutRef) {
75+
inputs.checkout_ref = checkoutRef
76+
}
77+
const payload = JSON.stringify({ ref: 'main', inputs })
78+
6279
const triggerCmd = `curl -s -w "HTTP Status: %{http_code}" -X POST \
6380
-H "Accept: application/vnd.github.v3+json" \
6481
-H "Authorization: token ${process.env.GITHUB_TOKEN}" \
6582
-H "Content-Type: application/json" \
6683
https://api.github.com/repos/CodebuffAI/codebuff/actions/workflows/freebuff-release.yml/dispatches \
67-
-d '{"ref":"main","inputs":{"version_type":"${versionType}"}}'`
84+
-d '${payload}'`
6885

6986
const response = execSync(triggerCmd, { encoding: 'utf8' })
7087

@@ -93,8 +110,11 @@ async function main() {
93110
log('✅ Using local CODEBUFF_GITHUB_TOKEN')
94111

95112
log(`Version bump type: ${versionType}`)
113+
if (checkoutRef) {
114+
log(`Building from ref: ${checkoutRef}`)
115+
}
96116

97-
await triggerWorkflow(versionType)
117+
await triggerWorkflow(versionType, checkoutRef)
98118

99119
log('')
100120
log(

opencode

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 73ee493265acf15fcd8caab2bc8cd3bd375b63cb

0 commit comments

Comments
 (0)