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
51
52
53
54
55
56
57
58
59
60
name: Release
# Publish to crates.io via Trusted Publishing (OIDC) when a version tag is pushed.
#
# Prerequisites (one-time, on crates.io):
# Settings → Trusted Publishing → add a GitHub publisher with
# Repository: reearth/fastxml
# Workflow: release.yml
# Environment: crates-io
# No CARGO_REGISTRY_TOKEN secret is needed — the token is minted per-run via OIDC.
#
# To cut a release:
# 1. Bump the version (Cargo.toml, Cargo.lock, README) and merge to main.
# 2. git tag v<x.y.z> && git push origin v<x.y.z>
on:
push:
tags:
- "v*"
permissions:
env:
CARGO_TERM_COLOR: always
jobs:
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
# The Trusted Publishing config on crates.io is scoped to this environment.
environment: crates-io
permissions:
# Required to mint the OIDC token exchanged for a crates.io access token.
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Verify tag matches Cargo.toml version
run: |
tag="${GITHUB_REF_NAME#v}"
# This is a workspace (fastxml + fastxml-conformance); select by name.
crate=$(cargo metadata --no-deps --format-version 1 \
| python3 -c "import json,sys; print(next(p['version'] for p in json.load(sys.stdin)['packages'] if p['name']=='fastxml'))")
if [ "$tag" != "$crate" ]; then
echo "::error::Tag v$tag does not match fastxml Cargo.toml version $crate"
exit 1
fi
echo "Releasing fastxml $crate"
- name: Authenticate with crates.io
id: auth
uses: rust-lang/crates-io-auth-action@v1
- name: Publish
run: cargo publish -p fastxml
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}