-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (72 loc) · 2.58 KB
/
ci.yml
File metadata and controls
93 lines (72 loc) · 2.58 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
name: CI
on:
push:
branches:
- trunk
- main
tags:
- "core-v*"
workflow_dispatch:
inputs:
publish:
description: "Publish maple-render-core to crates.io"
required: false
default: false
type: boolean
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
CARGO_TARGET_DIR: target
jobs:
rust:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
targets: wasm32-unknown-unknown
- name: Cache Rust artifacts
uses: Swatinem/rust-cache@v2
- name: Format check
run: cargo fmt --all -- --check
- name: Clippy (root crate)
run: cargo clippy --locked --all-targets -- -D warnings
- name: Check root crate
run: cargo check --locked
- name: Test root crate
run: cargo test --locked --lib
- name: Check wasm exports
run: cargo check --locked --lib --target wasm32-unknown-unknown
- name: Check maple-render-core standalone crate
run: cargo check --manifest-path crates/maple-render-core/Cargo.toml
- name: Test maple-render-core standalone crate
run: cargo test --manifest-path crates/maple-render-core/Cargo.toml
- name: Verify maple-render-core publish dry-run
run: cargo publish --dry-run --allow-dirty --manifest-path crates/maple-render-core/Cargo.toml
publish-maple-render-core:
name: Publish maple-render-core
runs-on: ubuntu-latest
needs: rust
if: startsWith(github.ref, 'refs/tags/core-v') || (github.event_name == 'workflow_dispatch' && github.event.inputs.publish == 'true')
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust artifacts
uses: Swatinem/rust-cache@v2
- name: Validate tag matches crate version
if: startsWith(github.ref, 'refs/tags/core-v')
run: |
VERSION=$(grep '^version = ' crates/maple-render-core/Cargo.toml | head -n1 | cut -d '"' -f2)
TAG_VERSION="${GITHUB_REF_NAME#core-v}"
if [ "$VERSION" != "$TAG_VERSION" ]; then
echo "Tag version ($TAG_VERSION) does not match crate version ($VERSION)"
exit 1
fi
- name: Publish maple-render-core to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --manifest-path crates/maple-render-core/Cargo.toml --token "$CARGO_REGISTRY_TOKEN"