Skip to content

Weekly Build

Weekly Build #35

Workflow file for this run

name: Weekly Build
on:
schedule:
- cron: '0 0 * * 0' # Runs every Sunday at midnight UTC
workflow_dispatch: # Allows manual triggering
jobs:
set-meta:
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
log: ${{ steps.set-log.outputs.log }}
steps:
- name: Set date
id: set-date
run: echo "date=$(date +%Y-%m-%d-%H%M)" >> "$GITHUB_OUTPUT"
- name: Set log
id: set-log
run: |
git clone --bare --filter=blob:none --single-branch https://github.com/Dragon-Fox-Collective/SBEPIS.git
cd SBEPIS.git
echo "log=$(git log --reverse --pretty=format:"%s" --since=1.week | sed 's/^/- /' | tr '\n' '\\' | sed 's/\\/\\n/g')" >> "$GITHUB_OUTPUT"
build-linux:
runs-on: ubuntu-latest
needs: [set-meta]
env:
FILENAME: ${{ needs.set-meta.outputs.linux-filename }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive
- 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-meta]
env:
FILENAME: ${{ needs.set-meta.outputs.windows-filename }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive
- 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-meta, build-linux, build-windows]
env:
DATE: ${{ needs.set-meta.outputs.date }}
LINUX_FILENAME: ${{ needs.set-meta.outputs.linux-filename }}
WINDOWS_FILENAME: ${{ needs.set-meta.outputs.windows-filename }}
LOG: ${{ needs.set-meta.outputs.log }}
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**\n$LOG",
"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