Weekly Build #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Weekly Build | |
on: | |
schedule: | |
- cron: '0 0 * * 0' # Runs every Sunday at midnight UTC | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
set-date: | |
runs-on: ubuntu-latest | |
outputs: | |
date: ${{ steps.set-date.outputs.date }} | |
linux-filename: sbepis-${{ steps.set-date.outputs.date }}-linux.tar.gz | |
windows-filename: sbepis-${{ steps.set-date.outputs.date }}-windows.zip | |
steps: | |
- name: Set date | |
id: set-date | |
run: echo "date=$(date +%Y-%m-%d-%H%M)" >> "$GITHUB_OUTPUT" | |
build-linux: | |
runs-on: ubuntu-latest | |
needs: [set-date] | |
env: | |
FILENAME: ${{ needs.set-date.outputs.linux-filename }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install dependencies | |
run: sudo apt-get update && sudo apt-get install -y libasound2-dev libudev-dev | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Build the game | |
run: cargo build --release | |
- name: Compress build files | |
run: | | |
mkdir -p build/SBEPIS | |
cp ./target/release/sbepis build/SBEPIS/SBEPIS | |
cp -r ./sbepis/assets build/SBEPIS/ | |
tar -czf $FILENAME -C build SBEPIS | |
- name: Install rclone | |
run: | | |
curl https://rclone.org/install.sh | sudo bash | |
- name: Configure rclone | |
run: | | |
mkdir -p ~/.config/rclone | |
cat <<EOF > ~/.config/rclone/rclone.conf | |
${{ secrets.RCLONE_CONFIG }} | |
EOF | |
- name: Upload build to Google Drive | |
run: rclone copy $FILENAME "gdrive:SBEPIS Builds" | |
build-windows: | |
runs-on: windows-latest | |
needs: [set-date] | |
env: | |
FILENAME: ${{ needs.set-date.outputs.windows-filename }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Build the game | |
run: cargo build --release | |
- name: Compress build files | |
run: | | |
mkdir build\SBEPIS | |
cp .\target\release\sbepis.exe build\SBEPIS\SBEPIS.exe | |
cp -r .\sbepis\assets build\SBEPIS\ | |
Compress-Archive -Path .\build\SBEPIS -DestinationPath $env:FILENAME | |
- name: Install rclone | |
run: | | |
choco install rclone | |
- name: Configure rclone | |
run: | | |
$rcloneConfigPath = "$env:USERPROFILE\.config\rclone\rclone.conf" | |
mkdir -p (Split-Path $rcloneConfigPath) | |
@" | |
${{ secrets.RCLONE_CONFIG }} | |
"@ | Set-Content -Path $rcloneConfigPath | |
- name: Upload build to Google Drive | |
run: rclone copy $env:FILENAME "gdrive:SBEPIS Builds" | |
notify-discord: | |
runs-on: ubuntu-latest | |
needs: [set-date, build-linux, build-windows] | |
env: | |
DATE: ${{ needs.set-date.outputs.date }} | |
LINUX_FILENAME: ${{ needs.set-date.outputs.linux-filename }} | |
WINDOWS_FILENAME: ${{ needs.set-date.outputs.windows-filename }} | |
steps: | |
- name: Install rclone | |
run: | | |
curl https://rclone.org/install.sh | sudo bash | |
- name: Configure rclone | |
run: | | |
mkdir -p ~/.config/rclone | |
cat <<EOF > ~/.config/rclone/rclone.conf | |
${{ secrets.RCLONE_CONFIG }} | |
EOF | |
- name: Send Discord notification | |
env: | |
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
run: | | |
LINUX_LINK=$(rclone link "gdrive:SBEPIS Builds/$LINUX_FILENAME") | |
WINDOWS_LINK=$(rclone link "gdrive:SBEPIS Builds/$WINDOWS_FILENAME") | |
EMBED_CONTENT=$(cat <<EOF | |
{ | |
"embeds": [ | |
{ | |
"title": "New Builds Available!", | |
"description": "Build Number: $DATE", | |
"color": 240116, | |
"fields": [ | |
{ | |
"name": "Windows", | |
"value": "[Download]($WINDOWS_LINK)", | |
"inline": true | |
}, | |
{ | |
"name": "Linux", | |
"value": "[Download]($LINUX_LINK)", | |
"inline": true | |
} | |
] | |
} | |
] | |
} | |
EOF | |
) | |
curl -H "Content-Type: application/json" \ | |
-X POST \ | |
-d "$EMBED_CONTENT" \ | |
$DISCORD_WEBHOOK_URL |