mirror of
https://github.com/JoshiCodes/knock.git
synced 2026-12-04 15:19:41 +01:00
GitHub workflow for macOS, Windows and native Linux builds; PKGBUILDs embed the frontend
- macOS: universal .app/.dmg and a universal CLI binary - Windows (best effort): .msi, setup .exe and the CLI - Linux on Ubuntu 22.04 amd64: deb, rpm, AppImage with a smoke test - Tags attach everything to the GitHub release - custom-protocol feature, so a plain cargo release build embeds the frontend instead of pointing at the dev server
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
name: release
|
||||
|
||||
# Runs on the GitHub mirror only (Gitea uses .gitea/workflows). macOS and
|
||||
# Windows minutes are expensive on private repositories, so this runs for
|
||||
# tags and on demand, not on every push.
|
||||
on:
|
||||
push:
|
||||
tags: ['v*']
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
macos:
|
||||
runs-on: macos-14
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
- name: Rust for both Mac architectures
|
||||
run: rustup target add aarch64-apple-darwin x86_64-apple-darwin
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: npm ci
|
||||
- name: Test
|
||||
run: cargo test -p knock-core --locked
|
||||
- name: App (universal .app and .dmg)
|
||||
run: npx tauri build --target universal-apple-darwin --bundles app,dmg
|
||||
- name: CLI (universal binary)
|
||||
run: |
|
||||
cargo build --release --locked -p knock-cli --target aarch64-apple-darwin
|
||||
cargo build --release --locked -p knock-cli --target x86_64-apple-darwin
|
||||
mkdir -p dist-cli
|
||||
lipo -create -output dist-cli/knock \
|
||||
target/aarch64-apple-darwin/release/knock target/x86_64-apple-darwin/release/knock
|
||||
tar -czf knock-cli-macos-universal.tar.gz -C dist-cli knock
|
||||
- name: Check
|
||||
run: |
|
||||
lipo -archs dist-cli/knock | grep -q arm64
|
||||
lipo -archs dist-cli/knock | grep -q x86_64
|
||||
ls target/universal-apple-darwin/release/bundle/dmg/*.dmg
|
||||
./dist-cli/knock --version
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: macos
|
||||
path: |
|
||||
target/universal-apple-darwin/release/bundle/dmg/*.dmg
|
||||
knock-cli-macos-universal.tar.gz
|
||||
|
||||
# Best effort per the spec.
|
||||
windows:
|
||||
runs-on: windows-latest
|
||||
continue-on-error: true
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: npm ci
|
||||
- name: App (.msi and setup .exe)
|
||||
run: npx tauri build --bundles msi,nsis
|
||||
- name: CLI
|
||||
shell: pwsh
|
||||
run: |
|
||||
cargo build --release --locked -p knock-cli
|
||||
Compress-Archive -Path target/release/knock.exe -DestinationPath knock-cli-windows-x64.zip
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows
|
||||
path: |
|
||||
target/release/bundle/msi/*.msi
|
||||
target/release/bundle/nsis/*.exe
|
||||
knock-cli-windows-x64.zip
|
||||
|
||||
# Native amd64 Linux build on Ubuntu 22.04, with the AppImage the arm64
|
||||
# Gitea runner cannot make, and a real smoke test.
|
||||
linux:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: System libraries
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev libdbus-1-dev xvfb
|
||||
- run: npm ci
|
||||
- name: Build
|
||||
run: |
|
||||
cargo build --release --locked -p knock-cli
|
||||
npx tauri build --bundles deb,rpm,appimage
|
||||
- name: Smoke test on Ubuntu 22.04
|
||||
run: |
|
||||
sudo apt-get install -y ./target/release/bundle/deb/*.deb
|
||||
python3 -m http.server 18765 >/dev/null 2>&1 &
|
||||
sleep 1
|
||||
mkdir -p /tmp/c/environments
|
||||
printf 'version: 1\nname: Smoke\n' > /tmp/c/knock.yaml
|
||||
printf 'name: Root\nurl: http://127.0.0.1:18765/\nassert:\n - { on: status, equals: 200 }\n' > /tmp/c/root.yaml
|
||||
knock run /tmp/c
|
||||
timeout 10 xvfb-run -a knock-app || [ $? -eq 124 ]
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux
|
||||
path: |
|
||||
target/release/bundle/deb/*.deb
|
||||
target/release/bundle/rpm/*.rpm
|
||||
target/release/bundle/appimage/*.AppImage
|
||||
|
||||
release:
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
needs: [macos, linux, windows]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: artifacts
|
||||
- name: Attach to the GitHub release
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
TAG: ${{ github.ref_name }}
|
||||
run: |
|
||||
pre=""
|
||||
case "$TAG" in *-*) pre="--prerelease";; esac
|
||||
gh release view "$TAG" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1 \
|
||||
|| gh release create "$TAG" -R "$GITHUB_REPOSITORY" --title "$TAG" --notes "" $pre
|
||||
find artifacts -type f -exec gh release upload "$TAG" -R "$GITHUB_REPOSITORY" --clobber {} +
|
||||
@@ -32,7 +32,7 @@ build() {
|
||||
cd knock
|
||||
export RUSTUP_TOOLCHAIN=stable
|
||||
npm run build
|
||||
cargo build --frozen --release -p knock-app -p knock-cli
|
||||
cargo build --frozen --release -p knock-app -p knock-cli --features knock-app/custom-protocol
|
||||
}
|
||||
|
||||
package() {
|
||||
|
||||
@@ -26,7 +26,7 @@ build() {
|
||||
cd "$pkgname"
|
||||
export RUSTUP_TOOLCHAIN=stable
|
||||
npm run build
|
||||
cargo build --frozen --release -p knock-app -p knock-cli
|
||||
cargo build --frozen --release -p knock-app -p knock-cli --features knock-app/custom-protocol
|
||||
}
|
||||
|
||||
check() {
|
||||
|
||||
@@ -36,3 +36,7 @@ notify = "8"
|
||||
futures-util = "0.3"
|
||||
regex = "1"
|
||||
tokio-tungstenite = "0.30"
|
||||
|
||||
[features]
|
||||
# Embeds the built frontend; the Tauri CLI turns it on for release builds.
|
||||
custom-protocol = ["tauri/custom-protocol"]
|
||||
|
||||
Reference in New Issue
Block a user