-
Notifications
You must be signed in to change notification settings - Fork 2
99 lines (94 loc) · 2.84 KB
/
rust.yml
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
94
95
96
97
98
99
name: Rust
on:
push:
branches: ["main"]
pull_request:
env:
CARGO_TERM_COLOR: always
jobs:
build-and-test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt
- uses: peaceiris/actions-mdbook@v1
- name: format check
uses: actions-rs/cargo@v1
with:
command: fmt
args: --check
- name: cargo build
uses: actions-rs/cargo@v1
with:
command: build
# must run mdbook test right after `cargo build` or it fails to find the crate
- name: mdbook test
run: mdbook test chorus_book -L ./target/debug/deps
- name: cargo test
uses: actions-rs/cargo@v1
with:
command: test
publish-book:
runs-on: ubuntu-22.04
needs: ["build-and-test"]
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v3
- uses: peaceiris/actions-mdbook@v1
- run: mdbook build chorus_book
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: ./chorus_book/book
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
publish-crates:
runs-on: ubuntu-22.04
needs: ["build-and-test"]
environment:
name: crates-io
url: "https://crates.io/crates/chorus_lib"
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: salsify/action-detect-and-tag-new-version@v2
id: detect_and_tag
with:
# reading the version from `chorus_lib` but the value is from the root `Cargo.toml` and is used for all packages
version-command: "cargo read-manifest --manifest-path ./chorus_lib/Cargo.toml | jq -r .version"
- name: cargo publish (chorus_derive)
if: steps.detect_and_tag.outputs.tag
uses: actions-rs/cargo@v1
with:
command: publish
args: -p chorus_derive
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: cargo publish (chorus_lib)
if: steps.detect_and_tag.outputs.tag
uses: actions-rs/cargo@v1
with:
command: publish
args: -p chorus_lib
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Create GitHub Release
if: steps.detect_and_tag.outputs.tag
uses: softprops/action-gh-release@v1
with:
tag_name: ${{steps.detect_and_tag.outputs.tag}}