Skip to content

Commit a7ebb9e

Browse files
committed
fix build release ci, use rustls in favor of openssl
1 parent 7f59746 commit a7ebb9e

File tree

3 files changed

+164
-220
lines changed

3 files changed

+164
-220
lines changed

.github/workflows/release.yml

+82-42
Original file line numberDiff line numberDiff line change
@@ -4,68 +4,108 @@ on:
44
workflow_dispatch:
55
push:
66
tags:
7-
- "*"
7+
- 'v[0-9]+.[0-9]+.[0-9]+'
88

99
jobs:
1010
build:
11-
name: Build and publish release
12-
runs-on: ubuntu-latest
11+
name: Release for ${{ matrix.target }} on ${{ matrix.os }}
12+
runs-on: ${{ matrix.os }}
1313
strategy:
14-
fail-fast: false
1514
matrix:
15+
target:
16+
- x86_64-unknown-linux-gnu
17+
- x86_64-unknown-linux-musl
18+
- aarch64-unknown-linux-gnu
19+
- aarch64-unknown-linux-musl
20+
- x86_64-pc-windows-msvc
21+
- i686-pc-windows-msvc
22+
- x86_64-apple-darwin
23+
- aarch64-apple-darwin
24+
1625
include:
1726
- target: x86_64-unknown-linux-gnu
18-
name: bitsrun-x86_64-unknown-linux-gnu.tar.gz
19-
cross: false
20-
strip: true
27+
os: ubuntu-22.04
28+
target-apt-arch: amd64
2129
- target: x86_64-unknown-linux-musl
22-
name: bitsrun-x86_64-unknown-linux-musl.tar.gz
23-
cross: true
24-
strip: true
25-
- target: i686-unknown-linux-gnu
26-
name: bitsrun-i686-unknown-linux-gnu.tar.gz
27-
cross: true
28-
strip: true
29-
- target: i686-unknown-linux-musl
30-
name: bitsrun-i686-unknown-linux-musl.tar.gz
31-
cross: true
32-
strip: true
30+
os: ubuntu-22.04
31+
target-apt-arch: amd64
3332
- target: aarch64-unknown-linux-gnu
34-
name: bitsrun-aarch64-unknown-linux-gnu.tar.gz
35-
cross: true
36-
strip: false
33+
os: ubuntu-22.04
34+
target-apt-arch: arm64
3735
- target: aarch64-unknown-linux-musl
38-
name: bitsrun-aarch64-unknown-linux-musl.tar.gz
39-
cross: true
40-
strip: false
36+
os: ubuntu-22.04
37+
target-apt-arch: arm64
38+
- target: x86_64-pc-windows-msvc
39+
os: windows-latest
40+
- target: i686-pc-windows-msvc
41+
os: windows-latest
42+
- target: x86_64-apple-darwin
43+
os: macos-latest
44+
- target: aarch64-apple-darwin
45+
os: macos-latest
46+
47+
env:
48+
BIN_NAME: bitsrun
49+
CARGO_BUILD_TARGET: ${{ matrix.target }}
50+
ARCHIVE_NAME: bitsrun-${{ matrix.target }}
4151

4252
steps:
4353
- uses: actions/checkout@master
44-
- uses: dtolnay/rust-toolchain@stable
45-
with:
46-
target: ${{ matrix.target }}
4754

48-
- name: Build binaries
49-
uses: ClementTsang/cargo-action@v0.0.6
55+
- name: Set up Ubuntu multiarch
56+
if: startsWith(matrix.os, 'ubuntu') && matrix.target-apt-arch != 'amd64'
57+
run: |
58+
readonly DISTRO_CODENAME=jammy
59+
sudo dpkg --add-architecture "${{ matrix.target-apt-arch }}"
60+
sudo sed -i "s/^deb http/deb [arch=$(dpkg-architecture -q DEB_HOST_ARCH)] http/" /etc/apt/sources.list
61+
sudo sed -i "s/^deb mirror/deb [arch=$(dpkg-architecture -q DEB_HOST_ARCH)] mirror/" /etc/apt/sources.list
62+
for suite in '' '-updates' '-backports' '-security'; do
63+
echo "deb [arch=${{ matrix.target-apt-arch }}] http://ports.ubuntu.com/ $DISTRO_CODENAME$suite main universe multiverse" | \
64+
sudo tee -a /etc/apt/sources.list >/dev/null
65+
done
66+
67+
- name: Install musl development files
68+
if: endsWith(matrix.target, '-musl')
69+
run: |
70+
sudo apt-get -yq update
71+
sudo apt-get -yq install musl-tools musl-dev:${{ matrix.target-apt-arch }}
72+
73+
- name: Install QEMU and AArch64 cross compiler
74+
if: startsWith(matrix.target, 'aarch64-unknown-linux')
75+
run: |
76+
sudo apt-get -yq update
77+
# libc6 must be present to run executables dynamically linked
78+
# against glibc for the target architecture
79+
sudo apt-get -yq install qemu-user gcc-aarch64-linux-gnu libc6:arm64
80+
81+
- name: Install Rust toolchain
82+
uses: dtolnay/rust-toolchain@stable
5083
with:
51-
command: build
52-
args: --release --target=${{ matrix.target }}
53-
use-cross: ${{ matrix.cross }}
84+
target: ${{ env.CARGO_BUILD_TARGET }}
5485

55-
- name: Strip binaries
56-
run: strip target/${{ matrix.target }}/release/bitsrun
57-
if: ${{ matrix.strip }}
86+
- name: Build binary
87+
run: cargo build --release
5888

59-
- name: Package binaries
89+
- name: Package binary archives
6090
run: |
61-
cd target/${{ matrix.target }}/release
62-
tar -czvf ${{ matrix.name }} bitsrun
63-
cd -
91+
mkdir "${{ env.ARCHIVE_NAME }}"
92+
93+
case '${{ matrix.target }}' in
94+
*-windows-*)
95+
cp target/${{ env.CARGO_BUILD_TARGET }}/release/${{ env.BIN_NAME }}.exe "${{ env.ARCHIVE_NAME }}"
96+
zip "${{ env.ARCHIVE_NAME }}.zip" "${{ env.ARCHIVE_NAME }}"/*;;
97+
*)
98+
cp target/${{ env.CARGO_BUILD_TARGET }}/release/${{ env.BIN_NAME }} "${{ env.ARCHIVE_NAME }}"
99+
chmod ugo+x "${{ env.ARCHIVE_NAME }}/${{ env.BIN_NAME }}"
100+
tar -vczf "${{ env.ARCHIVE_NAME }}.tar.gz" "${{ env.ARCHIVE_NAME }}"/*;;
101+
esac
102+
103+
ls
64104
65-
- name: Upload binaries to release
105+
- name: Upload binary for release
66106
uses: svenstaro/upload-release-action@v2
67107
with:
68108
repo_token: ${{ secrets.GITHUB_TOKEN }}
69-
file: target/${{ matrix.target }}/release/${{ matrix.name }}
70-
asset_name: ${{ matrix.name }}
109+
file: ${{ env.ARCHIVE_NAME }}${{ endsWith(env.CARGO_BUILD_TARGET, '-windows-msvc') && '.zip' || '.tar.gz'}}
110+
asset_name: ${{env.ARCHIVE_NAME}}-${{ github.ref }}-${{ endsWith(env.CARGO_BUILD_TARGET, '-windows-msvc') && '.zip' || '.tar.gz'}}
71111
tag: ${{ github.ref }}

0 commit comments

Comments
 (0)