-
Notifications
You must be signed in to change notification settings - Fork 4
152 lines (125 loc) · 4.35 KB
/
test-lint-release.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
name: Test/Lint/Release
permissions:
contents: write
on:
pull_request:
push:
branches:
- main
jobs:
clippy:
if: ${{ !startsWith(github.event.head_commit.message, 'tag') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable-2023-07-13 # Fixed so that it can be cached
profile: minimal
components: clippy
override: true
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Clippy
run: cargo clippy --all
test:
if: ${{ !startsWith(github.event.head_commit.message, 'tag') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable-2023-07-13 # Fixed so that it can be cached
override: true
components: llvm-tools-preview
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Install Grcov
run: cargo install grcov
- name: Run tests
run: cargo test --all --no-fail-fast
env:
RUSTFLAGS: '-C instrument-coverage'
LLVM_PROFILE_FILE: 'report-%p-%m.profraw'
- name: Run grcov
run: grcov . --binary-path target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore 'target/**' --ignore '../**' --ignore '/*' -o coverage.lcov
- name: Coveralls upload
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: coverage.lcov
release:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- test
- clippy
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0' # https://github.com/actions/checkout/issues/217
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable-2023-07-13 # Fixed so that it can be cached
profile: minimal
- name: Cache
uses: Swatinem/rust-cache@v2
- uses: korandoru/setup-zig@v1
with:
zig-version: 0.10.0
- name: Install bump tool
run: cargo install cargo-workspaces cargo-zigbuild
- name: Bump versions
run: |
SEM_VER=$(.github/semver.sh)
cargo workspaces version $SEM_VER -a -y --force '*' --no-git-commit
- name: Compile for x86_64-unknown-linux-gnu
run: |
rustup target add x86_64-unknown-linux-gnu
cargo zigbuild --target x86_64-unknown-linux-gnu --release
mkdir -p target/linux/amd64/release/
mv target/x86_64-unknown-linux-gnu/release/signway target/linux/amd64/release/signway
- name: Compile for aarch64-unknown-linux-gnu
run: |
rustup target add aarch64-unknown-linux-gnu
cargo zigbuild --target aarch64-unknown-linux-gnu --release
mkdir -p target/linux/arm64/release/
mv target/aarch64-unknown-linux-gnu/release/signway target/linux/arm64/release/signway
- name: Tag
id: tag
run: |
version=`grep '^version = ' Cargo.toml | sed 's/version = //; s/\"//; s/\"//'`
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "tag: v$version"
git tag "v$version"
git push
git push --tags
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Release
run: gh release create "v${{ steps.tag.outputs.version }}"
env:
GH_TOKEN: ${{ github.token }}
- name: Publish
run: cargo publish -p signway-server
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: gabotechs
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- uses: docker/build-push-action@v4
with:
context: .
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
tags: gabotechs/signway:${{ steps.tag.outputs.version }},gabotechs/signway:latest