@@ -154,9 +154,38 @@ jobs:
154154 - name : Approval granted
155155 run : echo "Release approved for publishing to crates.io"
156156
157+ ensure-owners :
158+ name : Ensure crates.io owners
159+ needs : create-tag
160+ if : needs.create-tag.outputs.created == 'true'
161+ runs-on : ubuntu-latest
162+ steps :
163+ - uses : actions/checkout@v4
164+ with :
165+ ref : ${{ needs.create-tag.outputs.tag }}
166+ - name : Install Rust toolchain
167+ uses : dtolnay/rust-toolchain@stable
168+
169+ - name : Add crates.io owners (best-effort)
170+ env :
171+ TOKEN : ${{ secrets.CARGO_REGISTRY_TOKEN }}
172+ OWNERS : github:univerlab:owners
173+ run : |
174+ set -eu
175+ if [ -z "$TOKEN" ]; then
176+ echo "No cargo token found in CARGO_REGISTRY_TOKEN; skipping owners update"
177+ exit 0
178+ fi
179+ CRATE_NAME=$(grep '^name = ' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/' | tr -d '\r')
180+ echo "crate=$CRATE_NAME"
181+ for owner in $(echo "$OWNERS" | tr ',' ' '); do
182+ echo "Adding owner: $owner"
183+ cargo owner --token "$TOKEN" --add "$owner" || echo "cargo owner failed for $owner (continuing)"
184+ done
185+
157186 publish :
158187 name : Publish to crates.io
159- needs : [create-tag, approve]
188+ needs : [create-tag, approve, ensure-owners ]
160189 runs-on : ubuntu-latest
161190 steps :
162191 - uses : actions/checkout@v4
@@ -166,5 +195,24 @@ jobs:
166195 - name : Install Rust toolchain
167196 uses : dtolnay/rust-toolchain@stable
168197
198+ - name : Check if stable release
199+ id : version_check
200+ run : |
201+ VERSION=$(grep '^version = ' Cargo.toml | sed 's/.*"\(.*\)".*/\1/')
202+ if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
203+ echo "is_stable=true" >> $GITHUB_OUTPUT
204+ echo "Version $VERSION is stable — will publish"
205+ else
206+ echo "is_stable=false" >> $GITHUB_OUTPUT
207+ echo "Version $VERSION is prerelease/dev — skipping publish"
208+ fi
209+
169210 - name : Cargo publish
170- run : cargo publish --token ${{ secrets.CARGO_TOKEN }}
211+ if : steps.version_check.outputs.is_stable == 'true'
212+ env :
213+ CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_REGISTRY_TOKEN }}
214+ run : cargo publish --allow-dirty
215+
216+ - name : Skipped prerelease
217+ if : steps.version_check.outputs.is_stable == 'false'
218+ run : echo "⏭️ Skipped crates.io publish for prerelease version"
0 commit comments