commit 4cdc2c819a60f89274ec06fff3683bd82c9beba1 from: mtmn date: Thu May 7 18:23:07 2026 UTC feat: add flake and release script commit - baa3ba3065ea3788dc658a03a30a652f692766d5 commit + 4cdc2c819a60f89274ec06fff3683bd82c9beba1 blob - /dev/null blob + fd565e60d24d401adcf14eb49e27abab1b9108e9 (mode 644) --- /dev/null +++ cliff.toml @@ -0,0 +1,45 @@ +[changelog] +header = "# Changelog\n\n" +body = """ +{% if version -%} +## [{{ version | trim_start_matches(pat="v") }}]{% if previous.version %} - {{ timestamp | date(format="%Y-%m-%d") }}{% endif %} + +{% else -%} +## [Unreleased] + +{% endif -%} +{% for group, commits in commits | group_by(attribute="group") -%} +### {{ group }} + +{% for commit in commits -%} +- {% if commit.breaking %}**breaking:** {% endif -%} +{% if commit.scope %}**{{ commit.scope }}:** {% endif -%} +{{ commit.message | upper_first }} \ +([`{{ commit.id | truncate(length=7, end="") }}`](https://git.sr.ht/~mtmn/scores/commit/{{ commit.id }})) +{% endfor %} +{% endfor %} +""" +footer = "" +trim = true + +[git] +conventional_commits = true +filter_unconventional = true +split_commits = false +commit_parsers = [ + { message = "^feat", group = "Features" }, + { message = "^fix", group = "Bug Fixes" }, + { message = "^docs", group = "Documentation" }, + { message = "^test", group = "Testing" }, + { message = "^chore", group = "Housekeeping" }, + { message = "^chore\\(deps\\)", group = "Dependencies" }, + { message = "^ci", skip = true }, +] +protect_breaking_commits = true +filter_commits = true +tag_pattern = "v[0-9].*" +topo_order = false +sort_commits = "oldest" + +[bump] +initial_tag = "v0.1.0" blob - /dev/null blob + 61ecdc1515ac938d4dc7d28ad121bd11bfb21065 (mode 644) --- /dev/null +++ flake.lock @@ -0,0 +1,115 @@ +{ + "nodes": { + "crane": { + "locked": { + "lastModified": 1778106249, + "narHash": "sha256-cM/AuKy5tMhwOOQIbha8ZRRMHVfNf7cv2aljIw+qoCg=", + "owner": "ipetkov", + "repo": "crane", + "rev": "6d015ea29630b7ad2402841386da2cb617a470a7", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1777969788, + "narHash": "sha256-8sr3w0KyQ0K7TEd8pYwYrxiDk0GZ4A7iIcl1lsxlzVM=", + "owner": "nix-community", + "repo": "fenix", + "rev": "3abc2d5559f4dc30c710ab152abcb4cb60b561ba", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1777954456, + "narHash": "sha256-hGdgeU2Nk87RAuZyYjyDjFL6LK7dAZN5RE9+hrDTkDU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "549bd84d6279f9852cae6225e372cc67fb91a4c1", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "crane": "crane", + "fenix": "fenix", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1777924689, + "narHash": "sha256-9Z0puLyCSYvtYhP1IZMxC05DSgwA+5rE99jsv1KErc4=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "91c7c2c4ca6a0520cfbf97e369e4fb7bf0b63b7a", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} blob - /dev/null blob + c0d40e955f029f749e226238c248e0be3c4b9df7 (mode 644) --- /dev/null +++ flake.nix @@ -0,0 +1,66 @@ +{ + inputs = { + nixpkgs.url = "nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + crane = { + url = "github:ipetkov/crane"; + }; + }; + + outputs = { + nixpkgs, + flake-utils, + fenix, + crane, + ... + }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = nixpkgs.legacyPackages.${system}; + fenixPkgs = fenix.packages.${system}; + + rustToolchain = fenixPkgs.stable.toolchain; + + craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; + src = craneLib.cleanCargoSource ./.; + + cargoToml = fromTOML (builtins.readFile ./Cargo.toml); + + baseNativeBuildInputs = with pkgs; [ + pkg-config + dbus + sqlite + openssl + ]; + + commonArgs = { + pname = "scores"; + inherit src; + inherit (cargoToml.package) version; + + strictDeps = true; + nativeBuildInputs = baseNativeBuildInputs; + buildInputs = with pkgs; [sqlite.dev openssl.dev dbus.dev]; + }; + + scores = craneLib.buildPackage (commonArgs + // { + cargoArtifacts = craneLib.buildDepsOnly commonArgs; + }); + in { + packages = { + default = scores; + inherit scores; + }; + + devShells.default = pkgs.mkShell { + nativeBuildInputs = [rustToolchain fenixPkgs.rust-analyzer] ++ baseNativeBuildInputs; + inherit (commonArgs) buildInputs; + }; + }); +} blob - /dev/null blob + a19044bb26872c4fd68183c0d350cdeb28693025 (mode 755) --- /dev/null +++ hack/release @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +set -euo pipefail + +require() { + command -v "$1" &>/dev/null || { + echo "error: $1 not found" + exit 1 + } +} +require git +require git-cliff + +# --- pre-flight --- + +if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then + echo "error: not on master branch" + exit 1 +fi + +if [ -n "$(git status --porcelain)" ]; then + echo "error: working tree is dirty" + exit 1 +fi + +# --- version calculation --- + +next=$(git-cliff --bumped-version | sed 's/^v//') + +if git tag | grep -qx "v$next"; then + echo "no releasable commits since v$next" + exit 0 +fi + +echo "releasing -> v$next" + +# --- update Cargo.toml --- + +sed -i "s/^version = .*/version = \"$next\"/" Cargo.toml +cargo generate-lockfile +git add Cargo.toml Cargo.lock + +# --- changelog --- + +git-cliff --tag "v$next" --output CHANGELOG.md +sed -i -e :a -e '/^\s*$/{$d;N;ba' -e '}' CHANGELOG.md +git add CHANGELOG.md + +git commit -m "chore: release v$next" + +# --- tag and push --- + +git tag "v$next" +git push origin master --tags + +echo "released v$next successfully"