mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-28 13:14:28 +01:00
ci: snapshot builds
This commit is contained in:
50
.github/workflows/snapshot.yml
vendored
Normal file
50
.github/workflows/snapshot.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
name: snapshot
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
- opentui
|
||||||
|
|
||||||
|
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- run: git fetch --force --tags
|
||||||
|
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ">=1.24.0"
|
||||||
|
cache: true
|
||||||
|
cache-dependency-path: go.sum
|
||||||
|
|
||||||
|
- uses: oven-sh/setup-bun@v2
|
||||||
|
with:
|
||||||
|
bun-version: 1.2.21
|
||||||
|
|
||||||
|
- name: Cache ~/.bun
|
||||||
|
id: cache-bun
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/.bun
|
||||||
|
key: ${{ runner.os }}-bun-1-2-21-${{ hashFiles('bun.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-bun-1-2-21-
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: bun install
|
||||||
|
|
||||||
|
- name: Publish
|
||||||
|
run: |
|
||||||
|
./packages/opencode/script/publish.ts
|
||||||
|
env:
|
||||||
|
OPENCODE_SNAPSHOT: true
|
||||||
|
OPENCODE_TAG: ${{ github.ref_name }}
|
||||||
|
GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }}
|
||||||
|
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
@@ -5,10 +5,14 @@ import { $ } from "bun"
|
|||||||
|
|
||||||
import pkg from "../package.json"
|
import pkg from "../package.json"
|
||||||
|
|
||||||
const dry = process.env["OPENCODE_DRY"] === "true"
|
|
||||||
const version = process.env["OPENCODE_VERSION"]!
|
|
||||||
const snapshot = process.env["OPENCODE_SNAPSHOT"] === "true"
|
const snapshot = process.env["OPENCODE_SNAPSHOT"] === "true"
|
||||||
const npmTag = snapshot ? "snapshot" : "latest"
|
let version = process.env["OPENCODE_VERSION"]
|
||||||
|
const tag = process.env["OPENCODE_TAG"] ?? (snapshot ? "snapshot" : "latest")
|
||||||
|
if (!version && snapshot) {
|
||||||
|
version = `0.0.0-${tag}-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}`
|
||||||
|
process.env["OPENCODE_VERSION"] = version
|
||||||
|
}
|
||||||
|
if (!version) throw new Error("OPENCODE_VERSION is required")
|
||||||
|
|
||||||
console.log(`publishing ${version}`)
|
console.log(`publishing ${version}`)
|
||||||
|
|
||||||
@@ -41,12 +45,10 @@ await Bun.file(`./dist/${pkg.name}/package.json`).write(
|
|||||||
2,
|
2,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
if (!dry) {
|
for (const [name] of Object.entries(binaries)) {
|
||||||
for (const [name] of Object.entries(binaries)) {
|
await $`cd dist/${name} && chmod 777 -R . && bun publish --access public --tag ${tag}`
|
||||||
await $`cd dist/${name} && chmod 777 -R . && bun publish --access public --tag ${npmTag}`
|
|
||||||
}
|
|
||||||
await $`cd ./dist/${pkg.name} && bun publish --access public --tag ${npmTag}`
|
|
||||||
}
|
}
|
||||||
|
await $`cd ./dist/${pkg.name} && bun publish --access public --tag ${tag}`
|
||||||
|
|
||||||
if (!snapshot) {
|
if (!snapshot) {
|
||||||
for (const key of Object.keys(binaries)) {
|
for (const key of Object.keys(binaries)) {
|
||||||
@@ -142,7 +144,7 @@ if (!snapshot) {
|
|||||||
await $`cd ./dist/aur-${pkg} && makepkg --printsrcinfo > .SRCINFO`
|
await $`cd ./dist/aur-${pkg} && makepkg --printsrcinfo > .SRCINFO`
|
||||||
await $`cd ./dist/aur-${pkg} && git add PKGBUILD .SRCINFO`
|
await $`cd ./dist/aur-${pkg} && git add PKGBUILD .SRCINFO`
|
||||||
await $`cd ./dist/aur-${pkg} && git commit -m "Update to v${version}"`
|
await $`cd ./dist/aur-${pkg} && git commit -m "Update to v${version}"`
|
||||||
if (!dry) await $`cd ./dist/aur-${pkg} && git push`
|
await $`cd ./dist/aur-${pkg} && git push`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Homebrew formula
|
// Homebrew formula
|
||||||
@@ -201,5 +203,5 @@ if (!snapshot) {
|
|||||||
await Bun.file("./dist/homebrew-tap/opencode.rb").write(homebrewFormula)
|
await Bun.file("./dist/homebrew-tap/opencode.rb").write(homebrewFormula)
|
||||||
await $`cd ./dist/homebrew-tap && git add opencode.rb`
|
await $`cd ./dist/homebrew-tap && git add opencode.rb`
|
||||||
await $`cd ./dist/homebrew-tap && git commit -m "Update to v${version}"`
|
await $`cd ./dist/homebrew-tap && git commit -m "Update to v${version}"`
|
||||||
if (!dry) await $`cd ./dist/homebrew-tap && git push`
|
await $`cd ./dist/homebrew-tap && git push`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user