-
Notifications
You must be signed in to change notification settings - Fork 1
160 lines (132 loc) · 4.54 KB
/
ci.yml
File metadata and controls
160 lines (132 loc) · 4.54 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
name: "CI"
on:
push:
branches: [ "**" ]
tags-ignore: [ "**" ]
pull_request:
workflow_dispatch:
inputs:
release:
type: boolean
description: Publish Release
concurrency:
cancel-in-progress: true
group: ci-${{ github.event.pull_request.number || github.ref }}
jobs:
check:
name: Run checks
runs-on: ubuntu-latest
permissions:
checks: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt, clippy
- name: Run rustfmt
uses: clechasseur/rs-fmt-check@v3
- name: Run clippy
uses: clechasseur/rs-clippy-check@v5
test:
needs: [ "check" ]
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Initialize Rust caching
uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test --all-targets
build:
needs: [ "test" ]
permissions: read-all
runs-on: ${{ matrix.platform.os }}
name: Compile ${{ matrix.platform.target }} / ${{ matrix.platform.os }}
strategy:
fail-fast: true
matrix:
platform:
# mac target
- { os: 'macos-latest', target: 'x86_64-apple-darwin', arch: 'x86_64', osn: 'mac' }
- { os: 'macos-latest', target: 'aarch64-apple-darwin', arch: 'aarch64', osn: 'mac' }
# linux target
- { os: 'ubuntu-latest', target: 'x86_64-unknown-linux-musl', arch: 'x86_64', osn: 'linux' }
- { os: 'ubuntu-latest', target: 'aarch64-unknown-linux-musl', arch: 'aarch64', osn: 'linux' }
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.platform.target }}
- name: Initialize Rust caching
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.platform.target }}
- name: Compile Binary
uses: clechasseur/rs-cargo@v4
with:
tool: cross
command: build
args: --release --target ${{ matrix.platform.target }} --bin easycheck
- name: Move artifacts
run: |
mkdir -p artifact
cp target/${{ matrix.platform.target }}/release/easycheck artifact/easycheck_${{ matrix.platform.osn }}_${{ matrix.platform.arch }}
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
path: artifact/easycheck_${{ matrix.platform.osn }}_${{ matrix.platform.arch }}
name: easycheck_${{ matrix.platform.osn }}_${{ matrix.platform.arch }}
release:
needs: [ "check", "test", "build" ]
name: Publish Release
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.release == 'true' }}
permissions:
contents: write
pull-requests: read
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check version was bumped
run: |
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0")
if [ "$VERSION" = "$LATEST_TAG" ]; then
echo "::error::Cargo.toml version ($VERSION) matches latest tag. Bump the version before releasing."
exit 1
fi
echo "TAG_NAME=$VERSION" >> $GITHUB_ENV
- name: Download artifacts
uses: actions/download-artifact@v8
with:
path: binaries
- name: Generate changelog
id: changelog_generate
uses: mikepenz/release-changelog-builder-action@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
ignorePreReleases: true
toTag: ${{ github.sha }}
configurationJson: '{"max_tags_to_fetch":5,"categories":[],"template":"#{{UNCATEGORIZED}}","pr_template":"- #{{TITLE}} (##{{NUMBER}} by #{{AUTHOR}})"}'
- name: Create Release
uses: softprops/action-gh-release@v2
with:
draft: false
prerelease: false
tag_name: ${{ env.TAG_NAME }}
body: ${{steps.changelog_generate.outputs.changelog}}
fail_on_unmatched_files: true
files: |
binaries/*/*