-
Notifications
You must be signed in to change notification settings - Fork 10
32 lines (28 loc) · 942 Bytes
/
release.yml
File metadata and controls
32 lines (28 loc) · 942 Bytes
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
name: Release
on:
push:
tags:
- 'v*'
jobs:
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Check if version exists on crates.io
id: check
run: |
VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
if cargo search mathcore --limit 1 | grep -q "mathcore = \"$VERSION\""; then
echo "Version $VERSION already exists on crates.io"
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "Version $VERSION not found on crates.io"
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Publish to crates.io
if: steps.check.outputs.exists == 'false'
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}