Skip to content

Commit 970259f

Browse files
committed
feat: update cross-compile to use houseabsolute/actions-rust-cross
1 parent cb75761 commit 970259f

File tree

3 files changed

+63
-78
lines changed

3 files changed

+63
-78
lines changed
Lines changed: 61 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# inspired by https://github.com/topheman/update-homebrew-tap-playground/blob/master/.github/workflows/cross-compile.yml
1+
# inspired by https://github.com/topheman/update-homebrew-tap-playground/blob/master/.github/workflows/cross-compile.yml# inspired by https://github.com/topheman/update-homebrew-tap-playground/blob/master/.github/workflows/cross-compile.yml
22
name: Cross-Compile
33

44
on: [push]
@@ -9,87 +9,70 @@ env:
99

1010
jobs:
1111
build:
12-
if: github.ref_type == 'tag'
13-
runs-on: ubuntu-latest
12+
name: Cross-Compile ${{ matrix.platform.target }}
13+
strategy:
14+
matrix:
15+
platform:
1416

17+
- runs-on: ubuntu-24.04
18+
target: x86_64-unknown-linux-gnu
19+
- runs-on: ubuntu-24.04-arm
20+
target: aarch64-unknown-linux-gnu
21+
- runs-on: macos-14
22+
target: x86_64-apple-darwin
23+
- runs-on: macos-14
24+
target: aarch64-apple-darwin
25+
runs-on: ${{ matrix.platform.runs-on }}
1526
steps:
16-
17-
- name: Set up MacOS Cross Compiler
18-
uses: Timmmm/setup-osxcross@v2
19-
with:
20-
osx-version: "12.3"
21-
22-
- name: Install Rustup targets
23-
run: rustup target add x86_64-unknown-linux-gnu x86_64-apple-darwin aarch64-apple-darwin
24-
25-
- name: Check out source code
26-
uses: actions/checkout@v4
27-
28-
- name: Check
29-
run: cargo check -p pluginlab
30-
31-
- name: Build
32-
run: cargo build -p pluginlab --release --target x86_64-unknown-linux-gnu --target x86_64-apple-darwin --target aarch64-apple-darwin
33-
34-
- name: Generate completions
35-
run: |
36-
mkdir -p ./target/x86_64-unknown-linux-gnu/release/completions/{zsh,bash,fish}
37-
./target/x86_64-unknown-linux-gnu/release/${{ env.BINARY_NAME }} generate-completions --shell zsh > ./target/x86_64-unknown-linux-gnu/release/completions/zsh/_${{ env.BINARY_NAME }}
38-
./target/x86_64-unknown-linux-gnu/release/${{ env.BINARY_NAME }} generate-completions --shell bash > ./target/x86_64-unknown-linux-gnu/release/completions/bash/${{ env.BINARY_NAME }}
39-
./target/x86_64-unknown-linux-gnu/release/${{ env.BINARY_NAME }} generate-completions --shell fish > ./target/x86_64-unknown-linux-gnu/release/completions/fish/${{ env.BINARY_NAME }}.fish
40-
41-
- name: Copy completions
42-
run: |
43-
cp -r ./target/x86_64-unknown-linux-gnu/release/completions ./target/x86_64-apple-darwin/release/completions
44-
cp -r ./target/x86_64-unknown-linux-gnu/release/completions ./target/aarch64-apple-darwin/release/completions
45-
46-
- name: Compress
47-
run: |
48-
rm -rf ./tmp
49-
mkdir ./tmp
50-
(cd target/x86_64-unknown-linux-gnu/release && tar -cvf ${{ env.BINARY_NAME }}-x86_64-unknown-linux-gnu.tar.gz ${{ env.BINARY_NAME }} completions && mv ${{ env.BINARY_NAME }}-x86_64-unknown-linux-gnu.tar.gz ../../../tmp)
51-
(cd target/x86_64-apple-darwin/release && tar -cvf ${{ env.BINARY_NAME }}-x86_64-apple-darwin.tar.gz ${{ env.BINARY_NAME }} completions && mv ${{ env.BINARY_NAME }}-x86_64-apple-darwin.tar.gz ../../../tmp)
52-
(cd target/aarch64-apple-darwin/release && tar -cvf ${{ env.BINARY_NAME }}-aarch64-apple-darwin.tar.gz ${{ env.BINARY_NAME }} completions && mv ${{ env.BINARY_NAME }}-aarch64-apple-darwin.tar.gz ../../../tmp)
53-
54-
- name: Calculate sha256
55-
run: |
56-
shasum -a 256 ./tmp/${{ env.BINARY_NAME }}-x86_64-unknown-linux-gnu.tar.gz >> ./tmp/sha256.txt
57-
shasum -a 256 ./tmp/${{ env.BINARY_NAME }}-x86_64-apple-darwin.tar.gz >> ./tmp/sha256.txt
58-
shasum -a 256 ./tmp/${{ env.BINARY_NAME }}-aarch64-apple-darwin.tar.gz >> ./tmp/sha256.txt
59-
- name: Cache
60-
if: github.ref_type == 'tag'
61-
id: cache-cross-compiled-artifacts
62-
uses: actions/cache@v4
63-
with:
64-
path: ./tmp
65-
key: ${{ runner.os }}-cross-compiled-artifacts-${{ github.sha }}
66-
67-
draft-release:
68-
if: github.ref_type == 'tag'
69-
permissions:
70-
contents: write
71-
runs-on: ubuntu-latest
27+
- name: Checkout source code
28+
uses: actions/checkout@v4
29+
- name: Build binary
30+
uses: houseabsolute/actions-rust-cross@v1
31+
with:
32+
command: build
33+
target: ${{ matrix.platform.target }}
34+
args: "--locked --release -p pluginlab"
35+
strip: true
36+
- name: Generate completions
37+
run: |
38+
mkdir -p ./tmp/${{ matrix.platform.target }}
39+
cp target/${{ matrix.platform.target }}/release/${{ env.BINARY_NAME }} ./tmp/${{ matrix.platform.target }}/${{ env.BINARY_NAME }}
40+
mkdir -p ./tmp/${{ matrix.platform.target }}/completions/{zsh,bash,fish}
41+
./tmp/${{ matrix.platform.target }}/${{ env.BINARY_NAME }} generate-completions --shell zsh > ./tmp/${{ matrix.platform.target }}/completions/zsh/_${{ env.BINARY_NAME }}
42+
./tmp/${{ matrix.platform.target }}/${{ env.BINARY_NAME }} generate-completions --shell bash > ./tmp/${{ matrix.platform.target }}/completions/bash/${{ env.BINARY_NAME }}
43+
./tmp/${{ matrix.platform.target }}/${{ env.BINARY_NAME }} generate-completions --shell fish > ./tmp/${{ matrix.platform.target }}/completions/fish/${{ env.BINARY_NAME }}.fish
44+
- name: Compress
45+
run: |
46+
mkdir -p ./compressed
47+
cd ./tmp/${{ matrix.platform.target }}
48+
tar -cvf ${{ env.BINARY_NAME }}-${{ matrix.platform.target }}.tar.gz ${{ env.BINARY_NAME }} completions
49+
mv ${{ env.BINARY_NAME }}-${{ matrix.platform.target }}.tar.gz ../../compressed
50+
- name: Cache compressed binaries
51+
uses: actions/cache@v4
52+
with:
53+
path: ./compressed
54+
key: ${{ matrix.platform.target }}-compressed-binaries-${{ github.sha }}
55+
upload-archives: # will be changed for release-draft
7256
needs: build
73-
env:
74-
RELEASE_NAME: ${{ github.ref_name }}
57+
name: Upload archive for build ${{ matrix.platform.target }}
58+
strategy:
59+
matrix:
60+
platform:
61+
- target: x86_64-unknown-linux-gnu
62+
- target: aarch64-unknown-linux-gnu
63+
- target: x86_64-apple-darwin
64+
- target: aarch64-apple-darwin
65+
runs-on: ubuntu-latest
7566
steps:
76-
- uses: actions/checkout@v4
77-
- name: Restore cached cross-compiled artifacts
78-
id: cache-cross-compiled-artifacts-restore
67+
- name: Restore cached compressed binaries
7968
uses: actions/cache/restore@v4
8069
with:
81-
path: ./tmp
82-
key: ${{ runner.os }}-cross-compiled-artifacts-${{ github.sha }}
83-
- name: Create release draft if it doesn't exist
84-
uses: topheman/create-release-if-not-exist@v1
70+
path: ./compressed
71+
key: ${{ matrix.platform.target }}-compressed-binaries-${{ github.sha }}
72+
- name: Upload archive
73+
uses: actions/upload-artifact@v4
8574
with:
86-
args: ${{ env.RELEASE_NAME }} --draft --generate-notes
87-
- name: Upload Binaries
88-
run: |
89-
gh release upload ${{ env.RELEASE_NAME }} \
90-
./tmp/${{ env.BINARY_NAME }}-x86_64-unknown-linux-gnu.tar.gz \
91-
./tmp/${{ env.BINARY_NAME }}-x86_64-apple-darwin.tar.gz \
92-
./tmp/${{ env.BINARY_NAME }}-aarch64-apple-darwin.tar.gz \
93-
./tmp/sha256.txt
94-
env:
95-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
path: ./compressed/
76+
name: ${{ env.BINARY_NAME }}-${{ matrix.platform.target }}.tar.gz
77+
retention-days: 10
78+

.github/workflows/rust-host.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on: [push, pull_request]
33

44
jobs:
55
build-and-test:
6+
if: false # TODO: remove
67
runs-on: ubuntu-latest
78
steps:
89
- name: Set variables based on OS and architecture for just dl-wasi-sdk

.github/workflows/web-host.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on: [push, pull_request]
33

44
jobs:
55
build:
6+
if: false # TODO: remove
67
runs-on: ubuntu-latest
78
steps:
89
- name: Set variables based on OS and architecture for just dl-wasi-sdk

0 commit comments

Comments
 (0)