forked from Pumpkin-MC/Pumpkin
-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (163 loc) · 4.9 KB
/
rust.yml
File metadata and controls
169 lines (163 loc) · 4.9 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: Cargo Build, Test, and Linting
on:
push:
pull_request:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-Dwarnings"
jobs:
format:
name: Check formatting
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- stable
steps:
- uses: actions/checkout@v6
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: rustup component add rustfmt
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --check
machete:
name: Detect unused dependencies
runs-on: ubuntu-latest
needs: [format]
strategy:
matrix:
toolchain:
- stable
steps:
- uses: actions/checkout@v6
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- uses: bnjbvr/cargo-machete@main
clippy_debug:
name: Run lints (debug)
runs-on: ubuntu-latest
needs: [machete]
strategy:
matrix:
toolchain:
- stable
steps:
- uses: actions/checkout@v6
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: rustup component add clippy
- uses: Swatinem/rust-cache@v2
- name: Clippy (debug)
run: cargo clippy --all-targets --all-features
clippy_release:
name: Run lints (release)
runs-on: ubuntu-latest
needs: [machete]
strategy:
matrix:
toolchain:
- stable
steps:
- uses: actions/checkout@v6
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: rustup component add clippy
- uses: Swatinem/rust-cache@v2
- name: Clippy (release)
run: cargo clippy --release --all-targets --all-features
build_and_test:
name: Build project and test
runs-on: ${{ matrix.os }}
needs: [clippy_debug, clippy_release]
strategy:
matrix:
os:
[
ubuntu-latest,
ubuntu-24.04-arm,
windows-latest,
windows-11-arm,
macos-latest,
macos-15-intel,
]
toolchain:
- stable
steps:
- uses: actions/checkout@v6
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
- name: Cargo nextest
run: cargo nextest run --verbose
- name: Cargo doctest
run: cargo test --doc --verbose
build_release:
name: Build project in release
runs-on: ${{ matrix.os }}
needs: [build_and_test]
strategy:
matrix:
os:
[
ubuntu-latest,
ubuntu-24.04-arm,
windows-latest,
windows-11-arm,
macos-latest,
macos-15-intel,
]
toolchain:
- stable
steps:
- uses: actions/checkout@v6
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- uses: Swatinem/rust-cache@v2
- name: Build Release
shell: bash
run: |
if [[ "${{ runner.arch }}" == "X64" ]]; then
export RUSTFLAGS="$RUSTFLAGS -C target-cpu=x86-64-v3"
fi
cargo build --verbose --release
- name: Prepare artifacts
shell: bash
run: |
mkdir -p dist
if [ "${{ runner.os }}" == "Windows" ]; then EXT=".exe"; fi
cp "target/release/pumpkin$EXT" "dist/pumpkin-${{ runner.arch }}-${{ runner.os }}$EXT"
- name: Export executable
uses: actions/upload-artifact@v7
with:
name: pumpkin-${{ runner.arch }}-${{ runner.os }}
compression-level: 9
path: dist/pumpkin-*
draft_release:
permissions:
contents: write
needs: [build_release]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v6
- name: Download prebuilt binary artifacts
uses: actions/download-artifact@v8
with:
pattern: "**/pumpkin-*"
path: dist/
merge-multiple: true
- name: Generate release notes
run: |
tree dist/
echo "From commit: $(git rev-parse --short HEAD)" > dist/RELEASE.md
echo "Generated on: $(date -u +"%Y-%m-%d %H:%M") UTC" >> dist/RELEASE.md
cat dist/RELEASE.md
- name: Update the nightly tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag --force nightly && git push --force origin tag nightly
- name: Draft a nightly github release
uses: softprops/action-gh-release@v2
with:
prerelease: true
files: dist/pumpkin*
tag_name: nightly
name: Nightly Build
body_path: dist/RELEASE.md