mirror of
https://github.com/SableClient/Sable.git
synced 2026-12-04 07:42:24 -08:00
ci(tauri): add nightly auto updating
This commit is contained in:
1 parent
0742666c75
commit
2b2d0d1681
6 files changed
+130
-52
No files matched your search
@@ -1,6 +1,6 @@
|
||||
// Composes the Tauri updater manifest (latest.json) from the per-platform .sig
|
||||
// assets already attached to the release.
|
||||
// Required env: TAG, REPO, GH_TOKEN.
|
||||
// Required env: TAG, VERSION, REPO, GH_TOKEN.
|
||||
|
||||
import { execSync } from 'node:child_process';
|
||||
import { readFileSync, readdirSync, writeFileSync, mkdtempSync } from 'node:fs';
|
||||
@@ -8,12 +8,17 @@ import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
|
||||
const TAG = process.env.TAG;
|
||||
const VERSION = process.env.VERSION;
|
||||
const REPO = process.env.REPO;
|
||||
if (!TAG || !REPO) {
|
||||
console.error('TAG and REPO env vars are required');
|
||||
if (!TAG || !VERSION || !REPO) {
|
||||
console.error('TAG, VERSION, and REPO env vars are required');
|
||||
process.exit(1);
|
||||
}
|
||||
const version = TAG.replace(/^v/, '');
|
||||
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(VERSION)) {
|
||||
console.error(`VERSION must be valid SemVer (got: ${VERSION})`);
|
||||
process.exit(1);
|
||||
}
|
||||
const version = VERSION;
|
||||
|
||||
const dir = mkdtempSync(join(tmpdir(), 'sable-sigs-'));
|
||||
execSync(`gh release download "${TAG}" --repo "${REPO}" --pattern '*.sig' --dir "${dir}"`, {
|
||||
@@ -50,13 +55,15 @@ if (Object.keys(platforms).length === 0) {
|
||||
}
|
||||
|
||||
let notes = `Sable ${version}`;
|
||||
try {
|
||||
notes =
|
||||
execSync(`gh release view "${TAG}" --repo "${REPO}" --json body -q .body`, {
|
||||
encoding: 'utf8',
|
||||
}).trim() || notes;
|
||||
} catch {
|
||||
// keep the default note
|
||||
if (TAG !== 'nightly') {
|
||||
try {
|
||||
notes =
|
||||
execSync(`gh release view "${TAG}" --repo "${REPO}" --json body -q .body`, {
|
||||
encoding: 'utf8',
|
||||
}).trim() || notes;
|
||||
} catch {
|
||||
// keep the default note
|
||||
}
|
||||
}
|
||||
|
||||
const manifest = { version, notes, pub_date: new Date().toISOString(), platforms };
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env node
|
||||
/* oxlint-disable no-console */
|
||||
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
const runNumber = process.argv[2];
|
||||
const runAttempt = process.argv[3];
|
||||
const packageJson = JSON.parse(readFileSync('package.json', 'utf8'));
|
||||
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(packageJson.version);
|
||||
|
||||
if (!match) {
|
||||
console.error(`package.json version must be stable SemVer (got: ${packageJson.version})`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!/^\d+$/.test(runNumber ?? '') || !/^\d+$/.test(runAttempt ?? '')) {
|
||||
console.error('Usage: nightly-version.mjs <run-number> <run-attempt>');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const [, major, minor, patch] = match;
|
||||
console.log(`${major}.${minor}.${Number(patch) + 1}-nightly.${runNumber}.${runAttempt}`);
|
||||
@@ -1,20 +1,32 @@
|
||||
#!/usr/bin/env node
|
||||
/* oxlint-disable no-console */
|
||||
|
||||
// Stamps a version into src-tauri/tauri.conf.json, which can drift from the
|
||||
// package.json version Knope tags on. Used by tauri-build.yml.
|
||||
// Stamps release-specific settings into src-tauri/tauri.conf.json, which can
|
||||
// drift from the package.json version Knope tags on. Used by tauri-build.yml.
|
||||
|
||||
import { readFileSync, writeFileSync } from 'node:fs';
|
||||
import process from 'node:process';
|
||||
|
||||
const version = process.argv[2];
|
||||
const updaterEndpoint = process.argv[3];
|
||||
if (!version || !/^\d+\.\d+\.\d+/.test(version)) {
|
||||
console.error(`Usage: set-tauri-version.mjs <version> (got: ${version ?? '<none>'})`);
|
||||
console.error(
|
||||
`Usage: set-tauri-version.mjs <version> [updater-endpoint] (got: ${version ?? '<none>'})`
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (updaterEndpoint && !/^https:\/\//.test(updaterEndpoint)) {
|
||||
console.error(`Updater endpoint must use HTTPS (got: ${updaterEndpoint})`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const file = 'src-tauri/tauri.conf.json';
|
||||
const config = JSON.parse(readFileSync(file, 'utf8'));
|
||||
config.version = version;
|
||||
if (updaterEndpoint) {
|
||||
config.plugins.updater.endpoints = [updaterEndpoint];
|
||||
}
|
||||
writeFileSync(file, `${JSON.stringify(config, null, 2)}\n`);
|
||||
console.log(`Set ${file} version to ${version}`);
|
||||
if (updaterEndpoint) console.log(`Set ${file} updater endpoint to ${updaterEndpoint}`);
|
||||
@@ -30,6 +30,7 @@ jobs:
|
||||
version: ${{ steps.meta.outputs.version }}
|
||||
ref: ${{ steps.meta.outputs.ref }}
|
||||
nightly: ${{ steps.meta.outputs.nightly }}
|
||||
started_at: ${{ steps.meta.outputs.started_at }}
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
steps:
|
||||
@@ -47,13 +48,16 @@ jobs:
|
||||
GIT_REF: ${{ github.ref }}
|
||||
GIT_REF_NAME: ${{ github.ref_name }}
|
||||
GIT_SHA: ${{ github.sha }}
|
||||
RUN_NUMBER: ${{ github.run_number }}
|
||||
RUN_ATTEMPT: ${{ github.run_attempt }}
|
||||
run: |
|
||||
STARTED_AT="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
|
||||
TAG="$INPUT_TAG"; REF="$INPUT_TAG"; NIGHTLY=false
|
||||
VERSION="${TAG#v}"
|
||||
elif [ "$GIT_REF" = "refs/heads/dev" ]; then
|
||||
TAG="nightly"; REF="$GIT_SHA"; NIGHTLY=true
|
||||
VERSION="$(node -p "require('./package.json').version")"
|
||||
VERSION="$(node .github/scripts/nightly-version.mjs "$RUN_NUMBER" "$RUN_ATTEMPT")"
|
||||
else
|
||||
TAG="$GIT_REF_NAME"; REF="$GIT_REF"; NIGHTLY=false
|
||||
VERSION="${TAG#v}"
|
||||
@@ -63,6 +67,7 @@ jobs:
|
||||
echo "version=$VERSION"
|
||||
echo "ref=$REF"
|
||||
echo "nightly=$NIGHTLY"
|
||||
echo "started_at=$STARTED_AT"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Wait for release to exist
|
||||
@@ -82,18 +87,21 @@ jobs:
|
||||
echo "Release $TAG was not found." >&2
|
||||
exit 1
|
||||
|
||||
- name: Refresh nightly prerelease
|
||||
- name: Ensure nightly prerelease exists
|
||||
if: ${{ steps.meta.outputs.nightly == 'true' }}
|
||||
shell: bash
|
||||
env:
|
||||
GIT_SHA: ${{ github.sha }}
|
||||
run: |
|
||||
gh release delete nightly --yes --cleanup-tag || true
|
||||
gh release create nightly \
|
||||
--prerelease \
|
||||
--target "$GIT_SHA" \
|
||||
--title "Nightly (dev)" \
|
||||
--notes "Rolling nightly build from dev — $GIT_SHA"
|
||||
if gh release view nightly >/dev/null 2>&1; then
|
||||
echo "Reusing the existing nightly release while the new build is prepared."
|
||||
else
|
||||
gh release create nightly \
|
||||
--prerelease \
|
||||
--target "$GIT_SHA" \
|
||||
--title "Nightly (dev)" \
|
||||
--notes "Rolling nightly build from dev — $GIT_SHA"
|
||||
fi
|
||||
|
||||
build:
|
||||
name: Build ${{ matrix.name }}
|
||||
@@ -170,7 +178,9 @@ jobs:
|
||||
|
||||
- name: Stamp release version into tauri.conf.json
|
||||
shell: bash
|
||||
run: node .github/scripts/set-tauri-version.mjs "$VERSION"
|
||||
env:
|
||||
UPDATER_ENDPOINT: ${{ needs.setup-release.outputs.nightly == 'true' && format('https://github.com/{0}/releases/download/nightly/latest.json', github.repository) || '' }}
|
||||
run: node .github/scripts/set-tauri-version.mjs "$VERSION" "$UPDATER_ENDPOINT"
|
||||
|
||||
# --- macOS / Windows: standard wry build via tauri-action ---
|
||||
- name: Configure updater artifacts
|
||||
@@ -357,8 +367,7 @@ jobs:
|
||||
|
||||
updater-manifest:
|
||||
name: Publish updater manifest
|
||||
needs: [setup-release, build]
|
||||
if: ${{ needs.setup-release.outputs.nightly != 'true' }}
|
||||
needs: [setup-release, build, android]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
permissions:
|
||||
@@ -368,7 +377,9 @@ jobs:
|
||||
artifact-metadata: write
|
||||
env:
|
||||
TAG: ${{ needs.setup-release.outputs.tag }}
|
||||
VERSION: ${{ needs.setup-release.outputs.version }}
|
||||
REPO: ${{ github.repository }}
|
||||
STARTED_AT: ${{ needs.setup-release.outputs.started_at }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
@@ -382,6 +393,16 @@ jobs:
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
if [ "${{ needs.setup-release.outputs.nightly }}" = "true" ]; then
|
||||
gh release view "$TAG" --json assets \
|
||||
| jq -r --arg cutoff "$STARTED_AT" \
|
||||
'.assets[] | select(.updatedAt <= $cutoff and (.name | endswith(".sig"))) | .name' \
|
||||
| while read -r name; do
|
||||
[ -n "$name" ] || continue
|
||||
echo "Removing superseded nightly signature: $name"
|
||||
gh release delete-asset "$TAG" "$name" --yes
|
||||
done
|
||||
fi
|
||||
node .github/scripts/build-updater-manifest.mjs
|
||||
if [ -f latest.json ]; then
|
||||
echo "produced=true" >> "$GITHUB_OUTPUT"
|
||||
@@ -402,3 +423,27 @@ jobs:
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: gh release upload "$TAG" latest.json --clobber
|
||||
|
||||
- name: Finalize nightly release
|
||||
if: ${{ needs.setup-release.outputs.nightly == 'true' && steps.manifest.outputs.produced == 'true' }}
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GIT_SHA: ${{ needs.setup-release.outputs.ref }}
|
||||
run: |
|
||||
gh api --method PATCH "repos/$REPO/git/refs/tags/nightly" \
|
||||
-f sha="$GIT_SHA" -F force=true
|
||||
gh release edit nightly \
|
||||
--prerelease \
|
||||
--target "$GIT_SHA" \
|
||||
--title "Nightly (dev)" \
|
||||
--notes "Rolling nightly build $VERSION from dev — $GIT_SHA"
|
||||
|
||||
gh release view nightly --json assets \
|
||||
| jq -r --arg cutoff "$STARTED_AT" \
|
||||
'.assets[] | select(.updatedAt <= $cutoff) | .name' \
|
||||
| while read -r name; do
|
||||
[ -n "$name" ] || continue
|
||||
echo "Removing superseded nightly asset: $name"
|
||||
gh release delete-asset nightly "$name" --yes
|
||||
done
|
||||
@@ -9,31 +9,9 @@ Join our matrix space [here](https://matrix.to/#/#sable:sable.moe) to discuss fe
|
||||
Forked from [Cinny](https://github.com/cinnyapp/cinny/).
|
||||
|
||||
## Getting started
|
||||
The web app is available at [app.sable.moe](https://app.sable.moe/) and gets updated on frequently, as soon as a feature is deemed stable.
|
||||
The stable web app is available at [app.sable.moe](https://app.sable.moe/) and tracks the [latest GitHub release](https://github.com/SableClient/Sable/releases/latest). Nightly builds are available at [dev.sable.moe](https://dev.sable.moe/) and from the [`nightly` GitHub release](https://github.com/SableClient/Sable/releases/tag/nightly).
|
||||
|
||||
You can also download our desktop app for windows and linux from [releases](https://github.com/SableClient/Sable/releases/latest).
|
||||
|
||||
### Verify release provenance
|
||||
|
||||
Release binaries and updater metadata are attested by their GitHub Actions build workflow. After downloading an artifact, verify that it was built by this repository:
|
||||
|
||||
```sh
|
||||
gh attestation verify <downloaded-file> --repo SableClient/Sable
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```sh
|
||||
gh attestation verify Sable_1.20.0_amd64.AppImage --repo SableClient/Sable
|
||||
```
|
||||
|
||||
The container attestation is published alongside the image in GHCR:
|
||||
|
||||
```sh
|
||||
gh attestation verify oci://ghcr.io/sableclient/sable:latest --repo SableClient/Sable
|
||||
```
|
||||
|
||||
Artifact attestations establish which repository, workflow, commit, and runner produced a file. Tauri updater signatures and Android package signatures provide the platform-specific update and installation guarantees separately.
|
||||
You can also download our desktop app for Windows and Linux from [releases](https://github.com/SableClient/Sable/releases/latest). Release artifacts include build attestations, and desktop installations update automatically.
|
||||
|
||||
## Self-hosting
|
||||
You have a few options for self hosting, you can:
|
||||
|
||||
+17
-3
@@ -7,6 +7,18 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
VERSION="${1:-$(grep -m1 '^version' src-tauri/Cargo.toml | sed 's/.*"\(.*\)".*/\1/')}"
|
||||
DEB_VERSION="$VERSION"
|
||||
RPM_VERSION="$VERSION"
|
||||
RPM_ITERATION=1
|
||||
if [[ "$VERSION" == *-* ]]; then
|
||||
BASE_VERSION="${VERSION%%-*}"
|
||||
PRERELEASE="${VERSION#*-}"
|
||||
# Debian sorts ~ before the final version. RPM uses the release field so its
|
||||
# Version remains hyphen-free and a 0.* prerelease sorts before release 1.
|
||||
DEB_VERSION="${BASE_VERSION}~${PRERELEASE}"
|
||||
RPM_VERSION="$BASE_VERSION"
|
||||
RPM_ITERATION="0.${PRERELEASE}"
|
||||
fi
|
||||
STAGE="src-tauri/target/release"
|
||||
OUT="$STAGE/bundle"
|
||||
WORK="$STAGE/cef-pkg"
|
||||
@@ -54,7 +66,7 @@ EOF
|
||||
write_desktop "$PKGROOT/usr/share/applications/sable.desktop"
|
||||
cp src-tauri/icons/128x128.png "$PKGROOT/usr/share/icons/hicolor/128x128/apps/sable.png"
|
||||
|
||||
COMMON=(-s dir -n sable -v "$VERSION" --iteration 1
|
||||
COMMON=(-s dir -n sable
|
||||
--description "Sable, a Matrix client"
|
||||
--url "https://sable.moe" --maintainer "SableClient"
|
||||
--category net)
|
||||
@@ -62,12 +74,14 @@ EOF
|
||||
DEB_DEPS=(--depends libwebkit2gtk-4.1-0 --depends libgtk-3-0
|
||||
--depends libnss3 --depends libnspr4 --depends libgbm1
|
||||
--depends libdrm2 --depends libxkbcommon0 --depends xdg-utils)
|
||||
(cd "$OUT/deb" && fpm "${COMMON[@]}" -t deb -a amd64 "${DEB_DEPS[@]}" -C "$PKGROOT" .)
|
||||
(cd "$OUT/deb" && fpm "${COMMON[@]}" -v "$DEB_VERSION" --iteration 1 \
|
||||
-t deb -a amd64 "${DEB_DEPS[@]}" -C "$PKGROOT" .)
|
||||
|
||||
RPM_DEPS=(--depends webkit2gtk4.1 --depends gtk3 --depends nss
|
||||
--depends nspr --depends mesa-libgbm --depends libdrm
|
||||
--depends libxkbcommon --depends xdg-utils)
|
||||
(cd "$OUT/rpm" && fpm "${COMMON[@]}" -t rpm -a x86_64 "${RPM_DEPS[@]}" -C "$PKGROOT" .)
|
||||
(cd "$OUT/rpm" && fpm "${COMMON[@]}" -v "$RPM_VERSION" --iteration "$RPM_ITERATION" \
|
||||
-t rpm -a x86_64 "${RPM_DEPS[@]}" -C "$PKGROOT" .)
|
||||
else
|
||||
echo "fpm not found; skipping deb/rpm (building AppImage only)"
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user