-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (85 loc) · 3.85 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
93
94
95
96
97
98
99
100
101
102
103
104
name: CI
on:
push:
branches:
- master
release:
types: [released]
pull_request:
branches:
- master
jobs:
build:
name: Build and Release
permissions:
contents: write
env:
APP_NAME: hello_world
strategy:
matrix:
target:
# Windows
- { displayName: 32-bit Windows,
rustTarget: i686-pc-windows-gnu,
runner: 'ubuntu-latest' }
- { displayName: 64-bit Windows,
rustTarget: x86_64-pc-windows-gnu,
runner: 'ubuntu-latest' }
# Linux
- { displayName: 32-bit Linux,
rustTarget: i686-unknown-linux-gnu,
runner: 'ubuntu-latest' }
- { displayName: 64-bit Linux,
rustTarget: x86_64-unknown-linux-gnu,
runner: 'ubuntu-latest' }
- { displayName: ARM32 ARMv6 Linux,
rustTarget: arm-unknown-linux-gnueabi,
runner: 'ubuntu-latest' }
- { displayName: ARM32 ARMv7 Linux,
rustTarget: armv7-unknown-linux-gnueabihf,
runner: 'ubuntu-latest' }
- { displayName: ARM64 Linux,
rustTarget: aarch64-unknown-linux-gnu,
runner: 'ubuntu-latest' }
# macOS
- { displayName: 64-bit macOS,
rustTarget: x86_64-apple-darwin,
runner: 'macos-latest' }
runs-on: ${{ matrix.target.runner }}
steps:
# Get the machine ready to build
- name: Checkout Code
uses: actions/checkout@v4
- name: Add Rust Target
run: rustup target add ${{ matrix.target.rustTarget }}
- name: Update Sources
if: ${{ contains(matrix.target.rustTarget, 'linux') }}
run: sudo apt update
- name: Add Windows Build Dependencies
if: ${{ contains(matrix.target.rustTarget, 'pc-windows') }}
run: sudo apt install -y gcc-mingw-w64
- name: Add ARM32 Build Dependencies
if: ${{ contains(matrix.target.rustTarget, 'arm') }}
run: sudo apt install -y gcc-arm-linux-gnueabihf gcc-arm-linux-gnueabi gcc-arm-none-eabi binutils-arm-linux-gnueabi
- name: Add ARM64 Build Dependencies
if: ${{ contains(matrix.target.rustTarget, 'aarch64') }}
run: sudo apt install -y gcc-aarch64-linux-gnu crossbuild-essential-arm64
- name: Add 32-bit Linux Build Dependencies
if: ${{ contains(matrix.target.rustTarget, 'i686-unknown-linux-gnu') }}
run: sudo apt install -y gcc-multilib
# Build time
- name: Build
run: cargo build --release --target ${{ matrix.target.rustTarget }}
- name: Upload Asset
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}-${{ matrix.target.rustTarget }}${{ endsWith(matrix.target.rustTarget, '-windows-gnu') && '.exe' || '' }}
path: ./target/${{ matrix.target.rustTarget }}/release/${{ env.APP_NAME }}${{ endsWith(matrix.target.rustTarget, '-windows-gnu') && '.exe' || '' }}
- name: Upload Release Asset
if: github.event_name == 'release'
id: upload-release-asset
env:
GH_TOKEN: ${{ github.token }}
run: |
cp ./target/${{ matrix.target.rustTarget }}/release/${{ env.APP_NAME }}${{ endsWith(matrix.target.rustTarget, '-windows-gnu') && '.exe' || '' }} ./${{ env.APP_NAME }}-${{ github.ref_name }}-${{ matrix.target.rustTarget }}${{ endsWith(matrix.target.rustTarget, '-windows-gnu') && '.exe' || '' }} &&
gh release upload ${{ github.event.release.tag_name }} ./${{ env.APP_NAME }}-${{ github.ref_name }}-${{ matrix.target.rustTarget }}${{ endsWith(matrix.target.rustTarget, '-windows-gnu') && '.exe' || '' }}#"${{ env.APP_NAME }}-${{ github.ref_name }}-${{ matrix.target.rustTarget }}${{ endsWith(matrix.target.rustTarget, '-windows-gnu') && '.exe' || '' }} (${{ matrix.target.displayName }})"