Files
knock/.github/workflows/release.yml
T
JoshiCodes 4b1590e750 Cookie jars per folder; pacman repository on Gitea; install guide per platform
- A folder can share its parent's cookie jar, keep its own, or use no
  cookies; sub folders follow. The Cookies tab shows the jar a request
  used. Jars are stored per collection and folder.
- The release workflow builds knock-bin from the deb and uploads it to
  the Gitea pacman repository (needs the GITEA_PACKAGES_TOKEN secret)
- knock-bin installs the desktop entry as knock-app.desktop
- README: install for Arch (signed pacman repo), Ubuntu/Debian,
  Fedora/openSUSE, AppImage, macOS (quarantine) and Windows (SmartScreen)
- release.sh works when the version is already set
2026-11-27 22:12:08 +01:00

190 lines
6.8 KiB
YAML

name: release
# Push a tag vX.Y.Z (scripts/release.sh does it) and this builds every
# platform and publishes a GitHub release. Manual runs build without
# releasing; pick platforms to save macOS and Windows minutes.
on:
push:
tags: ['v*']
workflow_dispatch:
inputs:
platforms:
description: 'Which builds to run: all, or a comma list of macos, windows, linux'
default: all
permissions:
contents: write
jobs:
macos:
if: github.event_name == 'push' || inputs.platforms == 'all' || contains(inputs.platforms, 'macos')
runs-on: macos-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
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@v5
with:
name: macos
path: |
target/universal-apple-darwin/release/bundle/dmg/*.dmg
knock-cli-macos-universal.tar.gz
# Best effort per the spec.
windows:
if: github.event_name == 'push' || inputs.platforms == 'all' || contains(inputs.platforms, 'windows')
runs-on: windows-latest
continue-on-error: true
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
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@v5
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:
if: github.event_name == 'push' || inputs.platforms == 'all' || contains(inputs.platforms, 'linux')
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
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@v5
with:
name: linux
path: |
target/release/bundle/deb/*.deb
target/release/bundle/rpm/*.rpm
target/release/bundle/appimage/*.AppImage
# Arch package for the pacman repository on Gitea, built from the deb.
# Needs the secret GITEA_PACKAGES_TOKEN (a Gitea token with package write
# access); without it the job is skipped.
arch:
if: startsWith(github.ref, 'refs/tags/v')
needs: [linux]
runs-on: ubuntu-latest
container: archlinux:latest
env:
TOKEN: ${{ secrets.GITEA_PACKAGES_TOKEN }}
REGISTRY: https://git.joshicodes.de/api/packages/JoshiCodes/arch/joshicodes
steps:
- uses: actions/checkout@v5
- uses: actions/download-artifact@v5
with:
name: linux
path: artifacts
- name: Build knock-bin
if: env.TOKEN != ''
run: |
pacman -Syu --noconfirm --needed base-devel
useradd -m builder
deb=$(find artifacts -name '*.deb' | head -1)
tag="${GITHUB_REF_NAME#v}"
ver="${tag//-/}"
mkdir -p /build && cp packaging/arch/knock-bin/PKGBUILD /build/ && cp "$deb" /build/
cd /build
name=$(basename "$deb")
sed -i -E "s/^pkgver=.*/pkgver=$ver/; s/^pkgrel=.*/pkgrel=1/" PKGBUILD
sed -i -E "s|^source=.*|source=(\"$name\")|" PKGBUILD
chown -R builder /build
su builder -c 'makepkg --nodeps --noconfirm'
ls -la *.pkg.tar.zst
- name: Upload to the Gitea pacman repository
if: env.TOKEN != ''
run: |
for f in /build/*.pkg.tar.zst; do
curl --fail-with-body -sS -X PUT --user "JoshiCodes:$TOKEN" --upload-file "$f" "$REGISTRY"
done
release:
if: startsWith(github.ref, 'refs/tags/v')
needs: [macos, linux, windows]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v5
with:
path: artifacts
merge-multiple: true
- name: Checksums
run: |
cd artifacts
sha256sum * > SHA256SUMS
cat SHA256SUMS
- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
run: |
pre=""
case "$TAG" in *-*) pre="--prerelease";; esac
if gh release view "$TAG" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
gh release upload "$TAG" -R "$GITHUB_REPOSITORY" --clobber artifacts/*
else
gh release create "$TAG" -R "$GITHUB_REPOSITORY" --title "knock ${TAG#v}" --generate-notes $pre artifacts/*
fi