-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (104 loc) · 3.06 KB
/
publish.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
name: publish
on:
release:
types: [published]
env:
CARGO_TERM_COLOR: always
permissions:
contents: write
jobs:
build-and-upload:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- build: linux-x86_64-musl
os: ubuntu-latest
target: x86_64-unknown-linux-musl
- build: linux-x86_64-gnu
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- build: macos-x86_64
os: macos-latest
target: x86_64-apple-darwin
- build: macos-aarch64
os: macos-latest
target: aarch64-apple-darwin
- build: windows-x86_64-gnu
os: windows-latest
target: x86_64-pc-windows-gnu
steps:
- uses: actions/checkout@v4
- name: Install Rust Tools
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
components: rustfmt, clippy, llvm-tools
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Format with rustfmt
run: |
make format-check
- name: Lint with clippy
run: |
make lint
- name: Test with llvm-cov
run: |
make test
- name: Get the release version from the tag
id: tag_version
shell: bash
run: |
echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> "$GITHUB_OUTPUT"
- name: Install musl-gcc
shell: bash
run: |
if [ "${{ matrix.target }}" = "x86_64-unknown-linux-musl" ]; then
sudo apt update
sudo apt install -y musl-tools
fi
- name: Build
run: |
cargo build --release --verbose --target ${{ matrix.target }}
- name: Build archive
shell: bash
run: |
# Replace with the name of your binary
binary_name="${{ github.event.repository.name }}"
dirname="$binary_name-${{ steps.tag_version.outputs.VERSION }}-${{ matrix.target }}"
mkdir "$dirname"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname"
else
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname"
fi
if [ "${{ matrix.os }}" = "windows-latest" ]; then
7z a "$dirname.zip" "$dirname"
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
else
tar -czf "$dirname.tar.gz" "$dirname"
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
fi
- name: Upload the binaries
uses: softprops/action-gh-release@v2
with:
files: |
${{ env.ASSET }}
Publish:
needs: build-and-upload
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Publish to Cargo
uses: actions-rs/cargo@v1
with:
command: publish
args: --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_API_KEY }}