Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Publish

on:
push:
branches:
- main
tags:
- v[0-9]+.[0-9]+.[0-9]+

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

# The workspace declares fugue-ppl as a path dependency, so cargo needs
# the sibling checkout even to read metadata. The published crate itself
# resolves fugue-ppl from crates.io by version (the path key is stripped
# at packaging time), so main is always the right branch here.
- name: Checkout sibling fugue (path dependency)
run: git clone --depth 1 --branch main https://github.com/alexnodeland/fugue.git "$GITHUB_WORKSPACE/../fugue"

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable

- name: Check if version is already published
id: version_check
run: |
PACKAGE_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "fugue-evo") | .version')

echo "Checking if fugue-evo version $PACKAGE_VERSION can be published..."

# Use cargo publish --dry-run to check if we can publish this version
# This is the most reliable method as it uses the same logic as actual publish
DRY_RUN_OUTPUT=$(cargo publish --dry-run --allow-dirty -p fugue-evo 2>&1)

if echo "$DRY_RUN_OUTPUT" | grep -q "already exists on crates.io index"; then
echo "Version $PACKAGE_VERSION of fugue-evo already exists on crates.io. Skipping publish."
echo "should_publish=false" >> $GITHUB_OUTPUT
else
echo "Version $PACKAGE_VERSION of fugue-evo can be published. Proceeding with publish."
echo "should_publish=true" >> $GITHUB_OUTPUT
fi

- name: Publish to crates.io
if: steps.version_check.outputs.should_publish == 'true'
run: cargo publish --allow-dirty -p fugue-evo
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ thiserror = "2.0"

# Observability
tracing = "0.1"
fugue-ppl = { path = "../fugue", version = "0.1.0" }
fugue-ppl = { path = "../fugue", version = "0.2.0" }

# WASM support (enabled via getrandom js feature when targeting wasm32)
[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand Down
4 changes: 4 additions & 0 deletions crates/fugue-evo-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ license = "MIT"
repository = "https://github.com/alexnodeland/fugue-evo"
keywords = ["genetic-algorithm", "wasm", "webassembly", "optimization"]
categories = ["algorithms", "wasm"]
# Distributed via `wasm-pack build` output (npm-shaped pkg/), not crates.io;
# its fugue-evo path dependency has no `version`, so `cargo publish` would
# reject the manifest anyway.
publish = false

[lib]
crate-type = ["cdylib", "rlib"]
Expand Down
Loading