rsticle 0.1.2

Treat source files as articles / narrative documentation
Documentation
set shell := ["nu", "--config", "Tasks.nu", "-c"]

export RELEASE_PACKAGE_VERSION := `package-version`
export RELEASE_TAG := `$"v(package-version)"`
export RELEASE_DIR := `$"releases/(package-version)"`
export RELEASE_ASSET_DIR := `$"releases/(package-version)/assets"`

test:
    cargo test --workspace --all-features
    cargo test --workspace --all-features --examples

doc:
    cargo doc --workspace --all-features --no-deps

build-release-binaries:
    cargo build --package rsticle-cli --release --target x86_64-unknown-linux-gnu
    cargo build --package rsticle-cli --release --target x86_64-pc-windows-gnu
    @#cargo build --package rsticle-cli --release --target aarch64-apple-darwin # not supported OOTB, and I'm not motivated enough to set it up


# Collect binaries into release directory and create checksums
collect-release-assets: build-release-binaries
    rm -rf {{RELEASE_ASSET_DIR}}
    mkdir {{RELEASE_ASSET_DIR}}

    cp target/x86_64-pc-windows-gnu/release/rsticle.exe $"{{RELEASE_ASSET_DIR}}/rsticle-x86_64-win.exe"
    cp target/x86_64-unknown-linux-gnu/release/rsticle $"{{RELEASE_ASSET_DIR}}/rsticle-x86_64-linux"

    do { cd {{RELEASE_ASSET_DIR}}; md5sum * | save md5sum.txt }


# Do full release. Requires path to release notes
release notes: test doc collect-release-assets
    git checkout main
    git pull --ff-only --tags

    cargo publish --package rsticle
    cargo publish --package rsticle-cli
    cargo publish --package rsticle-rustdoc

    git tag {{RELEASE_TAG}} -m $"Release {{RELEASE_PACKAGE_VERSION}}\n\n(open {{notes}})"
    git push origin {{RELEASE_TAG}}

    codeberg release new {{RELEASE_TAG}} {{notes}}
    codeberg release upload {{RELEASE_TAG}} (glob {{RELEASE_ASSET_DIR}}/*}


yank-release version:
    git tag --delete v{{version}}
    git push --delete origin v{{version}}
    codeberg release delete v{{version}}
    cargo yank rsticle --version {{version}}
    cargo yank rsticle-cli --version {{version}}
    cargo yank rsticle-rustdoc --version {{version}}