-
Notifications
You must be signed in to change notification settings - Fork 86
155 lines (132 loc) · 4.22 KB
/
build.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Build
on:
push:
pull_request:
jobs:
build:
timeout-minutes: 10
strategy:
matrix:
include:
# native stable
- name: 'stable linux'
os: 'ubuntu-latest'
target: 'x86_64-unknown-linux-gnu'
rust_version: 'stable'
- name: 'stable mac'
os: 'macos-latest'
target: 'x86_64-apple-darwin'
rust_version: 'stable'
- name: 'stable windows'
os: 'windows-latest'
target: 'x86_64-pc-windows-msvc'
rust_version: 'stable'
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}
steps:
- name: checkout repo
uses: actions/checkout@v2
- name: load cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ matrix.os }}-${{ matrix.target }}-${{ matrix.rust_version }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.target }}-${{ matrix.rust_version }}-cargo-
- name: install rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust_version }}
target: ${{ matrix.target }}
profile: minimal
components: clippy
default: true
- name: check
uses: actions-rs/cargo@v1
with:
command: clippy
args: --target ${{ matrix.target }} -- -D warnings
- name: build
uses: actions-rs/cargo@v1
with:
command: build
args: --target ${{ matrix.target }}
- name: doc
uses: actions-rs/cargo@v1
env:
RUSTDOCFLAGS: -D warnings
with:
command: doc
args: --no-deps --target ${{ matrix.target }}
cargo-fmt:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v2
- name: install rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
components: rustfmt
default: true
- name: check format
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
cargo-deny:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v2
- name: check denies
uses: EmbarkStudios/cargo-deny-action@v1
with:
log-level: warn
command: check
arguments: --all-features
publish:
runs-on: ubuntu-latest
needs: ['build', 'cargo-fmt', 'cargo-deny']
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
steps:
- name: checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: install cargo-release
run: |
curl -LsSf https://github.com/crate-ci/cargo-release/releases/download/v0.21.0/cargo-release-v0.21.0-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ${CARGO_HOME:-~/.cargo}/bin
- name: release to crates.io
run: |
git config user.name "releasebot"
git config user.email "actions@users.noreply.github.com"
git checkout master
cargo login ${{ secrets.CRATES_TOKEN }}
cargo release --no-confirm --execute $( echo '${{ github.ref }}' | sed 's?refs/tags/v??' )
- name: generate release notes
id: notes
run: |
NOTES=$(python -c 'import re; print(re.search("## v\\d+.\\d+.\\d+\n\nReleased \\d+-\\d+-\\d+\n\n((?:[\n]|.)*?)(?=## [vD])", open("CHANGELOG.md", "r").read()).group(1).strip().replace("%", "%25").replace("\n", "%0A"))')
echo "::set-output name=notes::$NOTES"
- name: release to github
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ${{ steps.notes.outputs.notes }}
draft: false
prerelease: false