#!/usr/bin/env bash # Usage: scripts/release.sh 0.2.0 # Sets the version everywhere, commits, tags v0.2.0 and pushes. The tag # starts .github/workflows/release.yml, which builds all platforms and # publishes the GitHub release. set -euo pipefail cd "$(dirname "$0")/.." v="${1:-}" if ! [[ "$v" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]]; then echo "usage: $0 e.g. $0 0.2.0 or $0 0.2.0-rc1" >&2 exit 2 fi if [ -n "$(git status --porcelain)" ]; then echo "working tree is not clean; commit or stash first" >&2 exit 1 fi if [ "$(git branch --show-current)" != main ]; then echo "releases are cut from main" >&2 exit 1 fi if git rev-parse -q --verify "refs/tags/v$v" >/dev/null; then echo "tag v$v exists already" >&2 exit 1 fi # Cargo workspace, npm, Tauri, Arch packages. sed -i -E "0,/^version = \"[^\"]+\"/s//version = \"$v\"/" Cargo.toml npm version "$v" --no-git-tag-version --allow-same-version >/dev/null sed -i -E "s/(\"version\": )\"[^\"]+\"/\1\"$v\"/" src-tauri/tauri.conf.json base="${v%%-*}" sed -i -E "s/^pkgver=.*/pkgver=$base/; s/^pkgrel=.*/pkgrel=1/" packaging/arch/knock/PKGBUILD packaging/arch/knock-bin/PKGBUILD cargo update -w --offline >/dev/null 2>&1 || cargo update -w >/dev/null git add Cargo.toml Cargo.lock package.json package-lock.json src-tauri/tauri.conf.json packaging/arch # The version may already be set (first release); then there is nothing to commit. git diff --cached --quiet || git commit -q -m "Release v$v" git tag -a "v$v" -m "knock $v" git push -q origin main "v$v" echo "Pushed v$v. Follow the build: gh run watch \$(gh run list -w release -L1 --json databaseId -q '.[0].databaseId')"