From 52291ef1bb080b261f5dadbb6c4dec15b5011cbf Mon Sep 17 00:00:00 2001 From: Krishan <33421343+kfiven@users.noreply.github.com> Date: Tue, 10 Mar 2026 04:16:07 +0000 Subject: [PATCH] chore: add release script and action --- .github/workflows/release.yml | 34 +++++++++++++++++ scripts/update-version.js | 71 +++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 scripts/update-version.js diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2398c04 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: Trigger elease + +on: + workflow_dispatch: + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 + submodules: true + + - name: Setup Node + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 + with: + node-version-file: ".node-version" + package-manager-cache: false + + - name: Install dependencies + run: npm ci + + - name: Setup Git identity + run: | + git config user.name "github-actions" + git config user.email "github-actions@github.com" + + - name: Run semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: npm run semantic-release \ No newline at end of file diff --git a/scripts/update-version.js b/scripts/update-version.js new file mode 100644 index 0000000..db80e8d --- /dev/null +++ b/scripts/update-version.js @@ -0,0 +1,71 @@ +import fs from "fs"; +import path from "path"; +import { execSync } from "child_process"; + +const version = process.argv[2]; + +if (!version) { + console.error("Missing version"); + process.exit(1); +} + +console.log(`Preparing release ${version}`); + +// 1. Update npm versions +execSync(`npm version ${version} --no-git-tag-version`, { + stdio: "inherit" +}); + +// 2. Update Cargo.toml +const cargoToml = "src-tauri/Cargo.toml"; +let cargoContent = fs.readFileSync(cargoToml, "utf8"); + +cargoContent = cargoContent.replace( + /^version\s*=\s*".*"/m, + `version = "${version}"` +); + +fs.writeFileSync(cargoToml, cargoContent); + +// 3. Update Cargo.lock +const cargoLock = "src-tauri/Cargo.lock"; +let lockContent = fs.readFileSync(cargoLock, "utf8"); + +lockContent = lockContent.replace( + /^version\s*=\s*".*"/m, + `version = "${version}"` +); + +fs.writeFileSync(cargoLock, lockContent); + +// 4. Update tauri.conf.json +const tauriConfigPath = "src-tauri/tauri.conf.json"; +const tauriConfig = JSON.parse(fs.readFileSync(tauriConfigPath)); + +tauriConfig.package.version = version; + +fs.writeFileSync( + tauriConfigPath, + JSON.stringify(tauriConfig, null, 2) + "\n" +); + +// 5. Update Cinny web submodule to latest tag +console.log("Updating cinny web submodule"); + +execSync("git submodule update --init --recursive", { stdio: "inherit" }); + +execSync("cd cinny && git fetch --tags", { stdio: "inherit" }); + +const latestTag = execSync( + "cd cinny && git describe --tags $(git rev-list --tags --max-count=1)" +) + .toString() + .trim(); + +console.log(`Latest cinny tag: ${latestTag}`); + +execSync(`cd cinny && git checkout ${latestTag}`, { stdio: "inherit" }); + +execSync("git add cinny", { stdio: "inherit" }); + +console.log("Release preparation complete"); \ No newline at end of file