-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
204 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
changelog: | ||
exclude: | ||
authors: | ||
- dependabot | ||
labels: | ||
- ignore-for-changelog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Draft Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "Version (must start with 'v')" | ||
required: true | ||
pull_request: {} | ||
|
||
env: | ||
SDK_VERSION: ${{ github.event.inputs.version || 'v0.2.0' }} | ||
SDK_TAG: sdk/${{ github.event.inputs.version || 'v0.2.0' }} | ||
SDK_BRANCH: release/sdk/${{ github.event.inputs.version || 'v0.2.0' }} | ||
|
||
jobs: | ||
draft: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # needed to get the previous release tag | ||
|
||
- run: corepack enable | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
cache: yarn | ||
|
||
- name: Check for existing ${{ env.SDK_TAG }} release | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
if gh release view "${{ env.SDK_TAG }}" --json "name,url"; then | ||
echo "Release ${SDK_TAG} already exists!" | ||
exit 1 | ||
fi | ||
- run: yarn install --immutable | ||
- run: yarn bump-sdk-version "${{ env.SDK_VERSION }}" | ||
|
||
- name: Detect previous version | ||
id: previous-release | ||
run: | | ||
tag=$(git describe --tags --abbrev=0 --match "sdk/v*") | ||
echo "tag=$tag" | tee -a $GITHUB_OUTPUT | ||
- name: Commit and push branch | ||
run: | | ||
git config user.name "Foxglove" | ||
git config user.email "[email protected]" | ||
git checkout -b "${{ env.SDK_BRANCH }}" | ||
git add . | ||
git commit -m "Release SDK version ${{ env.SDK_VERSION }}" | ||
git push -f origin "${{ env.SDK_BRANCH }}" | ||
- name: Create draft release | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
gh release create "${{ env.SDK_TAG }}" \ | ||
--title "${{ env.SDK_TAG }}" \ | ||
--target "${{ env.SDK_BRANCH }}" \ | ||
--generate-notes \ | ||
--notes-start-tag "${{ steps.previous-release.outputs.tag }}" \ | ||
--draft |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Post Release | ||
|
||
on: | ||
release: | ||
types: [released] | ||
|
||
env: | ||
SDK_TAG: ${{ github.event.release.tag_name }} | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ env.SDK_TAG }} | ||
fetch-depth: 0 | ||
|
||
- name: Git merge into main | ||
run: | | ||
git config user.name "Foxglove" | ||
git config user.email "[email protected]" | ||
git checkout -b main --track origin/main | ||
git merge --no-ff ${{ github.ref }} | ||
git push origin main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env tsx | ||
|
||
import { spawn } from "child_process"; | ||
import fs from "fs/promises"; | ||
import { glob } from "glob"; | ||
import path from "path"; | ||
|
||
const versionRegex = /^version\s*=\s*"[^"]*"/m; | ||
|
||
async function main() { | ||
const newVersion = process.argv[2]; | ||
if (newVersion?.startsWith("v") !== true) { | ||
console.log("Usage: bumpSdkVersion.ts <version>"); | ||
console.log("Version must start with 'v'"); | ||
process.exit(1); | ||
} | ||
|
||
// Remove the 'v' prefix for the actual version string | ||
const versionNumber = newVersion.slice(1); | ||
|
||
// Find all Cargo.toml files from workspace root | ||
const workspaceRoot = path.resolve(__dirname, ".."); | ||
const cargoFiles = await glob("**/Cargo.toml", { | ||
ignore: ["**/target/**", "**/node_modules/**"], | ||
cwd: workspaceRoot, | ||
absolute: true, | ||
}); | ||
|
||
let success = true; | ||
for (const cargoFile of cargoFiles) { | ||
console.log(`Checking ${cargoFile}...`); | ||
const content = await fs.readFile(cargoFile, "utf8"); | ||
|
||
if (!versionRegex.test(content)) { | ||
console.log(` ℹ️ Skipped, does not contain version field`); | ||
continue; | ||
} | ||
|
||
// Only update the main version field, not dependencies | ||
const updatedContent = content.replace(versionRegex, `version = "${versionNumber}"`); | ||
|
||
if (content === updatedContent) { | ||
const oldVersion = versionRegex.exec(content)?.[0] ?? '""'; | ||
console.error(` ❌ Version could not be updated from ${oldVersion} to "${versionNumber}"`); | ||
success = false; | ||
} else { | ||
await fs.writeFile(cargoFile, updatedContent); | ||
console.log(` ✅ Updated version in ${cargoFile} to ${versionNumber}`); | ||
} | ||
} | ||
|
||
if (!success) { | ||
console.error("\n❌ Some versions could not be updated"); | ||
process.exit(1); | ||
} | ||
|
||
// run cargo check | ||
console.log("\nRunning cargo check..."); | ||
const cargoCheck = spawn("cargo", ["check"], { | ||
cwd: workspaceRoot, | ||
stdio: "inherit", | ||
}); | ||
|
||
const exitCode = await new Promise<number>((resolve) => { | ||
cargoCheck.on("close", resolve); | ||
}); | ||
|
||
if (exitCode !== 0) { | ||
process.exit(exitCode); | ||
} | ||
} | ||
|
||
main().catch((err: unknown) => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters