Skip to content

Commit 3ae30db

Browse files
authored
add publish ci job (#41)
1 parent 43d417f commit 3ae30db

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

.github/workflows/publish.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: publish event-scanner
2+
3+
# This workflow publishes event-scanner on crates.io.
4+
permissions:
5+
contents: read
6+
7+
on:
8+
push:
9+
tags:
10+
- v*
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
14+
cancel-in-progress: true
15+
16+
env:
17+
CARGO_TERM_COLOR: always
18+
19+
jobs:
20+
check-publish:
21+
name: Publish event-scanner on crates.io
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v5
25+
26+
- name: Install rust
27+
uses: actions-rust-lang/setup-rust-toolchain@v1
28+
29+
- name: Verify tag matches crate version
30+
id: version-check
31+
run: |
32+
PKG_VERSION=$(cargo metadata --no-deps --format-version 1 \
33+
| jq -r '.packages[] | select(.name=="event-scanner") | .version')
34+
TAG_VERSION="${GITHUB_REF_NAME#v}"
35+
36+
echo "Package: ${PKG_VERSION}"
37+
echo "Tag: ${TAG_VERSION}"
38+
39+
if [ -z "$PKG_VERSION" ]; then
40+
echo "Failed to determine package version via cargo metadata" >&2
41+
exit 1
42+
fi
43+
if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
44+
echo "Tag v${TAG_VERSION} does not match package version ${PKG_VERSION}" >&2
45+
exit 1
46+
fi
47+
48+
- name: Check event-scanner
49+
run: cargo publish -p event-scanner --locked --dry-run
50+
51+
# cargo automatically picks up CARGO_REGISTRY_TOKEN from environment variables
52+
- name: Publish event-scanner
53+
env:
54+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
55+
run: |
56+
if [ -z "${CARGO_REGISTRY_TOKEN:-}" ]; then
57+
echo "CARGO_REGISTRY_TOKEN is not set in repository secrets" >&2
58+
exit 1
59+
fi
60+
cargo publish -p event-scanner --locked

0 commit comments

Comments
 (0)