-
-
Notifications
You must be signed in to change notification settings - Fork 37
112 lines (104 loc) · 4.07 KB
/
build-package.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
name: build-package
on:
push:
tags:
- 'v*'
jobs:
release:
name: Release - ${{ matrix.platform.release_for }}
if: startsWith(github.ref, 'refs/tags/v')
strategy:
fail-fast: false
matrix:
platform:
- release_for: Linux-x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
suffix: linux_amd64.bin
toolchain: stable
- release_for: Windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
suffix: windows_amd64.exe
toolchain: stable
- release_for: Linux-x86_64-musl
os: ubuntu-latest
target: x86_64-unknown-linux-musl
suffix: linux_x86_64_musl.bin
toolchain: stable
- release_for: Linux-armv7
os: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
suffix: linux_armv7_gnueabihf.bin
toolchain: stable
- release_for: Linux-aarch64
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
suffix: linux_aarch64.bin
toolchain: stable
# Disabled until corss release a new version
# https://github.com/cross-rs/cross/issues/1222
#
#- release_for: Android-aarch64
# os: ubuntu-latest
# target: aarch64-linux-android
# suffix: linux_aarch64_android.bin
# toolchain: stable
runs-on: ${{ matrix.platform.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup cache
uses: Swatinem/rust-cache@v2
- name: Install musl-tools
if: contains(matrix.platform.target, 'linux-musl')
run: sudo apt install musl-tools
- name: Install RPM tools
if: contains(matrix.platform.target, 'linux-gnu')
run: sudo apt-get install rpm
- name: Install aarch64 binutils
if: matrix.platform.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get install binutils-aarch64-linux-gnu build-essential crossbuild-essential-arm64 pkg-config libc6-arm64-cross libgcc1-arm64-cross libstdc++6-arm64-cross
sudo dpkg --add-architecture arm64
- name: Build
uses: houseabsolute/actions-rust-cross@v0
with:
command: build
target: ${{ matrix.platform.target }}
toolchain: ${{ matrix.platform.toolchain }}
args: --release
strip: yes
- name: Packaging for Debian - x84_64
if: matrix.platform.target == 'x86_64-unknown-linux-gnu'
run: |
cargo install cargo-deb
cargo deb --target=${{ matrix.platform.target }} --no-build
- name: Packaging for Debian - aarch64
if: matrix.platform.target == 'aarch64-unknown-linux-gnu'
run: |
cargo install cargo-deb
cargo deb --target=${{ matrix.platform.target }} --no-build --no-strip
- name: Packaging for RPM - x86_64
if: matrix.platform.target == 'x86_64-unknown-linux-gnu'
run: |
cargo install cargo-generate-rpm
cargo generate-rpm --target=${{ matrix.platform.target }}
- name: Packaging for RPM - aarch64
if: matrix.platform.target == 'aarch64-unknown-linux-gnu'
run: |
cargo install cargo-generate-rpm
cargo generate-rpm --target=${{ matrix.platform.target }}
- name: Packaging binary for Linux
if: contains(matrix.platform.os, 'ubuntu')
run: xz -kfS "_${GITHUB_REF#*/v}_${{ matrix.platform.suffix }}.xz" target/${{ matrix.platform.target }}/release/moproxy
- name: Packaging binary for Windows
if: contains(matrix.platform.os, 'windows')
run: xz -kf target/${{ matrix.platform.target }}/release/moproxy.exe > "moproxy_${GITHUB_REF#*/v}_${{ matrix.platform.suffix }}.xz"
- name: Release
uses: ncipollo/release-action@v1
with:
artifacts: "*.xz,target/**/*.xz,target/**/*.deb,target/**/*.rpm"
draft: true
allowUpdates: true
updateOnlyUnreleased: true