-
Notifications
You must be signed in to change notification settings - Fork 5
129 lines (107 loc) · 5.65 KB
/
deploy.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
on:
push:
defaults:
run:
shell: bash
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ['windows-latest', 'ubuntu-latest', 'macos-latest']
steps:
- uses: actions/checkout@v4
- name: Cache Rust build
uses: Swatinem/rust-cache@v2
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Set environment variables
run: |
echo "VERSION=$GITHUB_SHA" >> $GITHUB_ENV
echo "LAUNCHER_NAME=${{ vars.LAUNCHER_NAME }}" >> $GITHUB_ENV
DATA_LAUNCHER_NAME=$(echo "${{ vars.LAUNCHER_NAME }}" | tr '[:upper:]' '[:lower:]' | tr ' ' '_')
echo "DATA_LAUNCHER_NAME=$DATA_LAUNCHER_NAME" >> $GITHUB_ENV
echo "VERSION_MANIFEST_URL=${{ vars.VERSION_MANIFEST_URL }}" >> $GITHUB_ENV
if [ -n "${{ vars.AUTO_UPDATE_BASE }}" ]; then echo "AUTO_UPDATE_BASE=${{ vars.AUTO_UPDATE_BASE }}" >> $GITHUB_ENV; fi
- name: Build the launcher
run: |
mkdir -p build
if [ "${{ matrix.os }}" == "windows-latest" ]; then
cargo build --bin launcher --profile release-lto
mv "target/release-lto/launcher.exe" "build/${LAUNCHER_NAME}.exe"
echo "$VERSION" > build/version_windows.txt
elif [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
cargo build --bin launcher --profile release-lto
mv "target/release-lto/launcher" "build/${DATA_LAUNCHER_NAME}"
echo "$VERSION" > build/version_linux.txt
elif [ "${{ matrix.os }}" == "macos-latest" ]; then
mkdir -p icon.iconset
PNG_PATH="launcher/assets/$DATA_LAUNCHER_NAME.png"
sips -z 16 16 "$PNG_PATH" --out icon.iconset/icon_16x16.png
sips -z 32 32 "$PNG_PATH" --out icon.iconset/[email protected]
sips -z 32 32 "$PNG_PATH" --out icon.iconset/icon_32x32.png
sips -z 64 64 "$PNG_PATH" --out icon.iconset/[email protected]
sips -z 64 64 "$PNG_PATH" --out icon.iconset/icon_64x64.png
sips -z 128 128 "$PNG_PATH" --out icon.iconset/[email protected]
sips -z 128 128 "$PNG_PATH" --out icon.iconset/icon_128x128.png
sips -z 256 256 "$PNG_PATH" --out icon.iconset/[email protected]
sips -z 256 256 "$PNG_PATH" --out icon.iconset/icon_256x256.png
sips -z 512 512 "$PNG_PATH" --out icon.iconset/[email protected]
sips -z 512 512 "$PNG_PATH" --out icon.iconset/icon_512x512.png
sips -z 1024 1024 "$PNG_PATH" --out icon.iconset/[email protected]
iconutil -c icns icon.iconset -o launcher/assets/icon.icns
cargo install cargo-bundle
export MACOSX_DEPLOYMENT_TARGET=10.8
cargo bundle --bin launcher --profile release-lto --target aarch64-apple-darwin
mkdir -p app
cp -r "target/aarch64-apple-darwin/release-lto/bundle/osx/Potato Launcher.app" "app/$LAUNCHER_NAME.app"
rustup target add x86_64-apple-darwin
cargo bundle --bin launcher --profile release-lto --target x86_64-apple-darwin
lipo -create -output "app/$LAUNCHER_NAME.app/Contents/MacOS/launcher" \
"target/x86_64-apple-darwin/release-lto/bundle/osx/Potato Launcher.app/Contents/MacOS/launcher" \
"target/aarch64-apple-darwin/release-lto/bundle/osx/Potato Launcher.app/Contents/MacOS/launcher"
codesign --force --deep --sign - "app/$LAUNCHER_NAME.app"
DMG_FILENAME="${LAUNCHER_NAME}.dmg"
# CI runner sometimes fails with "hdiutil: create failed - Resource busy", so retry a few times
retry=0
max_retries=5
until [ $retry -ge $max_retries ]
do
hdiutil create "$DMG_FILENAME" -ov -volname "$LAUNCHER_NAME" -fs HFS+ -srcfolder "app/" && break
retry=$((retry+1))
echo "Retrying hdiutil create... ($retry/$max_retries)"
sleep 5
done
mv "$DMG_FILENAME" build/
mv "app/$LAUNCHER_NAME.app" "app/update.app"
tar -czvf "build/${DATA_LAUNCHER_NAME}_macos.tar.gz" -C app "update.app"
echo "$VERSION" > build/version_macos.txt
fi
- name: Set up SSH
if: ${{ github.ref == 'refs/heads/master' && secrets.SSH_KEY != '' && secrets.SERVER_USER != '' && secrets.SERVER_ADDR != '' && secrets.SERVER_PATH != '' }}
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: no
- name: Deploy to server
if: ${{ github.ref == 'refs/heads/master' && secrets.SSH_KEY != '' && secrets.SERVER_USER != '' && secrets.SERVER_ADDR != '' && secrets.SERVER_PATH != '' }}
env:
SERVER_USER: ${{ secrets.SERVER_USER }}
SERVER_ADDR: ${{ secrets.SERVER_ADDR }}
SERVER_PATH: ${{ secrets.SERVER_PATH }}
run: scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null build/* $SERVER_USER@$SERVER_ADDR:$SERVER_PATH/
- name: Purge Cloudflare cache
if: ${{ github.ref == 'refs/heads/master' && secrets.SSH_KEY != '' && secrets.SERVER_USER != '' && secrets.SERVER_ADDR != '' && secrets.SERVER_PATH != '' }}
env:
SERVER_USER: ${{ secrets.SERVER_USER }}
SERVER_ADDR: ${{ secrets.SERVER_ADDR }}
run: ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $SERVER_USER@$SERVER_ADDR '~/purge_cf_cache.sh'
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: launcher-${{ matrix.os }}
path: build/*