-
Notifications
You must be signed in to change notification settings - Fork 0
203 lines (172 loc) · 6.66 KB
/
package.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: Package
on:
push:
branches:
- '**'
tags:
- '**'
env:
CARGO_TERM_COLOR: always
APP_NAME: "jstation-controller"
jobs:
clippy:
uses: ./.github/workflows/clippy.yml
build-linux-package:
name: "Build linux package"
needs: clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install deps
run: sudo apt install libwayland-dev libasound2-dev libgl-dev libx11-xcb-dev libxcb1-dev libxcb-dri2-0-dev libxcb-icccm4-dev libxcursor-dev libxkbcommon-dev libxcb-shape0-dev libxcb-xfixes0-dev
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Set env
run: |
if [[ ${{ github.ref }} == refs/heads/* ]]; then
VERSION=`git rev-parse --short $GITHUB_SHA`
elif [[ ${{ github.ref }} == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=unknown
fi
echo "version=${VERSION}" >> $GITHUB_ENV
echo "app_version=${APP_NAME}-${VERSION}" >> $GITHUB_ENV
echo "app_variant=${APP_NAME}-${VERSION}.linux-x86_64" >> $GITHUB_ENV
shell: bash
- name: Build linux-x86_64
run: cargo build --release
- name: Install cargo-about
run: cargo install cargo-about
- name: Package
run: |
mkdir -p temp/${{ env.app_variant }}
cp target/release/${APP_NAME} temp/${{ env.app_variant }}/
cp README.md temp/${{ env.app_variant }}/
cp res/org.fengalin.${APP_NAME}.desktop temp/${{ env.app_variant }}/
cargo-about generate -o temp/${{ env.app_variant }}/LICENSES.html about.hbs
mkdir -p packages
cd packages
TAR=${{ env.app_variant }}.tar.gz
tar -czf ${TAR} --directory=../temp ${{ env.app_variant }}
sha256sum ${TAR} > ${TAR}.sha256
shell: bash
- name: Upload linux packages
uses: actions/upload-artifact@v3
with:
name: ${{ env.app_version }}-linux
path: packages/*
if-no-files-found: error
retention-days: 2
build-macos-package:
name: "Build macos package"
needs: clippy
runs-on: macos-11
steps:
- uses: actions/checkout@v3
- name: Install latest Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin
- name: Setup Rust dependency caching
uses: Swatinem/rust-cache@v2
- name: Set env
run: |
if [[ ${{ github.ref }} == refs/heads/* ]]; then
VERSION=`git rev-parse --short $GITHUB_SHA`
elif [[ ${{ github.ref }} == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=unknown
fi
echo "version=${VERSION}" >> $GITHUB_ENV
echo "app_version=${APP_NAME}-${VERSION}" >> $GITHUB_ENV
echo "app_variant=${APP_NAME}-${VERSION}.macos" >> $GITHUB_ENV
shell: bash
- name: Build for x86_64
run: |
cargo build --release
mv target/relase/jstation-controller target/release/jstation-controller-wgpu
cargo build --release --features glow
mv target/relase/jstation-controller target/release/jstation-controller-glow
- name: Build for aarch64
run: |
export SDKROOT=$(xcrun -sdk macosx11.1 --show-sdk-path)
echo "SDKROOT=$SDKROOT"
export MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx11.1 --show-sdk-platform-version)
echo "MACOSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET"
cargo build --release --target=aarch64-apple-darwin
mv target/aarch64-apple-darwin/relase/jstation-controller target/aarch64-apple-darwin/release/jstation-controller-wgpu
cargo build --release --target=aarch64-apple-darwin --features glow
mv target/aarch64-apple-darwin/relase/jstation-controller target/aarch64-apple-darwin/release/jstation-controller-glow
env:
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
shell: bash
- name: Install cargo-about
run: cargo install cargo-about
- name: Package
run: |
mkdir -p temp/${{ env.app_variant }}
cp README.md temp/${{ env.app_variant }}/
cargo-about generate -o temp/${{ env.app_variant }}/LICENSES.html about.hbs
lipo target/release/${APP_NAME}-wgpu target/aarch64-apple-darwin/release/${APP_NAME}-wgpu -output temp/${{ env.app_variant }}/${APP_NAME}-wgpu -create
lipo target/release/${APP_NAME}-glow target/aarch64-apple-darwin/release/${APP_NAME}-glow -output temp/${{ env.app_variant }}/${APP_NAME}-glow -create
mkdir -p packages
cd packages
TAR=${{ env.app_variant }}.tar.gz
tar -czf ${TAR} --directory=../temp ${{ env.app_variant }}
shasum -a 256 ${TAR} > ${TAR}.sha256
shell: bash
- name: Upload macos packages
uses: actions/upload-artifact@v3
with:
name: ${{ env.app_version }}-macos
path: packages/*
if-no-files-found: error
retention-days: 2
build-windows-package:
name: "Build windows package"
needs: clippy
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Setup MSVC shell
uses: ilammy/msvc-dev-cmd@v1
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Set env
run: |
if [[ ${{ github.ref }} == refs/heads/* ]]; then
VERSION=`git rev-parse --short $GITHUB_SHA`
elif [[ ${{ github.ref }} == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=unknown
fi
echo "version=${VERSION}" >> $GITHUB_ENV
echo "app_version=${APP_NAME}-${VERSION}" >> $GITHUB_ENV
echo "app_name=${APP_NAME}" >> $GITHUB_ENV
echo "app_variant=${APP_NAME}-${VERSION}.windows-x86_64" >> $GITHUB_ENV
shell: bash
- name: Build windows-x86_64
run: cargo build --release
- name: Install cargo-about
run: cargo install cargo-about
- name: Package
run: |
mkdir "temp\${{ env.app_variant }}"
Copy-Item README.md "temp\${{ env.app_variant }}\"
Copy-Item "target\release\${{ env.app_name }}.exe" "temp\${{ env.app_variant }}\"
cargo-about generate -o "temp\${{ env.app_variant }}\LICENSES.html" about.hbs
mkdir packages
cd packages
$archive = "${{ env.app_variant }}.zip"
Compress-Archive -Path "..\temp\${{ env.app_variant }}" -DestinationPath $archive -CompressionLevel Optimal
Get-FileHash $archive -Algorithm SHA256 > "$archive.sha256"
- name: Upload windows packages
uses: actions/upload-artifact@v3
with:
name: ${{ env.app_version }}-windows
path: packages/*
if-no-files-found: error
retention-days: 2