-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (115 loc) · 4.09 KB
/
build.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Build and upload binaries to release
on:
push:
tags:
- v[0-9].*
jobs:
build-and-release:
name: Build and release
strategy:
matrix:
job:
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
- target: i686-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: i686-pc-windows-msvc
os: windows-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
runs-on: ${{ matrix.job.os }}
env:
CARGO_TARGET_DIR: target
LEPTOS_BIN_TARGET_TRIPLE: ${{ matrix.job.target }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Initialize workflow variables
id: vars
shell: bash
run: |
TARGET=${{ matrix.job.target }}
case $TARGET in
*-pc-windows-*) BINARY="file-share.exe" ;;
*) BINARY="file-share" ;;
esac;
echo "BINARY=${BINARY}"
echo "BINARY=${BINARY}" >> "$GITHUB_OUTPUT"
case $TARGET in
x86_64-*) CROSS="false" ;;
*) CROSS="true" ;;
esac;
echo "CROSS=${CROSS}"
echo "CROSS=${CROSS}" >> "$GITHUB_OUTPUT"
case $TARGET in
*-linux-*) ARCHIVE="file-share_$TARGET.tar.gz" ;;
*) ARCHIVE="file-share_$TARGET.zip" ;;
esac;
echo "ARCHIVE=${ARCHIVE}"
echo "ARCHIVE=${ARCHIVE}" >> "$GITHUB_OUTPUT"
RELEASE="target/server/${{ matrix.job.target }}/release"
echo "RELEASE=${RELEASE}"
echo "RELEASE=${RELEASE}" >> "$GITHUB_OUTPUT"
case ${{ matrix.job.target }} in
aarch64-*-linux-*) STRIP="aarch64-linux-gnu-strip" ;;
*-pc-windows-msvc) STRIP="" ;;
*) STRIP="strip"
esac;
echo "STRIP=${STRIP}"
echo "STRIP=${STRIP}" >> "$GITHUB_OUTPUT"
- name: Install strip and gcc for aarch64
if: ${{ matrix.job.target == 'aarch64-unknown-linux-gnu' }}
run: |
sudo apt-get -y update
sudo apt-get -y install binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu
- name: Install NodeJS
uses: actions/setup-node@v3
with:
node-version: latest
- name: Install Tailwind and compile the stylesheet
run: |
npm i --no-package-lock
npm run build
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: ${{ matrix.job.target }}
profile: minimal
override: true
- name: Install cross
if: ${{ steps.vars.outputs.CROSS }}
uses: taiki-e/install-action@v2
with:
tool: cross
- name: Install cargo-leptos and wasm target
run: |
cargo install --force cargo-leptos
rustup target add wasm32-unknown-unknown
- name: Compile
if: ${{ steps.vars.outputs.CROSS == 'false' }}
run: cargo leptos build --release
- name: Compile with cross
if: ${{ steps.vars.outputs.CROSS == 'true' }}
run: cargo leptos build --release
env:
LEPTOS_BIN_CARGO_COMMAND: cross
- name: Strip the binary
if: ${{ steps.vars.outputs.STRIP }}
run: ${{ steps.vars.outputs.STRIP }} '${{ steps.vars.outputs.RELEASE }}/${{ steps.vars.outputs.BINARY }}'
- name: Create archive
run: |
tar caf ${{ steps.vars.outputs.ARCHIVE }} --directory=${{ steps.vars.outputs.RELEASE }} ${{ steps.vars.outputs.BINARY }}
- name: Upload binary to release
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ steps.vars.outputs.ARCHIVE }}
asset_name: ${{ steps.vars.outputs.ARCHIVE }}
tag: ${{ github.ref }}