-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (111 loc) · 3.65 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
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
name: Rust
on:
push:
branches: [main]
tags:
- v[0-9]*
pull_request:
branches: [main]
jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install stable toolchain
id: toolchain
uses: dtolnay/rust-toolchain@stable
- run: rustup override set ${{steps.toolchain.outputs.name}}
- run: rustup component add rustfmt
- name: Run cargo fmt
run: cargo fmt --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Update apt
run: sudo apt update
- name: Install alsa
run: sudo apt-get install -y libasound2-dev
- name: Install stable toolchain
id: toolchain
uses: dtolnay/rust-toolchain@stable
- run: rustup override set ${{steps.toolchain.outputs.name}}
- run: rustup component add clippy
- uses: clechasseur/rs-clippy-check@v3
with:
args: --all-features -- --deny warnings
build:
strategy:
fail-fast: false
matrix:
job:
- { target: x86_64-apple-darwin, os: macos-13 }
# use ubuntu 20.04 to keep minimum glibc version to 2.31
- { target: x86_64-unknown-linux-gnu, os: ubuntu-20.04 }
name: ${{ matrix.job.target }} (${{ matrix.job.os }})
runs-on: ${{ matrix.job.os }}
steps:
- uses: actions/checkout@v4
- name: Install dependencies
shell: bash
run: |
case ${{ matrix.job.target }} in
x86_64-unknown-linux-gnu) sudo apt install -y libasound2-dev;;
esac
- uses: Swatinem/rust-cache@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.job.target }}
override: true
- name: Build
shell: bash
run: cargo build --verbose
- name: Run tests
shell: bash
run: cargo test --verbose
- name: Extract crate information
shell: bash
run: |
echo "PROJECT_NAME=timer" >> $GITHUB_ENV
echo "PROJECT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' ./Cargo.toml | head -n1)" >> $GITHUB_ENV
- name: Make release
id: package
shell: bash
run: |
export CARGO_TARGET=${{ matrix.job.target }}
export PKG_BASE_NAME=${PROJECT_NAME}-${PROJECT_VERSION}-${CARGO_TARGET}
make release
echo "::set-output name=PKG_BASE_NAME::${PKG_BASE_NAME}"
- name: Publish crates
if: startsWith(github.ref, 'refs/tags/') && matrix.job.target == 'x86_64-unknown-linux-gnu'
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
shell: bash
run: |
cargo login "${CRATES_IO_TOKEN}"
make publish
- name: Get Changelog Entry
if: startsWith(github.ref, 'refs/tags/')
id: changelog_reader
uses: mindsers/[email protected]
with:
version: v${{ env.PROJECT_VERSION }}
path: ./CHANGELOG.md
- name: Publish
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
body: ${{ steps.changelog_reader.outputs.changes }}
prerelease: ${{ steps.changelog_reader.outputs.status == 'prereleased' }}
draft: ${{ steps.changelog_reader.outputs.status == 'unreleased' }}
files: |
${{ steps.package.outputs.PKG_BASE_NAME }}.tar.gz
vendor.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}