-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (41 loc) · 1.96 KB
/
Copy pathpublish.yml
File metadata and controls
50 lines (41 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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 }}