-
Notifications
You must be signed in to change notification settings - Fork 0
230 lines (223 loc) · 7.44 KB
/
publish.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# https://bl.ocks.org/PurpleBooth/84b3d7d6669f77d5a53801a258ed269a
name: lint, test and publish
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: '${{ runner.os }}-cargo-registry-${{ hashFiles(''**/Cargo.lock'') }}'
- uses: actions/cache@v1
with:
path: ~/.cargo/git
key: '${{ runner.os }}-cargo-index-${{ hashFiles(''**/Cargo.lock'') }}'
- uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Run check
run: cargo check
test:
runs-on: '${{ matrix.os }}'
strategy:
matrix:
include:
# TODO: fix it
# - os: macos-latest
- os: ubuntu-latest
- os: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: '${{ runner.os }}-cargo-registry-${{ hashFiles(''**/Cargo.lock'') }}'
- uses: actions/cache@v1
with:
path: ~/.cargo/git
key: '${{ runner.os }}-cargo-index-${{ hashFiles(''**/Cargo.lock'') }}'
- uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Run Test
run: cargo test --verbose
- name: Run Cargo Run
run: cargo run -- -h
lints:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: '${{ runner.os }}-cargo-registry-${{ hashFiles(''**/Cargo.lock'') }}'
- uses: actions/cache@v1
with:
path: ~/.cargo/git
key: '${{ runner.os }}-cargo-index-${{ hashFiles(''**/Cargo.lock'') }}'
- uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: 'rustfmt, clippy'
- name: Run cargo fmt
run: cargo fmt --all -- --check
- uses: actions-rs/cargo@v1
with:
command: clippy
args: '-- -D warnings'
version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
lfs: true
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- id: get_previous_version
run: echo ::set-output name=PREVIOUS_VERSION::$(git describe --tags "$(git rev-list --tags --max-count=1)")
shell: bash
- id: semvers
uses: WyriHaximus/github-action-next-semvers@master
with:
version: '${{ steps.get_previous_version.outputs.PREVIOUS_VERSION }}'
- run: mkdir -p ./version
- if: "!contains(github.event.head_commit.message, 'BC BREAK') && !contains(github.event.head_commit.message, 'Signed-off-by: dependabot-preview[bot] <[email protected]>')"
run: echo "$VERSION" >./version/version
env:
VERSION: ${{ steps.semvers.outputs.v_minor }}
- if: "contains(github.event.head_commit.message, 'Signed-off-by: dependabot-preview[bot] <[email protected]>')"
run: echo "$VERSION" >./version/version
env:
VERSION: ${{ steps.semvers.outputs.v_patch }}
- run: echo "$VERSION" > ./version/version
env:
VERSION: ${{ steps.semvers.outputs.v_major }}
if: "contains(github.event.head_commit.message, 'BC BREAK')"
- uses: actions/upload-artifact@master
with:
name: version
path: ./version/version
build:
needs:
- version
- lints
- test
- check
runs-on: '${{ matrix.os }}'
strategy:
matrix:
include:
- os: macos-latest
target: x86_64-apple-darwin
suffix: ''
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
suffix: ''
- os: windows-latest
target: x86_64-pc-windows-msvc
suffix: .exe
steps:
- uses: actions/checkout@master
with:
lfs: true
- id: get_repository_name
run: echo ::set-output name=REPOSITORY_NAME::$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")
shell: bash
- uses: actions/download-artifact@master
with:
name: version
- id: get_version
run: 'echo ::set-output "name=VERSION::$(cat ./version/version)"'
shell: bash
- uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: '${{ runner.os }}-cargo-registry-${{ hashFiles(''**/Cargo.lock'') }}'
- uses: actions/cache@v1
with:
path: ~/.cargo/git
key: '${{ runner.os }}-cargo-index-${{ hashFiles(''**/Cargo.lock'') }}'
- uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Install cargo cargo-bump
run: cargo install cargo-bump
- shell: bash
env:
VERSION: '${{ steps.get_version.outputs.VERSION }}'
run: cargo bump patch
- name: Cargo Build
env:
VERSION: '${{ steps.get_version.outputs.VERSION }}'
REPOSITORY_NAME: '${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}'
run: cargo build --release
# - uses: actions/upload-artifact@master
# with:
# name: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-${{ matrix.target }}
# path: ./target/release/${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}${{ matrix.suffix }}
# release:
# if: github.ref == 'refs/heads/main'
# needs:
# - build
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@master
# with:
# lfs: true
# - id: get_repository_name
# run: echo ::set-output name=REPOSITORY_NAME::$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")
# shell: bash
# - uses: actions/download-artifact@master
# with:
# name: version
# - id: get_version
# run: 'echo ::set-output name=VERSION::$(cat ./version/version)'
# shell: bash
# - uses: actions/download-artifact@master
# with:
# name: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-x86_64-unknown-linux-gnu
# - uses: actions/download-artifact@master
# with:
# name: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-x86_64-apple-darwin
# - uses: actions/download-artifact@master
# with:
# name: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-x86_64-pc-windows-msvc
# - name: Install cargo cargo-bump
# run: cargo install cargo-bump
# - shell: bash
# env:
# VERSION: '${{ steps.get_version.outputs.VERSION }}'
# run: cargo bump patch
# - uses: stefanzweifel/[email protected]
# with:
# commit_message: Bump cargo version
# branch: ${{ github.head_ref }}
# file_pattern: Cargo.toml
# push_options: '--force'
# - id: create_release
# uses: actions/[email protected]
# env:
# GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
# with:
# tag_name: '${{ steps.get_version.outputs.VERSION }}'
# release_name: 'Release ${{ steps.get_version.outputs.VERSION }}'
# draft: false
# prerelease: false
# - id: publish_cargo
# uses: katyo/publish-crates@v1
# with:
# registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}