From 61f8ac1f568cfcd8aa33bca62ab3102fc0c5add6 Mon Sep 17 00:00:00 2001 From: Valentin Heiserer Date: Mon, 10 Nov 2025 22:15:47 +0100 Subject: [PATCH] update readme and add action --- .github/workflows/release.yml | 83 +++++++++++++++++++++++++++++++++++ .gitignore | 4 +- Cargo.toml | 2 +- README.md | 12 ++--- shell.nix | 18 ++++++++ 5 files changed, 110 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 shell.nix diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1040dc8 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,83 @@ +name: Release crate + +on: + release: + types: [published] + + +env: + GITEA_BASE_URL: https://gitea.heiserer.de + REGISTRY_OWNER: ${{ github.repository_owner }} + + +jobs: + release: + name: Publish to crates.io and create GitHub Release + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Cache cargo registry and git index + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Build and test + run: cargo test --workspace --verbose + + - name: Install cargo-edit and set crate version + id: set_version + run: | + # install cargo-edit (provides `cargo set-version`) + cargo install cargo-edit --locked --force + TAG="${{ github.event.release.tag_name }}" + # strip a leading 'v' if present + VERSION="${TAG#v}" + cargo set-version "$VERSION" --workspace + # expose the version for later steps + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Configure Cargo registries (crates.io default + add Gitea) + shell: bash + env: + TOKEN: ${{ secrets.CARGO_GITEA_TOKEN }} + run: | + mkdir -p ~/.cargo + # crates.io stays default + cat > ~/.cargo/config.toml <<'EOF' + [registry] + default = "crates-io" + EOF + + # Add Gitea as extra registry (sparse index recommended) + { + echo "[registries.gitea]" + echo "index = \"sparse+${GITEA_BASE_URL}/api/packages/${REGISTRY_OWNER}/cargo/\"" + } >> ~/.cargo/config.toml + + # Auth for Gitea registry + umask 077 + cat > ~/.cargo/credentials.toml < {}; +in +pkgs.mkShell { + buildInputs = with pkgs; [ + cargo + rustc + rustPackages.clippy + pkg-config + gnupg + pinentry + pinentry-curses + ]; + shellHook = '' + # Export GPG_TTY so pinentry-curses can attach to the current terminal + export GPG_TTY=$(tty) + ''; +}