-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (84 loc) · 2.49 KB
/
release.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
name: Release
permissions:
contents: write
on:
push:
tags:
- "v*"
jobs:
build:
strategy:
matrix:
target:
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
include:
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
runs-on: ${{ matrix.os }}
outputs:
version: ${{ steps.properties.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
target: ${{ matrix.target }}
override: true
- name: Install arm64 toolchain
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- uses: Swatinem/rust-cache@v1
- name: Build release version
run: cargo build --verbose --release --target=${{ matrix.target }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.target }}
path: target/${{ matrix.target }}/release/main
release:
if: github.event_name != 'pull_request'
needs: [build]
runs-on: ubuntu-latest
outputs:
release-upload-url: ${{ steps.create-release.outputs.upload_url }}
steps:
- uses: actions/checkout@v4
- name: Create Release
id: create-release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
attach-assets-to-release:
strategy:
matrix:
target:
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
needs: [build, release]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: build-${{ matrix.target }}
path: build/
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.release-upload-url }}
asset_path: ./build/main
asset_name: main-${{ matrix.target }}
asset_content_type: binary/octet-stream