Skip to content

fix offline auth, add metadata caching and some small fixes #186

fix offline auth, add metadata caching and some small fixes

fix offline auth, add metadata caching and some small fixes #186

Workflow file for this run

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'
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: no
- name: Deploy to server
if: github.ref == 'refs/heads/master'
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'
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/*