ci: create release before builds so upload has a target

This commit is contained in:
Matt
2026-08-25 20:27:30 +00:00
parent 9f5faba7c2
commit 9a665f8865
20 changed files with 95 additions and 108 deletions
+95 -69
View File
@@ -9,19 +9,46 @@ permissions:
contents: write contents: write
jobs: jobs:
release: create-release:
runs-on: ubuntu-latest
outputs:
release-id: ${{ steps.create.outputs.id }}
steps:
- name: Create draft release
id: create
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${{ github.ref_name }}"
REPO="${{ github.repository }}"
gh release view "$TAG" --repo "$REPO" >/dev/null 2>&1 && \
echo "id=$(gh release view "$TAG" --repo "$REPO" --json id --jq '.id')" >> "$GITHUB_OUTPUT" && \
echo "Release already exists." && exit 0
gh release create "$TAG" \
--repo "$REPO" \
--title "Clustri $TAG" \
--notes "See the assets below to download and install." \
--draft --verify-tag --target main
echo "id=$(gh release view "$TAG" --repo "$REPO" --json id --jq '.id')" >> "$GITHUB_OUTPUT"
build:
needs: create-release
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- platform: ubuntu-22.04 - platform: ubuntu-22.04
args: "" runner: ubuntu-22.04
- platform: windows-latest target: ""
args: "" - platform: windows
- platform: macos-latest runner: windows-latest
args: "--target universal-apple-darwin" target: ""
- platform: macos
runner: macos-latest
target: "--target universal-apple-darwin"
runs-on: ${{ matrix.platform }} runs-on: ${{ matrix.runner }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@@ -38,7 +65,7 @@ jobs:
- name: Setup Rust - name: Setup Rust
uses: dtolnay/rust-toolchain@stable uses: dtolnay/rust-toolchain@stable
with: with:
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} targets: ${{ matrix.platform == 'macos' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
- name: Rust cache - name: Rust cache
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
@@ -51,41 +78,39 @@ jobs:
sudo apt-get update sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- name: Build and release - name: Build
uses: tauri-apps/tauri-action@v1 shell: bash
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
with: run: npx tauri build ${{ matrix.target }}
tagName: ${{ github.ref_name }}
releaseName: "Clustri ${{ github.ref_name }}"
releaseBody: "See the assets below to download and install."
releaseDraft: true
prerelease: false
updaterJsonPreferNsis: true
args: ${{ matrix.args }}
- name: Upload updater artifacts - name: Upload artifacts
shell: bash shell: bash
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
RELEASE_TAG="${{ github.ref_name }}" TAG="${{ github.ref_name }}"
REPO="${{ github.repository }}"
# Upload all .sig files from the entire target directory upload() {
find src-tauri/target -name "*.sig" -type f | while read sig_file; do local file="$1"
echo "Uploading $(basename "$sig_file")..." if [ -f "$file" ]; then
gh release upload "$RELEASE_TAG" "$sig_file" --clobber --repo ${{ github.repository }} 2>/dev/null || true echo "Uploading $(basename "$file")..."
done gh release upload "$TAG" "$file" --clobber --repo "$REPO" || true
fi
}
# Upload updater bundles (.app.tar.gz, .nsis.zip, .msi.zip) find src-tauri/target -path "*/bundle/*" \( \
find src-tauri/target \( -name "*.app.tar.gz" -o -name "*.nsis.zip" -o -name "*.msi.zip" \) -type f | while read bundle_file; do -name "*.deb" -o -name "*.rpm" -o -name "*.AppImage" -o \
echo "Uploading $(basename "$bundle_file")..." -name "*.dmg" -o -name "*.app.tar.gz" -o -name "*.msi" -o \
gh release upload "$RELEASE_TAG" "$bundle_file" --clobber --repo ${{ github.repository }} 2>/dev/null || true -name "*.exe" -o -name "*.nsis.zip" -o -name "*.msi.zip" -o \
-name "*.sig" \
\) -type f | while read f; do
upload "$f"
done done
update-latest-json: update-latest-json:
needs: release needs: build
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Generate and upload latest.json - name: Generate and upload latest.json
@@ -93,27 +118,31 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
python3 << 'PYEOF' python3 << 'PYEOF'
import json, subprocess, os, sys, tempfile import json, subprocess, os, tempfile
TAG = os.environ.get("GITHUB_REF_NAME", "") tag = os.environ["GITHUB_REF_NAME"]
REPO = os.environ.get("GITHUB_REPOSITORY", "") repo = os.environ["GITHUB_REPOSITORY"]
VERSION = TAG.lstrip("v") version = tag.lstrip("v")
BASE_URL = f"https://github.com/{REPO}/releases/download/{TAG}" base_url = f"https://github.com/{repo}/releases/download/{tag}"
def run(cmd): def run(cmd):
return subprocess.check_output(cmd, shell=True, text=True).strip() return subprocess.check_output(cmd, shell=True, text=True).strip()
data = json.loads(run(f'gh release view "{tag}" --repo "{repo}" --json assets'))
assets = {a["name"]: a for a in data["assets"]}
def find_asset(pattern): def find_asset(pattern):
data = json.loads(run(f'gh release view "{TAG}" --repo "{REPO}" --json assets')) for name in assets:
for a in data["assets"]: if pattern in name:
if pattern in a["name"]: return name
return a["name"]
return None return None
def download_asset(name): def download_sig(name):
if not name:
return ""
with tempfile.TemporaryDirectory() as d: with tempfile.TemporaryDirectory() as d:
subprocess.run( subprocess.run(
f'gh release download "{TAG}" --repo "{REPO}" -p "{name}" -D "{d}"', f'gh release download "{tag}" --repo "{repo}" -p "{name}" -D "{d}"',
shell=True, capture_output=True shell=True, capture_output=True
) )
path = os.path.join(d, name) path = os.path.join(d, name)
@@ -125,45 +154,42 @@ jobs:
platforms = {} platforms = {}
# Linux AppImage # Linux AppImage
appimage = find_asset(".AppImage") app = find_asset(".AppImage")
appimage_sig = find_asset(".AppImage.sig") sig = find_asset(".AppImage.sig")
if appimage and appimage_sig: if app and sig:
sig = download_asset(appimage_sig) s = download_sig(sig)
if sig: if s:
platforms["linux-x86_64"] = {"signature": sig, "url": f"{BASE_URL}/{appimage}"} platforms["linux-x86_64"] = {"signature": s, "url": f"{base_url}/{app}"}
# Windows NSIS # Windows NSIS
nsis = find_asset("-setup.exe") exe = find_asset("-setup.exe")
nsis_sig = find_asset("nsis.zip.sig") sig = find_asset("nsis.zip.sig")
if nsis and nsis_sig: if exe and sig:
sig = download_asset(nsis_sig) s = download_sig(sig)
if sig: if s:
platforms["windows-x86_64"] = {"signature": sig, "url": f"{BASE_URL}/{nsis}"} platforms["windows-x86_64"] = {"signature": s, "url": f"{base_url}/{exe}"}
# macOS universal # macOS universal
macos = find_asset("app.tar.gz") app = find_asset("app.tar.gz")
macos_sig = find_asset("app.tar.gz.sig") sig = find_asset("app.tar.gz.sig")
if macos and macos_sig: if app and sig:
sig = download_asset(macos_sig) s = download_sig(sig)
if sig: if s:
platforms["darwin-x86_64"] = {"signature": sig, "url": f"{BASE_URL}/{macos}"} platforms["darwin-x86_64"] = {"signature": s, "url": f"{base_url}/{app}"}
platforms["darwin-aarch64"] = {"signature": sig, "url": f"{BASE_URL}/{macos}"} platforms["darwin-aarch64"] = {"signature": s, "url": f"{base_url}/{app}"}
latest = { latest = {
"version": VERSION, "version": version,
"notes": "See the assets below to download and install.", "notes": "See the assets below to download and install.",
"pub_date": run("date -u +%Y-%m-%dT%H:%M:%SZ"), "pub_date": run("date -u +%Y-%m-%dT%H:%M:%SZ"),
"platforms": platforms, "platforms": platforms,
} }
with open("latest.json", "w") as f: with open("/tmp/latest.json", "w") as f:
json.dump(latest, f, indent=2) json.dump(latest, f, indent=2)
print(json.dumps(latest, indent=2)) print(json.dumps(latest, indent=2))
subprocess.run(
f'gh release upload "{TAG}" latest.json --clobber --repo "{REPO}"',
shell=True, check=True
)
print("latest.json uploaded successfully.")
PYEOF PYEOF
gh release upload "${{ github.ref_name }}" /tmp/latest.json --clobber --repo "${{ github.repository }}"
echo "latest.json uploaded."
-1
View File
@@ -1 +0,0 @@
{"rustc_fingerprint":9200552825474144316,"outputs":{"7752308220390268658":{"success":true,"status":"","code":0,"stdout":"rustc 1.97.1 (8bab26f4f 2026-07-14)\nbinary: rustc\ncommit-hash: 8bab26f4f68e0e26f0bb7960be334d5b520ea452\ncommit-date: 2026-07-14\nhost: x86_64-unknown-linux-gnu\nrelease: 1.97.1\nLLVM version: 22.1.6\n","stderr":""},"7971740275564407648":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_primitive_alignment=\"16\"\ntarget_has_atomic_primitive_alignment=\"32\"\ntarget_has_atomic_primitive_alignment=\"64\"\ntarget_has_atomic_primitive_alignment=\"8\"\ntarget_has_atomic_primitive_alignment=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""}},"successes":{}}
-3
View File
@@ -1,3 +0,0 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by cargo.
# For information about cache directory tags see https://bford.info/cachedir/
View File
@@ -1 +0,0 @@
This file has an mtime of when this was started.
@@ -1 +0,0 @@
This file has an mtime of when this was started.
@@ -1 +0,0 @@
This file has an mtime of when this was started.
@@ -1 +0,0 @@
This file has an mtime of when this was started.
@@ -1 +0,0 @@
This file has an mtime of when this was started.
@@ -1 +0,0 @@
4609aa34aaf3f167
@@ -1 +0,0 @@
{"rustc":12019306335353385202,"features":"[]","declared_features":"[]","target":14045917370260632744,"profile":2225463790103693989,"path":11797909581934051219,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/unicode-ident-8443eb632a3fbe4c/dep-lib-unicode_ident","checksum":false}}],"rustflags":[],"config":9396254390672932401,"compile_kind":0}
@@ -1,5 +0,0 @@
/home/user/projects/dev/clustri/src-tauri/target/debug/build/libc-19124a20af635abc/build_script_build-19124a20af635abc.d: /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.189/build.rs
/home/user/projects/dev/clustri/src-tauri/target/debug/build/libc-19124a20af635abc/build_script_build-19124a20af635abc: /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.189/build.rs
/home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.189/build.rs:
@@ -1,5 +0,0 @@
/home/user/projects/dev/clustri/src-tauri/target/debug/build/proc-macro2-28cd7e73fe64eada/build_script_build-28cd7e73fe64eada.d: /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/proc-macro2-1.0.107/build.rs
/home/user/projects/dev/clustri/src-tauri/target/debug/build/proc-macro2-28cd7e73fe64eada/build_script_build-28cd7e73fe64eada: /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/proc-macro2-1.0.107/build.rs
/home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/proc-macro2-1.0.107/build.rs:
@@ -1,5 +0,0 @@
/home/user/projects/dev/clustri/src-tauri/target/debug/build/quote-6dff9724e4e81362/build_script_build-6dff9724e4e81362.d: /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/quote-1.0.47/build.rs
/home/user/projects/dev/clustri/src-tauri/target/debug/build/quote-6dff9724e4e81362/build_script_build-6dff9724e4e81362: /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/quote-1.0.47/build.rs
/home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/quote-1.0.47/build.rs:
@@ -1,5 +0,0 @@
/home/user/projects/dev/clustri/src-tauri/target/debug/build/serde_core-e613c711ddfe8493/build_script_build-e613c711ddfe8493.d: /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/serde_core-1.0.229/build.rs
/home/user/projects/dev/clustri/src-tauri/target/debug/build/serde_core-e613c711ddfe8493/build_script_build-e613c711ddfe8493: /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/serde_core-1.0.229/build.rs
/home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/serde_core-1.0.229/build.rs:
@@ -1,8 +0,0 @@
/home/user/projects/dev/clustri/src-tauri/target/debug/deps/unicode_ident-8443eb632a3fbe4c.d: /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/unicode-ident-1.0.24/src/lib.rs /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/unicode-ident-1.0.24/src/tables.rs
/home/user/projects/dev/clustri/src-tauri/target/debug/deps/libunicode_ident-8443eb632a3fbe4c.rlib: /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/unicode-ident-1.0.24/src/lib.rs /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/unicode-ident-1.0.24/src/tables.rs
/home/user/projects/dev/clustri/src-tauri/target/debug/deps/libunicode_ident-8443eb632a3fbe4c.rmeta: /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/unicode-ident-1.0.24/src/lib.rs /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/unicode-ident-1.0.24/src/tables.rs
/home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/unicode-ident-1.0.24/src/lib.rs:
/home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/unicode-ident-1.0.24/src/tables.rs: