-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (106 loc) · 2.94 KB
/
ci-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
name: ci
on:
pull_request:
types:
- opened
- synchronize
- reopened
push:
branches:
- master
tags:
- "[0-9]+.[0-9]+.[0-9]+*"
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --all -- --check
- run: cargo check
- run: cargo clippy -- -D warnings
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo build
release:
needs:
- build
- lint
- test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
include:
- os: macos-latest
target: x86_64-apple-darwin
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
- name: Get tag
id: tag
run: "echo ::set-output name=TAG::${GITHUB_REF##*/}"
- name: Build in release mode
uses: actions-rs/cargo@v1
with:
command: build
args: --release --all-features --target ${{ matrix.target }}
- name: Package the binary
run: >
tar cfz labelr-${{ steps.tag.outputs.TAG }}-${{ matrix.target }}.tar.gz
-C target/${{ matrix.target }}/release/
labelr
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: labelr-${{ steps.tag.outputs.TAG }}-${{ matrix.target }}.tar.gz
path: labelr-${{ steps.tag.outputs.TAG }}-${{ matrix.target }}.tar.gz
- name: Upload CHANGELOG.md
uses: actions/upload-artifact@v4
with:
name: CHANGELOG.md
path: CHANGELOG.md
if: matrix.os == 'ubuntu-latest'
publish:
needs:
- release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
path: CHANGELOG.md/CHANGELOG.md
- name: Publish the release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: ${{ steps.changelog_reader.outputs.changes }}