Skip to content

Commit a99239b

Browse files
committed
feat: add GitHub Actions tests workflow for crate.io publishing
1 parent 2ae6c71 commit a99239b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish Crate
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch: # Permite ejecutar manualmente desde la interfaz de GitHub
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Install Rust
18+
uses: actions/setup-rust@v1
19+
with:
20+
rust-version: stable
21+
22+
- name: Check version consistency
23+
run: |
24+
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
25+
CRATE_VERSION=$(cargo metadata --no-deps --format-version=1 | jq -r '.packages[0].version')
26+
if [ "$TAG_VERSION" != "$CRATE_VERSION" ]; then
27+
echo "Tag version (v$TAG_VERSION) does not match Cargo.toml version ($CRATE_VERSION)"
28+
exit 1
29+
fi
30+
31+
- name: Publish to crates.io
32+
run: cargo publish --dry-run
33+
env:
34+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

0 commit comments

Comments
 (0)