diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..3bcc128 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,32 @@ +name: CI + +on: + push: + branches: ['**'] + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + container: rust:latest + defaults: + run: + working-directory: src + steps: + - uses: actions/checkout@v4 + + - name: Cache cargo registry + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + src/target + key: ${{ runner.os }}-cargo-${{ hashFiles('src/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo- + + - name: Build + run: cargo build --release + + - name: Test + run: cargo test --release diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..d74c374 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,47 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + build-linux-static: + runs-on: ubuntu-latest + container: rust:latest + defaults: + run: + working-directory: src + steps: + - uses: actions/checkout@v4 + + - name: Cache cargo registry + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + src/target + key: linux-musl-cargo-${{ hashFiles('src/Cargo.lock') }} + restore-keys: linux-musl-cargo- + + - name: Install musl toolchain + run: | + apt-get update -qq && apt-get install -y -qq musl-tools + rustup target add x86_64-unknown-linux-musl + + - name: Build static binary + run: cargo build --release --target x86_64-unknown-linux-musl + + - name: Prepare artifact + run: | + mkdir -p /tmp/dist + cp target/x86_64-unknown-linux-musl/release/obikmer /tmp/dist/obikmer-linux-x86_64 + strip /tmp/dist/obikmer-linux-x86_64 + + - name: Upload release asset + uses: actions/upload-artifact@v4 + with: + name: obikmer-linux-x86_64 + path: /tmp/dist/obikmer-linux-x86_64 + if-no-files-found: error diff --git a/Makefile b/Makefile index 0fe6d46..04942bf 100644 --- a/Makefile +++ b/Makefile @@ -63,3 +63,28 @@ clean-doc: .PHONY: clean clean: clean-doc rm -rf $(VENV) + +# ── release ─────────────────────────────────────────────────────────────────── + +CARGO_TOML := $(CARGO_DIR)/obikmer/Cargo.toml + +.PHONY: bump-version +bump-version: + @current=$$(grep '^version = ' $(CARGO_TOML) | head -n 1 | sed 's/version = "\(.*\)"/\1/'); \ + if [ -n "$(RELEASE)" ]; then \ + new_version="$(RELEASE)"; \ + else \ + major=$$(echo $$current | cut -d. -f1); \ + minor=$$(echo $$current | cut -d. -f2); \ + patch=$$(echo $$current | cut -d. -f3); \ + new_patch=$$((patch + 1)); \ + new_version="$$major.$$minor.$$new_patch"; \ + fi; \ + echo "Version: $$current -> $$new_version"; \ + sed -i.bak "s/^version = \"$$current\"/version = \"$$new_version\"/" $(CARGO_TOML) && \ + rm $(CARGO_TOML).bak + +.PHONY: release +release: bump-version + @jj auto-describe + @jj git push --change @ diff --git a/src/Cargo.lock b/src/Cargo.lock index bdb1caa..bb91a4d 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -1704,7 +1704,7 @@ dependencies = [ [[package]] name = "obikmer" -version = "0.1.0" +version = "0.1.1" dependencies = [ "clap", "csv", diff --git a/src/obikmer/Cargo.toml b/src/obikmer/Cargo.toml index 4045476..07239a0 100644 --- a/src/obikmer/Cargo.toml +++ b/src/obikmer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "obikmer" -version = "0.1.0" +version = "0.1.1" edition = "2024" [[bin]] diff --git a/src/obikmer/src/main.rs b/src/obikmer/src/main.rs index fdcf69c..a0b270b 100644 --- a/src/obikmer/src/main.rs +++ b/src/obikmer/src/main.rs @@ -6,7 +6,7 @@ use clap::{Parser, Subcommand}; use tracing_subscriber::{EnvFilter, fmt}; #[derive(Parser)] -#[command(name = "obikmer", about = "DNA k-mer tools")] +#[command(name = "obikmer", about = "DNA k-mer tools", version)] struct Cli { #[command(subcommand)] command: Commands,