-
-
Notifications
You must be signed in to change notification settings - Fork 6
79 lines (70 loc) · 1.94 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
name: Rust
on:
push:
branches: [main, "*.x"]
pull_request:
release:
types: [created]
env:
RUST_BACKTRACE: "1"
RUST_LOG: "info"
# speed up build by using clang/lld
CC: "clang-14"
CXX: "clang++-14"
LD: "clang-14"
LDFLAGS: "-fuse-ld=lld-14"
RUSTFLAGS: "-C linker=clang-14 -C link-arg=-fuse-ld=lld-14"
jobs:
test:
strategy:
fail-fast: false
matrix:
rust:
- toolchain: "stable"
- toolchain: "nightly"
name: "Test (Rust ${{matrix.rust.toolchain}})"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: "${{matrix.rust.toolchain}}"
id: "rust-toolchain"
- uses: actions/cache@v3
with:
path: |
~/.cargo/git
~/.cargo/registry
target
key: "${{runner.os}} Rust ${{steps.rust-toolchain.outputs.cachekey}}"
- run: cargo test
- name: cargo run
run: |
cargo run -- --bin
git diff --exit-code README.md
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: ./rustfmt.sh --check
docker:
runs-on: ubuntu-latest
needs: [test]
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3
- name: Log In at ghcr.io
run: echo "${{secrets.GITHUB_TOKEN}}" | docker login ghcr.io -u msrd0 --password-stdin
- name: Build and Push image to ghcr.io
run: |
image="ghcr.io/msrd0/cargo-doc2readme"
tag="$image:$(git describe --tags)"
echo "==> Building docker image"
docker build . --pull --tag "$image"
docker tag "$image" "$tag"
echo "==> Pushing docker image"
docker push "$tag"
docker push "$image"