-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (144 loc) · 4.77 KB
/
Copy pathrust.yml
File metadata and controls
169 lines (144 loc) · 4.77 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
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
name: Main
on:
push:
permissions:
actions: write
checks: write
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
lint-audit:
name: Lint and vulnerability audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: swatinem/rust-cache@v2
- name: Format check
run: cargo fmt --check
- name: Clippy
run: cargo clippy --all-targets --verbose -- -D warnings
- name: Install cargo-audit
run: cargo install cargo-audit --locked
- name: Audit dependencies
run: cargo audit
build-test:
name: Build and test (${{ matrix.os }})
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: swatinem/rust-cache@v2
- name: Build
run: >
cargo build
--release
--verbose
env:
CARGO_TARGET_DIR: binaries/${{ matrix.os }}
- name: Run tests (without coverage)
if: matrix.os != 'ubuntu-latest'
run: >
cargo test
--verbose
- name: Run tests (with coverage)
if: matrix.os == 'ubuntu-latest'
run: >
cargo install cargo-tarpaulin
&& cargo tarpaulin
--verbose
--out Xml
--engine llvm
--skip-clean
- name: Upload coverage reports to Codecov
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v3
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: sysplot-${{ matrix.os }}
path: binaries/${{ matrix.os }}/release/sysplot${{ matrix.os == 'windows-latest' && '.exe' || '' }}
push-binaries:
name: Push binaries
runs-on: ubuntu-latest
needs: [build-test, lint-audit]
steps:
- uses: actions/checkout@v3
- uses: swatinem/rust-cache@v2
- uses: actions/download-artifact@v4
with:
name: sysplot-ubuntu-latest
path: binaries/ubuntu-latest/release
- uses: actions/download-artifact@v4
with:
name: sysplot-macos-latest
path: binaries/macos-latest/release
- uses: actions/download-artifact@v4
with:
name: sysplot-windows-latest
path: binaries/windows-latest/release
- name: Remove previously committed package files
run: git rm -rf --ignore-unmatch target/debian target/release/rpmbuild
- name: Install packaging tools
run: |
cargo install cargo-deb
sudo apt-get update
sudo apt-get install -y rpm
- name: Build .deb package
run: cargo deb
- name: Build .rpm package
run: |
cargo build --release
VERSION=$(grep '^version' Cargo.toml | head -1 | cut -d'"' -f2)
RPMTOP="$(pwd)/target/release/rpmbuild"
mkdir -p "$RPMTOP"/{SOURCES,SPECS,BUILD,RPMS,SRPMS,BUILDROOT}
STAGE=$(mktemp -d)
mkdir -p "$STAGE/sysplot-$VERSION/usr/bin"
cp target/release/sysplot "$STAGE/sysplot-$VERSION/usr/bin/"
tar czf "$RPMTOP/SOURCES/sysplot-$VERSION.tar.gz" -C "$STAGE" "sysplot-$VERSION"
sed -e "s/@@VERSION@@/$VERSION/" -e "s/@@RELEASE@@/1/" .rpm/sysplot.spec > "$RPMTOP/SPECS/sysplot.spec"
rpmbuild --define "_topdir $RPMTOP" -bb "$RPMTOP/SPECS/sysplot.spec"
- name: Commit and push
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add -f binaries/ubuntu-latest/release/sysplot
git add -f binaries/macos-latest/release/sysplot
git add -f binaries/windows-latest/release/sysplot.exe
git add -f target/debian/*.deb
git add -f target/release/rpmbuild/RPMS/x86_64/*.rpm
git commit -m 'uploading binaries and packages'
git push
release-please:
name: Execute release chores
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
needs: push-binaries
outputs:
created: ${{ steps.release.outputs.release_created }}
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: rust
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
needs: release-please
if: needs.release-please.outputs.created
steps:
- uses: actions/checkout@v3
- uses: swatinem/rust-cache@v2
- name: Publish
# https://doc.rust-lang.org/cargo/reference/config.html?highlight=CARGO_REGISTRY_TOKEN#credentials
run: >
cargo publish
--verbose
--locked
--token ${{ secrets.CARGO_REGISTRY_TOKEN }}