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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Publish dig-logging to crates.io when a vX.Y.Z tag is pushed (the tag-on-merge release.yml cuts it).
# This crate is a VERSIONED crates.io dependency of its consumers (dig-node, dig-dns, dig-updater),
# NOT a git dep — per the dig_ecosystem #681 no-git-deps policy. Requires the CARGO_REGISTRY_TOKEN
# repo secret (a crates.io API token); the job fails fast + explains if it is not set.
name: Publish to crates.io
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g., v0.1.0)'
required: true
type: string
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt, clippy
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all -- --check
- name: Check clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run tests
run: cargo test --all-features -- --test-threads=1
- name: Check documentation
run: cargo doc --no-deps --all-features
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
needs: test
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Verify the crate builds + packages
run: |
cargo build --release
cargo package --allow-dirty
- name: Require CARGO_REGISTRY_TOKEN
run: |
if [ -z "${{ secrets.CARGO_REGISTRY_TOKEN }}" ]; then
echo "::error::CARGO_REGISTRY_TOKEN is not set. Create a crates.io API token and add it"
echo "as the CARGO_REGISTRY_TOKEN repository secret to enable publishing."
exit 1
fi
- name: Publish to crates.io
run: cargo publish --allow-dirty --token "${{ secrets.CARGO_REGISTRY_TOKEN }}"