Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/build-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@ jobs:
.
configurator

- name: Read crate version
- name: Read release version
id: meta
run: |
VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name=="wayscriber") | .version')
if [[ "${GITHUB_REF_NAME:-}" == v* ]]; then
VERSION="${GITHUB_REF_NAME#v}"
fi
if [[ -z "${VERSION:-}" ]]; then
VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name=="wayscriber") | .version')
fi
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"

- name: Pre-fetch Cargo dependencies (locked)
Expand Down
8 changes: 8 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ fn main() {
tablet: { feature = "tablet-input" },
}

println!("cargo:rerun-if-env-changed=WAYSCRIBER_RELEASE_VERSION");
match env::var("WAYSCRIBER_RELEASE_VERSION") {
Ok(release_version) if !release_version.is_empty() => {
println!("cargo:rustc-env=WAYSCRIBER_RELEASE_VERSION={release_version}");
}
_ => {}
}

let hash = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
Expand Down
2 changes: 1 addition & 1 deletion src/about_window/render/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn add_link_line(
}

fn version() -> &'static str {
env!("CARGO_PKG_VERSION")
crate::build_info::version()
}

fn commit_hash() -> &'static str {
Expand Down
3 changes: 3 additions & 0 deletions src/build_info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn version() -> &'static str {
option_env!("WAYSCRIBER_RELEASE_VERSION").unwrap_or(env!("CARGO_PKG_VERSION"))
}
5 changes: 4 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use clap::{ArgAction, Parser};

