Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.

Commit 3c3d539

Browse files
committed
github: add release ci
1 parent d75acb7 commit 3c3d539

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

.github/workflows/release.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
on:
2+
push:
3+
tags:
4+
- 'v*'
5+
6+
env:
7+
project: 'matm'
8+
9+
jobs:
10+
test:
11+
strategy:
12+
matrix:
13+
include:
14+
- target: x86_64-unknown-linux-gnu
15+
os: ubuntu-latest
16+
- target: x86_64-pc-windows-msvc
17+
os: windows-latest
18+
19+
runs-on: ${{ matrix.os }}
20+
steps:
21+
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Toolchain
26+
uses: actions-rs/toolchain@v1
27+
with:
28+
profile: minimal
29+
toolchain: stable
30+
target: ${{ matrix.target }}
31+
override: true
32+
33+
- name: Cache Rustup
34+
uses: actions/cache@v4
35+
with:
36+
path: |
37+
~/.rustup/settings.toml
38+
~/.rustup/toolchains/${{ matrix.target }}-*
39+
~/.rustup/update-hashes/${{ matrix.target }}-*
40+
key: run-toolchain-rust_${{ matrix.target }}
41+
42+
- name: Cache Cargo
43+
uses: actions/cache@v4
44+
with:
45+
path: |
46+
~/.cargo/registry
47+
~/.cargo/git
48+
target
49+
key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
50+
51+
- name: Build
52+
uses: actions-rs/cargo@v1
53+
with:
54+
use-cross: true
55+
command: build
56+
args: --release --target=${{ matrix.target }}
57+
58+
- name: Test
59+
uses: actions-rs/cargo@v1
60+
with:
61+
use-cross: true
62+
command: test
63+
64+
- name: Upload
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: ${{ env.project }}_${{ matrix.target }}
68+
path: |
69+
./target/${{ matrix.target }}/release/${{ env.project }}
70+
./target/${{ matrix.target }}/release/${{ env.project }}.exe
71+
72+
release:
73+
needs: [ test ]
74+
runs-on: ubuntu-latest
75+
steps:
76+
77+
- name: Download
78+
uses: actions/download-artifact@v4
79+
with:
80+
path: artifacts
81+
82+
83+
- name: Archives
84+
run: |
85+
for dir in $(find artifacts -mindepth 1 -maxdepth 1 -type d); do
86+
file=$(ls "$dir")
87+
chmod +x "$dir/$file"
88+
tar -czvf "$dir.tar.gz" -C "$dir" "$file"
89+
done
90+
91+
- name: Release
92+
uses: softprops/action-gh-release@v2
93+
with:
94+
files: |
95+
artifacts/*.tar.gz
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.PAT }}

0 commit comments

Comments
 (0)