From 5c2ed492d6a034871cb30472d958bb29e65c0af8 Mon Sep 17 00:00:00 2001 From: darman Date: Thu, 30 Jul 2026 00:10:38 +0200 Subject: [PATCH] hypr-chrome v0.1.1 (#7) --------- Co-authored-by: gitea-actions Reviewed-on: https://git.mgaction.town/darman/hypr-chrome/pulls/7 --- .env | 1 + .gitea/workflows/version-bump.yml | 89 +++++++++++++++++++++++++++++++ CLAUDE.md | 4 ++ CMakeLists.txt | 13 ++++- flake.nix | 12 ++++- 5 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 .env create mode 100644 .gitea/workflows/version-bump.yml diff --git a/.env b/.env new file mode 100644 index 0000000..a3a4478 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +PLUGIN_VERSION=0.1.1 diff --git a/.gitea/workflows/version-bump.yml b/.gitea/workflows/version-bump.yml new file mode 100644 index 0000000..24d34b2 --- /dev/null +++ b/.gitea/workflows/version-bump.yml @@ -0,0 +1,89 @@ +name: Version Bump + +on: + pull_request: + branches: [develop] + types: [opened, synchronize, reopened, labeled, unlabeled, closed] + +permissions: + contents: write + +jobs: + # Register this job's name as a required status check on develop's branch + # protection - that's what actually blocks the merge button. + check-bump-label: + if: github.event.action != 'closed' + runs-on: ubuntu-latest + steps: + - name: Require a bump/major, bump/minor, bump/patch, or bump/skip label + env: + LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }} + run: | + echo "$LABELS" | grep -qE '"bump/(major|minor|patch|skip)"' || { + echo "::error::PR into develop must carry one of bump/major, bump/minor, bump/patch, bump/skip" + exit 1 + } + + # Runs once, after the merge has already happened, to commit the actual + # version bump onto develop. + apply-version-bump: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: develop + fetch-depth: 0 + token: ${{ secrets.CI_BOT_TOKEN }} + + - name: Determine bump level from PR labels + id: level + env: + LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }} + run: | + for lvl in major minor patch skip; do + if echo "$LABELS" | grep -q "\"bump/$lvl\""; then + echo "level=$lvl" >> "$GITHUB_OUTPUT" + exit 0 + fi + done + echo "::error::merged PR into develop has no bump/major, bump/minor, bump/patch, or bump/skip label" + exit 1 + + - name: Bump PLUGIN_VERSION in .env + if: steps.level.outputs.level != 'skip' + env: + LEVEL: ${{ steps.level.outputs.level }} + run: | + set -euo pipefail + + CURRENT=$(sed -n 's/^PLUGIN_VERSION=//p' .env) + IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT" + + case "$LEVEL" in + major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;; + minor) MINOR=$((MINOR + 1)); PATCH=0 ;; + patch) PATCH=$((PATCH + 1)) ;; + *) echo "::error::unknown bump level '$LEVEL'"; exit 1 ;; + esac + + NEW="$MAJOR.$MINOR.$PATCH" + + sed -i "s/^PLUGIN_VERSION=.*/PLUGIN_VERSION=${NEW}/" .env + + echo "CURRENT_VERSION=${CURRENT}" >> "$GITHUB_ENV" + echo "NEW_VERSION=${NEW}" >> "$GITHUB_ENV" + + - name: Commit and push + if: steps.level.outputs.level != 'skip' + run: | + set -euo pipefail + if [ "$CURRENT_VERSION" = "$NEW_VERSION" ]; then + echo "::error::version did not change (${CURRENT_VERSION} -> ${NEW_VERSION})" + exit 1 + fi + git config user.name "gitea-actions" + git config user.email "actions@noreply.localhost" + git add .env + git commit -m "Bump PLUGIN_VERSION to ${NEW_VERSION}" + git push origin HEAD:develop diff --git a/CLAUDE.md b/CLAUDE.md index beec172..b7408c8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -6,6 +6,10 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co `hypr-chrome` is a Hyprland compositor plugin (a `.so` loaded via `hyprctl plugin load`). It draws a chamfered HUD-style border frame behind every window, expanded past the window's own edges, plus a floating title bar hanging off the top-left corner. It is a C++ shared library built against Hyprland's plugin API/headers — there is no application logic outside the compositor plugin lifecycle. +## Workflow + +Do not commit directly to `master` or `develop`. All feature work goes on a `feature/` branch and all bug fixes go on a `fix/` branch, cut from `develop` and merged back into `develop` via PR. `develop` is periodically merged into `master` with its commits squashed into a single release commit — `master` should only ever contain release commits. + ## Build Requires the Hyprland headers/libs (`hyprland`, `libdrm`, `libinput`, `libudev`, `wayland-server`, `xkbcommon`, `pixman-1`, cairo, etc., all ABI-matched to a specific Hyprland build). A pinned Nix flake dev shell provides all of it: diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c02b39..184c872 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,19 @@ cmake_minimum_required(VERSION 3.27) +# PLUGIN_VERSION lives in .env (single source of truth - also read by +# flake.nix) so .gitea/workflows/version-bump.yml only ever has to touch one +# file, rather than a "VERSION X.Y" grep/sed that can't tell this project's +# own version apart from cmake_minimum_required's version above. +file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/.env" HYPR_CHROME_ENV_LINES) +foreach(HYPR_CHROME_ENV_LINE IN LISTS HYPR_CHROME_ENV_LINES) + if(HYPR_CHROME_ENV_LINE MATCHES "^PLUGIN_VERSION=(.*)$") + set(HYPR_CHROME_PLUGIN_VERSION "${CMAKE_MATCH_1}") + endif() +endforeach() + project(hypr-chrome DESCRIPTION "Draws a chamfered HUD-style border frame with a title bar around each window." - VERSION 0.1 + VERSION ${HYPR_CHROME_PLUGIN_VERSION} ) # Match the Makefile's prior default (CXXFLAGS ?= -O2) so a bare `cmake -B diff --git a/flake.nix b/flake.nix index ad5b465..453f023 100644 --- a/flake.nix +++ b/flake.nix @@ -18,13 +18,23 @@ let system = "x86_64-linux"; pkgs = import nixpkgs { inherit system; }; + + # Read from .env (also read by CMakeLists.txt) rather than a separate + # hardcoded string, so .gitea/workflows/version-bump.yml only ever has + # to touch that one file for both build systems to stay in sync. + pluginVersion = + let + envLines = pkgs.lib.splitString "\n" (builtins.readFile ./.env); + versionLine = pkgs.lib.findFirst (pkgs.lib.hasPrefix "PLUGIN_VERSION=") null envLines; + in + pkgs.lib.removePrefix "PLUGIN_VERSION=" versionLine; in { # Build with Hyprland's own stdenv (not nixpkgs' default one) so the # compiler/libstdc++ ABI matches what Hyprland itself was built with. packages.${system}.default = pkgs.hyprland.stdenv.mkDerivation { pname = "hypr-chrome"; - version = "0.1"; + version = pluginVersion; src = self; nativeBuildInputs = [ pkgs.cmake pkgs.pkg-config ];