#[derive(Parser, Debug)]
#[command(name = "wayscriber")]
#[command(version, about = "Screen annotation tool for Wayland compositors")]
#[command(
version = crate::build_info::version(),
about = "Screen annotation tool for Wayland compositors"
)]
pub struct Cli {
/// Run as daemon (background service; bind a toggle like Super+D)
#[arg(long, short = 'd', action = ArgAction::SetTrue)]
Expand Down
2 changes: 1 addition & 1 deletion src/daemon/tray/ksni.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl ksni::Tray for WayscriberTray {
ksni::ToolTip {
icon_name: "wayscriber".into(),
icon_pixmap: vec![],
title: format!("Wayscriber {}", env!("CARGO_PKG_VERSION")),
title: format!("Wayscriber {}", crate::build_info::version()),
description,
}
}
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! rely on so that external tools (e.g. GUI configurators) can share validation
//! logic and serialization code with the main binary.

pub mod build_info;
pub mod capture;
pub mod config;
pub mod draw;
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod about_window;
mod app;
mod backend;
mod build_info;
mod capture;
mod cli;
mod config;
Expand Down
2 changes: 1 addition & 1 deletion src/ui/help_overlay/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn render_help_overlay(
} else {
format!(
"{} {} {} {} {} {} {} {} {}",
env!("CARGO_PKG_VERSION"),
crate::build_info::version(),
BULLET,
palette_binding,
ARROW,
Expand Down
5 changes: 3 additions & 2 deletions tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ Helper scripts for development, installation, packaging, and release workflows.
- **bump-version.sh** - Bump version numbers
- Updates Cargo.toml, configurator/Cargo.toml, Cargo.lock, PKGBUILD, .SRCINFO
- Auto-increments patch version if no version specified
- Supports MAJOR.MINOR.PATCH.HOTFIX for packaging-only hotfix releases
- Usage: `./tools/bump-version.sh [--dry-run] [new_version]`

- **create-release-tag.sh** - Create git tag (local only)
- Creates annotated tag `v<version>` without pushing
- Requires clean working tree
- Usage: `./tools/create-release-tag.sh <version>`
- Usage: `./tools/create-release-tag.sh <version>` (X.Y.Z or X.Y.Z.N)

- **publish-release-tag.sh** - Create and push git tag
- Creates annotated tag and pushes to origin
- Auto-detects version from Cargo.toml if not specified
- Usage: `./tools/publish-release-tag.sh [--version X.Y.Z] [--dry-run]`
- Usage: `./tools/publish-release-tag.sh [--version X.Y.Z[.N]] [--dry-run]`

- **release.sh** - Full release workflow
- Bumps version, commits changes, creates tag, and pushes
Expand Down
26 changes: 21 additions & 5 deletions tools/bump-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ usage() {
Usage: tools/bump-version.sh [--dry-run] [new_version]

- If new_version is omitted, bumps the patch version (e.g., 0.9.2 -> 0.9.3).
- new_version can be MAJOR.MINOR.PATCH or MAJOR.MINOR.PATCH.HOTFIX.
- Updates:
* Cargo.toml (wayscriber)
* configurator/Cargo.toml
Expand Down Expand Up @@ -82,13 +83,28 @@ else
next_version="${major}.${minor}.${patch}"
fi

if ! [[ "$next_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "error: invalid version format: $next_version (expected MAJOR.MINOR.PATCH digits)" >&2
if ! [[ "$next_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]; then
echo "error: invalid version format: $next_version (expected MAJOR.MINOR.PATCH[.HOTFIX])" >&2
exit 1
fi

IFS='.' read -r major minor patch hotfix extra <<<"$next_version"
if [[ -n "${extra:-}" ]]; then
echo "error: invalid version format: $next_version (too many segments)" >&2
exit 1
fi

cargo_version="${major}.${minor}.${patch}"
package_version="${next_version}"
if [[ -z "${hotfix:-}" ]]; then
cargo_version="${next_version}"
fi

echo "Current version: $current_version"
echo "Bumping to: $next_version"
if [[ "$cargo_version" != "$next_version" ]]; then
echo "Cargo version: $cargo_version (release version has hotfix)"
fi

update_version_field() {
local file="$1"
Expand All @@ -99,7 +115,7 @@ update_version_field() {
if $DRY_RUN; then
echo "dry-run: would update version in $file"
else
NEXT_VERSION="$next_version" perl -0777 -pi -e 's/(\[package\][^\[]*?\nversion\s*=\s*")\K[^"]+/$ENV{NEXT_VERSION}/s' "$file"
NEXT_VERSION="$cargo_version" perl -0777 -pi -e 's/(\[package\][^\[]*?\nversion\s*=\s*")\K[^"]+/$ENV{NEXT_VERSION}/s' "$file"
fi
}

Expand All @@ -118,9 +134,9 @@ fi

if [[ -f packaging/PKGBUILD ]]; then
if $DRY_RUN; then
echo "dry-run: would set pkgver=${next_version} in packaging/PKGBUILD and regenerate .SRCINFO"
echo "dry-run: would set pkgver=${package_version} in packaging/PKGBUILD and regenerate .SRCINFO"
else
sed -i "s/^pkgver=.*/pkgver=${next_version}/" packaging/PKGBUILD
sed -i "s/^pkgver=.*/pkgver=${package_version}/" packaging/PKGBUILD
(cd packaging && makepkg --printsrcinfo > .SRCINFO)
fi
else
Expand Down
5 changes: 3 additions & 2 deletions tools/create-release-tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Requirements:

Examples:
tools/create-release-tag.sh 0.9.2
tools/create-release-tag.sh 0.9.9.1
EOF
}

Expand All @@ -33,8 +34,8 @@ require_bin git
version="$1"
tag="v${version}"

if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "error: invalid version format: $version (expected MAJOR.MINOR.PATCH)" >&2
if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]; then
echo "error: invalid version format: $version (expected MAJOR.MINOR.PATCH[.HOTFIX])" >&2
exit 1
fi

Expand Down
4 changes: 4 additions & 0 deletions tools/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ if [[ -z "$VERSION" ]]; then
| head -n1)"
fi

if [[ -n "$VERSION" ]]; then
export WAYSCRIBER_RELEASE_VERSION="$VERSION"
fi

mkdir -p "${ARTIFACT_ROOT}"

info() { printf '\033[0;32m[INFO]\033[0m %s\n' "$*" >&2; }
Expand Down
7 changes: 6 additions & 1 deletion tools/publish-release-tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ DRY_RUN=0

usage() {
cat <<'EOF'
publish-release-tag.sh [--version X.Y.Z] [--dry-run]
publish-release-tag.sh [--version X.Y.Z[.N]] [--dry-run]

Creates an annotated git tag "v<version>" and pushes it to origin.
If --version is omitted, uses the wayscriber crate version from Cargo metadata.
Expand All @@ -33,6 +33,11 @@ if [[ -z "$VERSION" ]]; then
VERSION="$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name=="wayscriber") | .version')"
fi

if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]; then
echo "error: invalid version format: $VERSION (expected MAJOR.MINOR.PATCH[.HOTFIX])" >&2
exit 1
fi

TAG="v${VERSION}"

# Safety checks
Expand Down
47 changes: 37 additions & 10 deletions tools/update-aur.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ AUR_REPO="wayscriber"
PACKAGE_URL="https://aur.archlinux.org/packages/wayscriber"
AUR_DIR="$HOME/aur-packages/wayscriber"

usage() {
cat <<'EOF'
update-aur.sh [--version X.Y.Z[.N]]

Updates the AUR package metadata. By default, uses the Cargo.toml version.
EOF
}

VERSION_OVERRIDE=""
while [[ $# -gt 0 ]]; do
case "$1" in
--version) VERSION_OVERRIDE="$2"; shift 2 ;;
-h|--help) usage; exit 0 ;;
*) echo "Unknown arg: $1" >&2; usage; exit 1 ;;
esac
done

echo "═══════════════════════════════════════════════════════════════"
echo " WAYSCRIBER - AUR UPDATE AUTOMATION"
echo "═══════════════════════════════════════════════════════════════"
Expand All @@ -34,16 +51,26 @@ CARGO_VERSION=$(grep '^version = ' "$PROJECT_ROOT/Cargo.toml" | head -1 | sed 's
echo -e "${GREEN}📦 Current version in Cargo.toml: $CARGO_VERSION${NC}"
echo ""

RELEASE_VERSION="${VERSION_OVERRIDE:-$CARGO_VERSION}"
if ! [[ "$RELEASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]; then
echo -e "${RED}❌ Invalid version format: $RELEASE_VERSION (expected MAJOR.MINOR.PATCH[.HOTFIX])${NC}"
exit 1
fi
if [[ "$RELEASE_VERSION" != "$CARGO_VERSION" ]]; then
echo -e "${YELLOW}📦 Using release version override: $RELEASE_VERSION${NC}"
echo ""
fi

# Check if version tag exists on GitHub
cd "$PROJECT_ROOT"
if ! git tag | grep -q "^v$CARGO_VERSION\$"; then
echo -e "${YELLOW}⚠️ Git tag v$CARGO_VERSION does not exist${NC}"
if ! git tag | grep -q "^v$RELEASE_VERSION\$"; then
echo -e "${YELLOW}⚠️ Git tag v$RELEASE_VERSION does not exist${NC}"
echo ""
read -p "Create and push tag v$CARGO_VERSION? (y/n) " -n 1 -r
read -p "Create and push tag v$RELEASE_VERSION? (y/n) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
git tag -a "v$CARGO_VERSION" -m "Release v$CARGO_VERSION"
git push origin "v$CARGO_VERSION"
git tag -a "v$RELEASE_VERSION" -m "Release v$RELEASE_VERSION"
git push origin "v$RELEASE_VERSION"
echo -e "${GREEN}✅ Tag created and pushed${NC}"
else
echo -e "${RED}❌ Aborted - tag required for AUR${NC}"
Expand Down Expand Up @@ -85,13 +112,13 @@ echo -e "${GREEN}Copied $SOURCE_FILE to $AUR_DIR/PKGBUILD${NC}"
# Update version in PKGBUILD
cd "$AUR_DIR"
if grep -q '^pkgver=' PKGBUILD; then
sed -i "s/^pkgver=.*/pkgver=$CARGO_VERSION/" PKGBUILD
sed -i "s/^pkgver=.*/pkgver=$RELEASE_VERSION/" PKGBUILD
fi
if grep -q '^pkgrel=' PKGBUILD; then
sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD
fi

echo -e "${GREEN}✅ Updated PKGBUILD: pkgver=$CARGO_VERSION, pkgrel=1${NC}"
echo -e "${GREEN}✅ Updated PKGBUILD: pkgver=$RELEASE_VERSION, pkgrel=1${NC}"
echo ""

echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
Expand Down Expand Up @@ -144,7 +171,7 @@ echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
# Add and commit
git add PKGBUILD .SRCINFO .gitignore 2>/dev/null || git add PKGBUILD .SRCINFO
git commit -m "Update to v$CARGO_VERSION"
git commit -m "Update to v$RELEASE_VERSION"

# Push
if git push origin master 2>/dev/null; then
Expand All @@ -163,7 +190,7 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "═══════════════════════════════════════════════════════════════"
echo ""
echo "Package URL: $PACKAGE_URL"
echo "Version: $CARGO_VERSION"
echo "Version: $RELEASE_VERSION"
echo ""
echo "Users can update with:"
echo " yay -Syu wayscriber"
Expand All @@ -175,6 +202,6 @@ else
echo "To push manually later:"
echo " cd $AUR_DIR"
echo " git add PKGBUILD .SRCINFO"
echo " git commit -m 'Update to v$CARGO_VERSION'"
echo " git commit -m 'Update to v$RELEASE_VERSION'"
echo " git push origin master"
fi