Skip to content

Commit 8a97dbe

Browse files
Merge pull request #80 from Entrolution/ci/publish-workflow
Add tag-triggered crates.io publish workflow
2 parents 15c5ff5 + 9606e62 commit 8a97dbe

5 files changed

Lines changed: 151 additions & 11 deletions

File tree

.github/workflows/publish.yml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags: ['v*']
6+
7+
env:
8+
CARGO_TERM_COLOR: always
9+
RUST_BACKTRACE: 1
10+
11+
jobs:
12+
ci:
13+
name: CI
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v6
17+
18+
- name: Install Rust
19+
uses: dtolnay/rust-toolchain@stable
20+
with:
21+
components: rustfmt, clippy
22+
23+
- name: Cache cargo
24+
uses: Swatinem/rust-cache@v2
25+
26+
- name: Check formatting
27+
run: cargo fmt --all -- --check
28+
29+
- name: Build workspace
30+
run: cargo build --workspace --all-features
31+
32+
- name: Run tests
33+
run: cargo test --workspace --all-features
34+
35+
- name: Clippy
36+
run: cargo clippy --workspace --all-features -- -D warnings
37+
38+
- name: Build docs
39+
run: cargo doc --workspace --no-deps --all-features
40+
env:
41+
RUSTDOCFLAGS: -D warnings
42+
43+
- name: Install cargo-audit
44+
run: cargo install cargo-audit --locked || true
45+
46+
- name: Audit dependencies
47+
run: cargo audit --ignore RUSTSEC-2023-0071
48+
49+
- name: Install cargo-deny
50+
run: cargo install cargo-deny --locked || true
51+
52+
- name: Check dependency policies
53+
run: cargo deny check
54+
55+
publish:
56+
name: Publish to crates.io
57+
needs: [ci]
58+
runs-on: ubuntu-latest
59+
environment: release
60+
permissions:
61+
id-token: write
62+
contents: read
63+
steps:
64+
- uses: actions/checkout@v6
65+
66+
- name: Install Rust
67+
uses: dtolnay/rust-toolchain@stable
68+
69+
- name: Cache cargo
70+
uses: Swatinem/rust-cache@v2
71+
72+
- name: Validate tag matches Cargo.toml version
73+
run: |
74+
TAG="${GITHUB_REF#refs/tags/v}"
75+
CORE_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "cdx-core") | .version')
76+
CLI_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "cdx-cli") | .version')
77+
echo "Tag version: $TAG"
78+
echo "cdx-core version: $CORE_VERSION"
79+
echo "cdx-cli version: $CLI_VERSION"
80+
if [ "$TAG" != "$CORE_VERSION" ]; then
81+
echo "ERROR: Tag v$TAG does not match cdx-core version $CORE_VERSION"
82+
exit 1
83+
fi
84+
if [ "$TAG" != "$CLI_VERSION" ]; then
85+
echo "ERROR: Tag v$TAG does not match cdx-cli version $CLI_VERSION"
86+
exit 1
87+
fi
88+
89+
- name: Dry run cdx-core
90+
run: cargo publish --dry-run -p cdx-core
91+
92+
- name: Dry run cdx-cli
93+
run: cargo publish --dry-run -p cdx-cli
94+
95+
- name: Authenticate with crates.io
96+
uses: rust-lang/crates-io-auth-action@v1
97+
98+
- name: Publish cdx-core
99+
run: cargo publish -p cdx-core
100+
101+
- name: Wait for crates.io index update
102+
run: sleep 30
103+
104+
- name: Publish cdx-cli
105+
run: cargo publish -p cdx-cli
106+
107+
release:
108+
name: Create GitHub Release
109+
needs: [publish]
110+
runs-on: ubuntu-latest
111+
permissions:
112+
contents: write
113+
steps:
114+
- uses: actions/checkout@v6
115+
116+
- name: Extract changelog for this version
117+
id: changelog
118+
run: |
119+
TAG="${GITHUB_REF#refs/tags/v}"
120+
# Extract the section for this version from CHANGELOG.md
121+
# Matches from "## [X.Y.Z]" until the next "## [" or end of file
122+
CHANGELOG=$(awk -v ver="$TAG" '
123+
/^## \[/ {
124+
if (found) exit
125+
if ($0 ~ "\\[" ver "\\]") found=1
126+
next
127+
}
128+
found { print }
129+
' CHANGELOG.md)
130+
if [ -z "$CHANGELOG" ]; then
131+
CHANGELOG="Release v$TAG"
132+
fi
133+
# Write to file to avoid delimiter issues
134+
echo "$CHANGELOG" > /tmp/changelog.txt
135+
136+
- name: Create GitHub Release
137+
uses: softprops/action-gh-release@v2
138+
with:
139+
body_path: /tmp/changelog.txt
140+
generate_release_notes: false

CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ Initial release implementing Codex Document Format Specification v0.1.
243243
- `sign_document` - Sign a document with ES256
244244
- `extract_content` - Extract text content from blocks
245245

246-
[Unreleased]: https://github.com/gvonness-apolitical/cdx-core/compare/v0.3.0...HEAD
247-
[0.3.0]: https://github.com/gvonness-apolitical/cdx-core/compare/v0.2.0...v0.3.0
248-
[0.2.0]: https://github.com/gvonness-apolitical/cdx-core/compare/v0.1.0...v0.2.0
249-
[0.1.0]: https://github.com/gvonness-apolitical/cdx-core/releases/tag/v0.1.0
246+
[Unreleased]: https://github.com/Entrolution/cdx-core/compare/v0.3.0...HEAD
247+
[0.3.0]: https://github.com/Entrolution/cdx-core/compare/v0.2.0...v0.3.0
248+
[0.2.0]: https://github.com/Entrolution/cdx-core/compare/v0.1.0...v0.2.0
249+
[0.1.0]: https://github.com/Entrolution/cdx-core/releases/tag/v0.1.0

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ src/
142142

143143
## Specification Reference
144144

145-
This library implements the [Codex Document Format Specification](https://github.com/gvonness-apolitical/codex-file-format-spec). When implementing new features:
145+
This library implements the [Codex Document Format Specification](https://github.com/Entrolution/codex-file-format-spec). When implementing new features:
146146

147147
- Reference the relevant spec section
148148
- Note any deviations or extensions

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ resolver = "2"
77
edition = "2021"
88
rust-version = "1.88"
99
license = "MIT OR Apache-2.0"
10-
repository = "https://github.com/gvonness-apolitical/cdx-core"
10+
repository = "https://github.com/Entrolution/cdx-core"
1111

1212
[workspace.dependencies]
1313
# Shared dependencies across workspace
@@ -17,4 +17,4 @@ thiserror = "2.0"
1717
chrono = { version = "0.4", features = ["serde", "now"], default-features = false }
1818

1919
# Internal crates
20-
cdx-core = { path = "cdx-core" }
20+
cdx-core = { path = "cdx-core", version = "0.1.0" }

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
[![CI](https://github.com/gvonness-apolitical/cdx-core/actions/workflows/ci.yml/badge.svg)](https://github.com/gvonness-apolitical/cdx-core/actions/workflows/ci.yml)
2-
[![codecov](https://codecov.io/gh/gvonness-apolitical/cdx-core/graph/badge.svg)](https://codecov.io/gh/gvonness-apolitical/cdx-core)
1+
[![CI](https://github.com/Entrolution/cdx-core/actions/workflows/ci.yml/badge.svg)](https://github.com/Entrolution/cdx-core/actions/workflows/ci.yml)
2+
[![codecov](https://codecov.io/gh/Entrolution/cdx-core/graph/badge.svg)](https://codecov.io/gh/Entrolution/cdx-core)
33
[![Crates.io](https://img.shields.io/crates/v/cdx-core.svg)](https://crates.io/crates/cdx-core)
44
[![Documentation](https://docs.rs/cdx-core/badge.svg)](https://docs.rs/cdx-core)
55
[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)](LICENSE-MIT)
66
[![MSRV](https://img.shields.io/badge/MSRV-1.88-blue.svg)](https://www.rust-lang.org)
77

88
# cdx-core
99

10-
Core Rust library for reading, writing, and validating [Codex Document Format](https://github.com/gvonness-apolitical/codex-file-format-spec) (`.cdx`) files.
10+
Core Rust library for reading, writing, and validating [Codex Document Format](https://github.com/Entrolution/codex-file-format-spec) (`.cdx`) files.
1111

1212
## Overview
1313

@@ -161,7 +161,7 @@ cargo run --example open_and_verify path/to/document.cdx
161161

162162
## Specification Compliance
163163

164-
This library implements the [Codex Document Format Specification v0.1](https://github.com/gvonness-apolitical/codex-file-format-spec).
164+
This library implements the [Codex Document Format Specification v0.1](https://github.com/Entrolution/codex-file-format-spec).
165165

166166
### Module Status
167167

0 commit comments

Comments
 (0)