Skip to content

Instantly share code, notes, and snippets.

@corasan
Created January 23, 2026 14:39
Show Gist options
  • Select an option

  • Save corasan/c26607a49ef47e98dc8233d0a92aaec4 to your computer and use it in GitHub Desktop.

Select an option

Save corasan/c26607a49ef47e98dc8233d0a92aaec4 to your computer and use it in GitHub Desktop.
Custom release script for expo apps with Bun
#!/usr/bin/env bun
import { $ } from 'bun'
const VALID_BUMPS = ['patch', 'minor', 'major'] as const
type Bump = (typeof VALID_BUMPS)[number]
function bumpVersion(current: string, bump: Bump): string {
const [major, minor, patch] = current.split('.').map(Number)
switch (bump) {
case 'major':
return `${major + 1}.0.0`
case 'minor':
return `${major}.${minor + 1}.0`
case 'patch':
return `${major}.${minor}.${patch + 1}`
}
}
async function updatePackageJson(version: string) {
const file = Bun.file('package.json')
const pkg = await file.json()
pkg.version = version
await Bun.write(file, `${JSON.stringify(pkg, null, '\t')}\n`)
}
async function updateAppConfig(version: string) {
const file = Bun.file('app.config.ts')
let content = await file.text()
content = content.replace(
/version: '[0-9]+\.[0-9]+\.[0-9]+'/,
`version: '${version}'`,
)
await Bun.write(file, content)
}
async function run() {
const bump = process.argv[2] as Bump | undefined
if (!bump || !VALID_BUMPS.includes(bump)) {
console.error('Usage: bun scripts/release.ts <patch|minor|major>')
process.exit(1)
}
const pkg = await Bun.file('package.json').json()
const currentVersion = pkg.version
const newVersion = bumpVersion(currentVersion, bump)
const tag = `v${newVersion}`
console.log(`Bumping version: ${currentVersion} → ${newVersion}`)
await updatePackageJson(newVersion)
await updateAppConfig(newVersion)
console.log('Updated package.json and app.config.ts')
await $`git add package.json app.config.ts`
await $`git commit -m "chore: release ${tag}"`
console.log('Committed version bump')
await $`git tag ${tag}`
console.log(`Created tag ${tag}`)
await $`git push origin main --tags`
console.log('Pushed to origin')
await $`gh release create ${tag} --generate-notes`
console.log(`Created GitHub release ${tag}`)
console.log('\n✓ Release complete! Build will trigger automatically.')
}
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment