Skip to content
This repository was archived by the owner on Mar 24, 2024. It is now read-only.

Commit 5912d1d

Browse files
committed
use matrix for all builds
Added the cross-compilation builds to the main matrix for less duplication. Added installation of cross-compiler and configuration of linker for linux cross-compilation target.
1 parent fb98e0f commit 5912d1d

File tree

1 file changed

+52
-75
lines changed

1 file changed

+52
-75
lines changed

.github/workflows/release.yml

Lines changed: 52 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,35 @@ on:
55
- "v*"
66

77
jobs:
8-
release-amd64:
8+
create-release:
99
runs-on: ${{ matrix.os }}
1010

1111
strategy:
1212
matrix:
13-
os: [ubuntu-latest, macos-latest, windows-latest]
13+
include:
14+
- build: linux-amd64
15+
os: ubuntu-latest
16+
cross: false
17+
18+
- build: macos-amd64
19+
os: macos-latest
20+
cross: false
21+
22+
- build: windows-amd64
23+
os: windows-latest
24+
cross: false
25+
26+
- build: linux-aarch64
27+
os: ubuntu-latest
28+
cross: true
29+
linker-package: gcc-aarch64-linux-gnu
30+
linker: aarch64-linux-gnu-gcc
31+
target: aarch64-unknown-linux-gnu
32+
33+
- build: macos-aarch64
34+
os: macos-latest
35+
cross: true
36+
target: aarch64-apple-darwin
1437

1538
steps:
1639
- name: Checkout
@@ -20,18 +43,38 @@ jobs:
2043
id: version
2144
uses: damienaicheh/[email protected]
2245

46+
- name: Install cross-compiler
47+
if: matrix.os == 'ubuntu-latest' && matrix.cross
48+
run: |
49+
sudo apt update
50+
sudo apt install ${{ matrix.linker-package }}
51+
mkdir -p .cargo
52+
echo [target.${{ matrix.target }}] > .cargo/config.toml
53+
echo linker = '"'${{ matrix.linker }}'"' >> .cargo/config.toml
54+
2355
- name: Build
56+
if: "!matrix.cross"
2457
run: cargo build --release --verbose
2558

26-
- name: Archive executable (linux)
27-
if: matrix.os == 'ubuntu-latest'
28-
working-directory: ./target/release
29-
run: tar czvf ../../highlights-linux-amd64.tar.gz highlights
59+
- name: Build (linux cross)
60+
if: matrix.os == 'ubuntu-latest' && matrix.cross
61+
run: cargo build --release --verbose --target ${{ matrix.target }}
62+
env:
63+
CC: ${{ matrix.linker }}
3064

31-
- name: Archive executable (mac)
32-
if: matrix.os == 'macos-latest'
65+
- name: Build (mac cross)
66+
if: matrix.os == 'macos-latest' && matrix.cross
67+
run: cargo build --release --verbose --target ${{ matrix.target }}
68+
69+
- name: Archive executable
70+
if: matrix.os != 'windows-latest' && !matrix.cross
3371
working-directory: ./target/release
34-
run: tar czvf ../../highlights-macos-amd64.tar.gz highlights
72+
run: tar czvf ../../highlights-${{ matrix.build }}.tar.gz highlights
73+
74+
- name: Archive executable (cross)
75+
if: matrix.os != 'windows-latest' && matrix.cross
76+
working-directory: ./target/${{ matrix.target }}/release
77+
run: tar czvf ../../../highlights-${{ matrix.build }}.tar.gz highlights
3578

3679
- name: Archive executable (windows)
3780
if: matrix.os == 'windows-latest'
@@ -45,72 +88,6 @@ jobs:
4588
draft: true
4689
prerelease: ${{ env.PRE_RELEASE != ''}}
4790

48-
release-macos-aarch64:
49-
runs-on: macos-latest
50-
51-
steps:
52-
- name: Checkout
53-
uses: actions/checkout@v2
54-
55-
- name: Extract version from tag
56-
id: version
57-
uses: damienaicheh/[email protected]
58-
59-
- name: Install latest stable rust toolchain
60-
uses: actions-rs/toolchain@v1
61-
with:
62-
toolchain: stable
63-
target: aarch64-apple-darwin
64-
default: true
65-
override: true
66-
67-
- name: Build
68-
run: cargo build --release --target aarch64-apple-darwin --verbose
69-
70-
- name: Archive executable
71-
working-directory: ./target/aarch64-apple-darwin/release
72-
run: tar czvf ../../../highlights-macos-aarch64.tar.gz highlights
73-
74-
- name: Create release
75-
uses: softprops/action-gh-release@v1
76-
with:
77-
files: highlights-*
78-
draft: true
79-
prerelease: ${{ env.PRE_RELEASE != ''}}
80-
81-
release-linux-aarch64:
82-
runs-on: ubuntu-latest
83-
84-
steps:
85-
- name: Checkout
86-
uses: actions/checkout@v2
87-
88-
- name: Extract version from tag
89-
id: version
90-
uses: damienaicheh/[email protected]
91-
92-
- name: Install latest stable rust toolchain
93-
uses: actions-rs/toolchain@v1
94-
with:
95-
toolchain: stable
96-
target: aarch64-unknown-linux-gnu
97-
default: true
98-
override: true
99-
100-
- name: Build
101-
run: cargo build --release --target aarch64-unknown-linux-gnu --verbose
102-
103-
- name: Archive executable
104-
working-directory: ./target/aarch64-unknown-linux-gnu/release
105-
run: tar czvf ../../../highlights-linux-aarch64.tar.gz highlights
106-
107-
- name: Create release
108-
uses: softprops/action-gh-release@v1
109-
with:
110-
files: highlights-*
111-
draft: true
112-
prerelease: ${{ env.PRE_RELEASE != ''}}
113-
11491
release-docker:
11592
runs-on: ubuntu-latest
11693

0 commit comments

Comments
 (0)