forked from YetAnotherMechanicusEnjoyer/vimcord
-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (84 loc) · 2.55 KB
/
rust.yml
File metadata and controls
104 lines (84 loc) · 2.55 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
name: Rust CI/CD
run-name: Rust CI/CD | ${{ github.event_name }} by ${{ github.actor }} on '${{ github.ref_name }}'
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
branches:
- main
- dev
pull_request:
branches:
- main
jobs:
ci:
name: Rust CI
runs-on: ubuntu-latest
defaults:
run:
working-directory: .
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache Cargo Dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy, rustfmt
- name: Run cargo-deny checks
uses: EmbarkStudios/cargo-deny-action@v1
with:
command: "check bans sources"
manifest-path: "./Cargo.toml"
rust-version: "1.88.0"
- name: Pre-build project
run: cargo build
- name: Check formatting
run: cargo fmt --check
- name: Lint with Clippy
run: cargo clippy -- -D warnings
- name: Run Tests
run: cargo test
publish-cargo:
name: Publishing to Cargo
runs-on: ubuntu-22.04
if: startsWith(github.ref, 'refs/tags/')
needs: [ci]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install cargo-edit
run: cargo install cargo-edit
- name: Extract Git Tag version
id: version_extract
run: |
TAG_NAME=${{ github.ref_name }}
VERSION_NUMBER=$(echo $TAG_NAME | sed 's/^v//')
echo "VERSION=$VERSION_NUMBER" >> $GITHUB_OUTPUT
shell: bash
- name: Update Cargo.toml version
run: cargo set-version ${{ steps.version_extract.outputs.VERSION }}
- name: Configure Git User
run: |
git config user.email "servoskull@omnissiah.mars"
git config user.name "Servo Skull"
- name: Commit version
run: |
git add Cargo.toml
git commit -m "[RELEASE] Bump version to ${{ steps.version_extract.outputs.VERSION }} before publishing" && git push || exit 0
- run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }}