diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml new file mode 100644 index 0000000..8daf837 --- /dev/null +++ b/.forgejo/workflows/release.yml @@ -0,0 +1,82 @@ +name: Release + +on: + push: + tags: + - 'v*' + workflow_dispatch: + +jobs: + release: + name: Build and Release + runs-on: nix + + steps: + - name: Check out Repository + uses: https://git.konstantinfickel.de/actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + fetch-depth: 0 + + - name: Extract version and handle tagging + id: version + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + # Manual trigger: read version from Cargo.toml + VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/') + TAG="v${VERSION}" + + # Check if tag already exists + if git rev-parse "$TAG" >/dev/null 2>&1; then + echo "::error::Version ${VERSION} is already released" + exit 1 + fi + + # Create and push the tag + git tag "$TAG" + git push origin "$TAG" + + echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT + echo "TAG=${TAG}" >> $GITHUB_OUTPUT + else + # Tag push trigger: extract version from tag + VERSION="${GITHUB_REF_NAME#v}" + echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT + echo "TAG=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT + fi + + - name: Build .deb package + run: nix build .#streamd-deb -o result-deb + + - name: Build static binary + run: nix build .#streamd-musl -o result-musl + + - name: Prepare release artifacts + run: | + mkdir -p release + cp result-deb release/streamd_${{ steps.version.outputs.VERSION }}_amd64.deb + cp result-musl/bin/streamd release/streamd-${{ steps.version.outputs.VERSION }}-linux-x86_64 + + - name: Create release + uses: https://code.forgejo.org/actions/forgejo-release@v2 + with: + direction: upload + url: https://git.konstantinfickel.de + repo: kfickel/streamd + token: ${{ secrets.RELEASE_TOKEN }} + tag: ${{ steps.version.outputs.TAG }} + release-dir: release + release-notes: | + ## streamd ${{ steps.version.outputs.VERSION }} + + ### Debian/Ubuntu + ```bash + wget /streamd_${{ steps.version.outputs.VERSION }}_amd64.deb + sudo dpkg -i streamd_${{ steps.version.outputs.VERSION }}_amd64.deb + ``` + + ### Static binary + ```bash + wget /streamd-${{ steps.version.outputs.VERSION }}-linux-x86_64 + chmod +x streamd-*-linux-x86_64 + sudo mv streamd-*-linux-x86_64 /usr/local/bin/streamd + ``` diff --git a/README.md b/README.md index 1ee95a9..a738339 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,39 @@ Strea.md is a personal knowledge management and time-tracking CLI tool. It organizes time-ordered markdown files using `@tag` annotations, letting you manage tasks, track time, and query your notes from the terminal. +## Installation + +### Debian/Ubuntu (.deb package) + +Download and install the latest release: + +```bash +wget https://git.konstantinfickel.de/kfickel/streamd/releases/download/vX.Y.Z/streamd_X.Y.Z_amd64.deb +sudo dpkg -i streamd_X.Y.Z_amd64.deb +``` + +This includes shell completions for bash, zsh, and fish. + +### Static Binary + +Download the statically-linked binary: + +```bash +wget https://git.konstantinfickel.de/kfickel/streamd/releases/download/vX.Y.Z/streamd-X.Y.Z-linux-x86_64 +chmod +x streamd-X.Y.Z-linux-x86_64 +sudo mv streamd-X.Y.Z-linux-x86_64 /usr/local/bin/streamd +``` + +### Nix + +Using the flake directly: + +```bash +nix run git+https://git.konstantinfickel.de/kfickel/streamd +``` + +Or add to your NixOS/Home Manager configuration using the provided `homeManagerModules.default`. + ## Core Concepts - **Shards** — Sections of markdown files, organized hierarchically by headings. Each shard can contain markers, tags, and nested child shards. diff --git a/flake.nix b/flake.nix index d0c3479..38723ae 100644 --- a/flake.nix +++ b/flake.nix @@ -30,6 +30,9 @@ inherit (nixpkgs) lib; forAllSystems = lib.genAttrs lib.systems.flakeExposed; + # Read version from Cargo.toml as single source of truth + version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.version; + mkPkgs = system: import nixpkgs { @@ -58,7 +61,7 @@ commonArgs = { src = craneLib.path ./.; pname = "streamd"; - version = "0.1.0"; + inherit version; strictDeps = true; }; @@ -102,15 +105,85 @@ commitizen.enable = true; }; }; + + mkMuslCraneLib = + system: + let + pkgs = mkPkgs system; + toolchain = pkgs.rust-bin.stable.latest.default.override { + targets = [ "x86_64-unknown-linux-musl" ]; + }; + in + (crane.mkLib pkgs).overrideToolchain toolchain; + + mkStreamdMusl = + system: + let + craneLib = mkMuslCraneLib system; + commonArgs = { + src = craneLib.path ./.; + pname = "streamd"; + inherit version; + strictDeps = true; + CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl"; + CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static"; + }; + cargoArtifacts = craneLib.buildDepsOnly commonArgs; + in + craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; }); + + mkStreamdDeb = + system: + let + pkgs = mkPkgs system; + streamd-musl = mkStreamdMusl system; + in + pkgs.runCommand "streamd_${version}_amd64.deb" { + nativeBuildInputs = [ pkgs.nfpm ]; + } '' + # Generate shell completions + mkdir -p completions + ${streamd-musl}/bin/streamd completions bash > completions/streamd.bash + ${streamd-musl}/bin/streamd completions zsh > completions/_streamd + ${streamd-musl}/bin/streamd completions fish > completions/streamd.fish + + cat > nfpm.yaml <