-
Notifications
You must be signed in to change notification settings - Fork 1
166 lines (148 loc) · 5.86 KB
/
Copy pathbuild.yml
File metadata and controls
166 lines (148 loc) · 5.86 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
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
name: Build Artifacts
permissions:
contents: read
on:
workflow_call:
inputs:
version:
description: 'Version to build'
required: true
type: string
upload_artifacts:
description: 'Whether to upload artifacts'
required: false
type: boolean
default: true
branch:
description: 'Git branch to checkout'
required: false
type: string
default: 'main'
skip_msi:
description: 'Skip MSI bundling on Windows (required for pre-release version strings like nightly-YYMMDD)'
required: false
type: boolean
default: false
secrets:
XMCL_CURSEFORGE_API_KEY:
required: true
XMCL_OPENLIST_BASE_URL:
required: true
NEXT_PUBLIC_OPENLIST_BASE_URL:
required: true
jobs:
Build-and-Release:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
platform: windows
arch: x86_64
- os: windows-latest
target: i686-pc-windows-msvc
platform: windows
arch: i686
- os: windows-11-arm
target: aarch64-pc-windows-msvc
platform: windows
arch: aarch64
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
platform: linux
arch: x86_64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
# See https://github.com/tauri-apps/tauri-action
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
# targets: ${{ matrix.platform == 'macos' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
- name: Install Linux dependencies
if: matrix.platform == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
# Additional dependencies for RPM building
sudo apt-get install -y rpm
- name: Install frontend dependencies
run: |
npm install -g pnpm
pnpm import
pnpm install
- name: Remove Font files (MacOS)
if: matrix.platform == 'macos'
run: |
rm -r public/fonts/Sinter/
rm src/styles/fonts.css
touch src/styles/fonts.css
- uses: swatinem/rust-cache@v2
with:
workspaces: "./src-tauri -> target"
key: ${{ matrix.platform }}-${{ matrix.target }}
- name: Build the app (MacOS)
if: matrix.platform == 'macos'
run: pnpm run tauri build --bundles app --target ${{ matrix.target }}
env:
XMCL_CURSEFORGE_API_KEY: ${{ secrets.XMCL_CURSEFORGE_API_KEY }}
XMCL_OPENLIST_BASE_URL: ${{ secrets.XMCL_OPENLIST_BASE_URL }}
NEXT_PUBLIC_OPENLIST_BASE_URL: ${{ secrets.NEXT_PUBLIC_OPENLIST_BASE_URL }}
- name: Build the app
if: matrix.platform != 'macos'
shell: bash
run: |
BUILD_ARGS="--target ${{ matrix.target }}"
if [[ "${{ matrix.platform }}" = "windows" && "${{ inputs.skip_msi }}" = "true" ]]; then
BUILD_ARGS="$BUILD_ARGS --no-bundle"
fi
pnpm run tauri build $BUILD_ARGS
env:
XMCL_CURSEFORGE_API_KEY: ${{ secrets.XMCL_CURSEFORGE_API_KEY }}
XMCL_OPENLIST_BASE_URL: ${{ secrets.XMCL_OPENLIST_BASE_URL }}
NEXT_PUBLIC_OPENLIST_BASE_URL: ${{ secrets.NEXT_PUBLIC_OPENLIST_BASE_URL }}
- name: Prepare release artifact
shell: bash
env:
VERSION: ${{ inputs.version }}
run: |
ARTIFACT_NAME="XMCL_${{ env.VERSION }}_${{ matrix.platform }}_${{ matrix.arch }}"
echo "Artifact Name: $ARTIFACT_NAME"
mkdir artifacts
if [ "${{ matrix.platform }}" = "windows" ]; then
python scripts/release/bundle_portable_assets.py -p "src-tauri/target/${{ matrix.target }}/release/" "xmcl.exe"
# For Windows, copy the portable exe
mv "src-tauri/target/${{ matrix.target }}/release/xmcl-patched.exe" artifacts/"$ARTIFACT_NAME"_portable.exe
if [ "${{ inputs.skip_msi }}" != "true" ]; then
mv "src-tauri/target/${{ matrix.target }}/release/bundle/msi/"*.msi artifacts/"$ARTIFACT_NAME".msi
fi
ls -la artifacts
elif [ "${{ matrix.platform }}" = "macos" ]; then
ls src-tauri/target/${{ matrix.target }}/release/bundle/macos
# For MacOS, compress the .app folder
tar -cvzf artifacts/"$ARTIFACT_NAME".app.tar.gz -C "src-tauri/target/${{ matrix.target }}/release/bundle/macos" "XMCL.app"
ls -la artifacts
elif [ "${{ matrix.platform }}" = "linux" ]; then
python scripts/release/bundle_portable_assets.py -p "src-tauri/target/${{ matrix.target }}/release/" "xmcl"
mv "src-tauri/target/${{ matrix.target }}/release/bundle/appimage/"*.AppImage artifacts/"$ARTIFACT_NAME".AppImage
mv "src-tauri/target/${{ matrix.target }}/release/bundle/deb/"*.deb artifacts/"$ARTIFACT_NAME".deb
mv "src-tauri/target/${{ matrix.target }}/release/bundle/rpm/"*.rpm artifacts/"$ARTIFACT_NAME".rpm
mv "src-tauri/target/${{ matrix.target }}/release/xmcl-patched" artifacts/"$ARTIFACT_NAME"_portable
ls -la artifacts
fi
echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_ENV
- name: Upload artifact
if: inputs.upload_artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: "artifacts/*"
if-no-files-found: error