-
Notifications
You must be signed in to change notification settings - Fork 4
119 lines (115 loc) · 4.6 KB
/
cross-compile.yml
File metadata and controls
119 lines (115 loc) · 4.6 KB
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
113
114
115
116
117
118
119
# inspired by https://github.com/topheman/update-homebrew-tap-playground/blob/master/.github/workflows/cross-compile.yml
name: Cross-Compile
on: [push]
env:
CARGO_TERM_COLOR: always
BINARY_NAME: pluginlab
jobs:
build:
if: github.ref_type == 'tag'
name: Cross-Compile ${{ matrix.platform.target }}
strategy:
matrix:
platform:
- runs-on: ubuntu-24.04
target: x86_64-unknown-linux-gnu
- runs-on: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
- runs-on: macos-14
target: x86_64-apple-darwin
- runs-on: macos-14
target: aarch64-apple-darwin
runs-on: ${{ matrix.platform.runs-on }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Build binary
uses: houseabsolute/actions-rust-cross@v1
with:
command: build
target: ${{ matrix.platform.target }}
args: "--locked --release -p pluginlab"
strip: true
- name: Generate completions
run: |
mkdir -p ./tmp/${{ matrix.platform.target }}
cp target/${{ matrix.platform.target }}/release/${{ env.BINARY_NAME }} ./tmp/${{ matrix.platform.target }}/${{ env.BINARY_NAME }}
mkdir -p ./tmp/${{ matrix.platform.target }}/completions/{zsh,bash,fish}
./tmp/${{ matrix.platform.target }}/${{ env.BINARY_NAME }} generate-completions --shell zsh > ./tmp/${{ matrix.platform.target }}/completions/zsh/_${{ env.BINARY_NAME }}
./tmp/${{ matrix.platform.target }}/${{ env.BINARY_NAME }} generate-completions --shell bash > ./tmp/${{ matrix.platform.target }}/completions/bash/${{ env.BINARY_NAME }}
./tmp/${{ matrix.platform.target }}/${{ env.BINARY_NAME }} generate-completions --shell fish > ./tmp/${{ matrix.platform.target }}/completions/fish/${{ env.BINARY_NAME }}.fish
- name: Compress
run: |
mkdir -p ./compressed
cd ./tmp/${{ matrix.platform.target }}
tar -cvf ${{ env.BINARY_NAME }}-${{ matrix.platform.target }}.tar.gz ${{ env.BINARY_NAME }} completions
mv ${{ env.BINARY_NAME }}-${{ matrix.platform.target }}.tar.gz ../../compressed
- name: Cache compressed binaries
uses: actions/cache@v4
with:
path: ./compressed
key: ${{ matrix.platform.target }}-compressed-binaries-${{ github.sha }}
upload-archives:
if: false # This step is totally skipped, activate the workflow outside of a tag (for debug purposes)
needs: build
name: Upload archive for build ${{ matrix.platform.target }}
strategy:
matrix:
platform:
- target: x86_64-unknown-linux-gnu
- target: aarch64-unknown-linux-gnu
- target: x86_64-apple-darwin
- target: aarch64-apple-darwin
runs-on: ubuntu-latest
steps:
- name: Restore cached compressed binaries
uses: actions/cache/restore@v4
with:
path: ./compressed
key: ${{ matrix.platform.target }}-compressed-binaries-${{ github.sha }}
- name: Upload archive
uses: actions/upload-artifact@v4
with:
path: ./compressed/
name: ${{ env.BINARY_NAME }}-${{ matrix.platform.target }}.tar.gz
retention-days: 10
create-release-draft-if-not-exist:
if: github.ref_type == 'tag'
permissions:
contents: write
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create release draft
uses: topheman/create-release-if-not-exist@v1
with:
args: ${{ github.ref_name }} --draft --generate-notes
upload-artifacts-to-release-draft:
if: github.ref_type == 'tag'
permissions:
contents: write
needs: create-release-draft-if-not-exist
env:
RELEASE_NAME: ${{ github.ref_name }}
name: Upload artifacts to release draft ${{ matrix.platform.target }}
strategy:
matrix:
platform:
- target: x86_64-unknown-linux-gnu
- target: aarch64-unknown-linux-gnu
- target: x86_64-apple-darwin
- target: aarch64-apple-darwin
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Restore cached compressed binaries
uses: actions/cache/restore@v4
with:
path: ./compressed
key: ${{ matrix.platform.target }}-compressed-binaries-${{ github.sha }}
- name: Upload artifacts to release draft
run: |
gh release upload ${{ env.RELEASE_NAME }} ./compressed/${{ env.BINARY_NAME }}-${{ matrix.platform.target }}.tar.gz
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}