Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54f8aef6a2 | ||
|
|
bb4551a739 | ||
|
|
c2a588fd02 | ||
|
|
249cf8c03b |
@@ -0,0 +1,264 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
bump:
|
||||||
|
description: "Semantic version bump to apply before release"
|
||||||
|
required: true
|
||||||
|
default: patch
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- patch
|
||||||
|
- minor
|
||||||
|
- major
|
||||||
|
release_name:
|
||||||
|
description: "Display name for the GitHub release"
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
draft:
|
||||||
|
description: "Create release as draft"
|
||||||
|
required: true
|
||||||
|
default: true
|
||||||
|
type: boolean
|
||||||
|
prerelease:
|
||||||
|
description: "Mark release as pre-release"
|
||||||
|
required: true
|
||||||
|
default: true
|
||||||
|
type: boolean
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: release-${{ github.ref_name }}
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
prepare-release:
|
||||||
|
name: Bump versions, commit, and tag
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
tag: ${{ steps.bump-version.outputs.tag }}
|
||||||
|
version: ${{ steps.bump-version.outputs.version }}
|
||||||
|
steps:
|
||||||
|
- name: Ensure workflow runs from a branch
|
||||||
|
run: |
|
||||||
|
if [ "${GITHUB_REF_TYPE}" != "branch" ]; then
|
||||||
|
echo "workflow_dispatch must be run from a branch ref, got: ${GITHUB_REF_TYPE}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
ref: ${{ github.ref_name }}
|
||||||
|
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version-file: package.json
|
||||||
|
|
||||||
|
- name: Bump app versions and infer release tag
|
||||||
|
id: bump-version
|
||||||
|
run: |
|
||||||
|
node --input-type=module <<'EOF'
|
||||||
|
import fs from "node:fs";
|
||||||
|
|
||||||
|
const bump = process.env.RELEASE_BUMP;
|
||||||
|
const files = [
|
||||||
|
"apps/server/package.json",
|
||||||
|
"apps/desktop/package.json",
|
||||||
|
"apps/web/package.json",
|
||||||
|
];
|
||||||
|
const sourceVersionFile = "apps/server/package.json";
|
||||||
|
|
||||||
|
const semverRegex = /^(\d+)\.(\d+)\.(\d+)$/;
|
||||||
|
const versions = files.map((file) => {
|
||||||
|
const json = JSON.parse(fs.readFileSync(file, "utf8"));
|
||||||
|
return { file, version: json.version };
|
||||||
|
});
|
||||||
|
|
||||||
|
const source = versions.find((entry) => entry.file === sourceVersionFile);
|
||||||
|
if (!source) {
|
||||||
|
throw new Error(`Could not find source version file '${sourceVersionFile}'.`);
|
||||||
|
}
|
||||||
|
const outOfSync = versions.filter((entry) => entry.version !== source.version);
|
||||||
|
if (outOfSync.length > 0) {
|
||||||
|
const details = outOfSync.map((entry) => `${entry.file}=${entry.version}`).join(", ");
|
||||||
|
console.warn(
|
||||||
|
`Detected out-of-sync app versions. Using ${sourceVersionFile}=${source.version} as source of truth. Others: ${details}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentVersion = source.version;
|
||||||
|
const match = semverRegex.exec(currentVersion);
|
||||||
|
if (!match) {
|
||||||
|
throw new Error(
|
||||||
|
`Version '${currentVersion}' is not a supported plain semver (x.y.z).`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let major = Number.parseInt(match[1], 10);
|
||||||
|
let minor = Number.parseInt(match[2], 10);
|
||||||
|
let patch = Number.parseInt(match[3], 10);
|
||||||
|
|
||||||
|
if (bump === "patch") {
|
||||||
|
patch += 1;
|
||||||
|
} else if (bump === "minor") {
|
||||||
|
minor += 1;
|
||||||
|
patch = 0;
|
||||||
|
} else if (bump === "major") {
|
||||||
|
major += 1;
|
||||||
|
minor = 0;
|
||||||
|
patch = 0;
|
||||||
|
} else {
|
||||||
|
throw new Error(`Unsupported bump type '${bump}'.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const version = `${major}.${minor}.${patch}`;
|
||||||
|
const tag = `v${version}`;
|
||||||
|
|
||||||
|
for (const file of files) {
|
||||||
|
const json = JSON.parse(fs.readFileSync(file, "utf8"));
|
||||||
|
json.version = version;
|
||||||
|
fs.writeFileSync(file, `${JSON.stringify(json, null, 2)}\n`, "utf8");
|
||||||
|
}
|
||||||
|
|
||||||
|
const outputPath = process.env.GITHUB_OUTPUT;
|
||||||
|
fs.appendFileSync(outputPath, `version=${version}\n`);
|
||||||
|
fs.appendFileSync(outputPath, `tag=${tag}\n`);
|
||||||
|
|
||||||
|
console.log(`Bumped version ${currentVersion} -> ${version}`);
|
||||||
|
console.log(`Inferred release tag: ${tag}`);
|
||||||
|
EOF
|
||||||
|
env:
|
||||||
|
RELEASE_BUMP: ${{ inputs.bump }}
|
||||||
|
|
||||||
|
- name: Validate inferred tag does not already exist
|
||||||
|
run: |
|
||||||
|
tag="${{ steps.bump-version.outputs.tag }}"
|
||||||
|
if git rev-parse --verify --quiet "refs/tags/${tag}"; then
|
||||||
|
echo "Tag ${tag} already exists locally."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if git ls-remote --tags origin "${tag}" | grep -q .; then
|
||||||
|
echo "Tag ${tag} already exists on origin."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Commit version bump
|
||||||
|
run: |
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
git add apps/server/package.json apps/desktop/package.json apps/web/package.json
|
||||||
|
if git diff --cached --quiet; then
|
||||||
|
echo "No version change detected; refusing to create empty release commit."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
git commit -m "chore(release): bump app versions to ${{ steps.bump-version.outputs.version }}
|
||||||
|
|
||||||
|
Co-authored-by: codex <[email protected]>"
|
||||||
|
|
||||||
|
- name: Create and push release tag
|
||||||
|
run: |
|
||||||
|
git tag -a "${{ steps.bump-version.outputs.tag }}" -m "Release ${{ steps.bump-version.outputs.tag }}"
|
||||||
|
git push origin "${{ github.ref_name }}"
|
||||||
|
git push origin "refs/tags/${{ steps.bump-version.outputs.tag }}"
|
||||||
|
|
||||||
|
build-macos:
|
||||||
|
name: Build and package macOS (${{ matrix.arch }})
|
||||||
|
runs-on: macos-14
|
||||||
|
needs: prepare-release
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
arch:
|
||||||
|
- arm64
|
||||||
|
- x64
|
||||||
|
env:
|
||||||
|
CI: "true"
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ needs.prepare-release.outputs.tag }}
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup Bun
|
||||||
|
uses: oven-sh/setup-bun@v2
|
||||||
|
with:
|
||||||
|
bun-version-file: package.json
|
||||||
|
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version-file: package.json
|
||||||
|
|
||||||
|
- name: Cache Bun and Turbo
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.bun/install/cache
|
||||||
|
.turbo
|
||||||
|
key: ${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}-${{ hashFiles('turbo.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}-
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: bun install --frozen-lockfile
|
||||||
|
|
||||||
|
- name: Build and package macOS artifact
|
||||||
|
run: |
|
||||||
|
bun run dist:desktop:dmg -- --arch "${{ matrix.arch }}" --version "${{ needs.prepare-release.outputs.version }}"
|
||||||
|
ls -lah release
|
||||||
|
# TODO: Add production macOS signing and notarization in CI:
|
||||||
|
# - Import Developer ID Application certificate + private key into keychain.
|
||||||
|
# - Provide APPLE_ID / APPLE_TEAM_ID / APPLE_APP_SPECIFIC_PASSWORD secrets.
|
||||||
|
# - Build with signing enabled and notarize + staple before release upload.
|
||||||
|
|
||||||
|
- name: Generate SHA256 checksums
|
||||||
|
run: |
|
||||||
|
checksum_file="release/SHA256SUMS-${{ matrix.arch }}.txt"
|
||||||
|
find release -maxdepth 1 -type f ! -name "SHA256SUMS-*.txt" -print0 \
|
||||||
|
| xargs -0 shasum -a 256 > "$checksum_file"
|
||||||
|
cat "$checksum_file"
|
||||||
|
|
||||||
|
- name: Upload packaged artifacts to workflow run
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: release-assets-${{ needs.prepare-release.outputs.tag }}-${{ matrix.arch }}
|
||||||
|
path: release/*
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
publish-release:
|
||||||
|
name: Create GitHub release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- prepare-release
|
||||||
|
- build-macos
|
||||||
|
steps:
|
||||||
|
- name: Download packaged artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
pattern: release-assets-${{ needs.prepare-release.outputs.tag }}-*
|
||||||
|
merge-multiple: true
|
||||||
|
path: release-assets
|
||||||
|
|
||||||
|
- name: Create GitHub release and upload assets
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
tag_name: ${{ needs.prepare-release.outputs.tag }}
|
||||||
|
target_commitish: ${{ needs.prepare-release.outputs.tag }}
|
||||||
|
name: ${{ inputs.release_name != '' && inputs.release_name || needs.prepare-release.outputs.tag }}
|
||||||
|
draft: ${{ inputs.draft }}
|
||||||
|
prerelease: ${{ inputs.prerelease }}
|
||||||
|
generate_release_notes: true
|
||||||
|
files: release-assets/*
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
# TODO: Add a multi-platform release matrix and publish Linux/Windows installers:
|
||||||
|
# - Linux: build/sign AppImage/deb/rpm artifacts on ubuntu runners.
|
||||||
|
# - Windows: build/sign MSI/NSIS artifacts on windows runners.
|
||||||
|
# - Consider per-platform updater metadata/signature publishing strategy.
|
||||||
Reference in new issue
Block a user