Build and Release #10
Workflow file for this run
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: Build and Release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version number for the release (e.g., v1.0.0)' | |
required: true | |
release_name: | |
description: 'Name of the release' | |
required: true | |
default: 'New Release' | |
draft: | |
description: 'Create as draft release?' | |
required: false | |
default: true | |
type: boolean | |
prerelease: | |
description: 'Is this a prerelease?' | |
required: false | |
default: false | |
type: boolean | |
jobs: | |
build-windows: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: main | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
pip install -r requirements.txt | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
- name: Create ui/.env file | |
run: | | |
echo "PUBLIC_WS_URL=127.0.0.1:5174/ws`nPUBLIC_DESKTOP_MODE=true" > ui/.env | |
- name: Install and build the Svelte frontend | |
run: | | |
cd ui | |
npm install | |
npm run build | |
cd .. | |
- name: Build Windows ZIP and MSI | |
run: | | |
python setup.py build | |
python setup.py bdist_msi | |
- name: Prepare dist directory | |
run: | | |
$version = "${{ github.event.inputs.version }}" | |
$distDir = "dist/psp-windows-$version" | |
if (Test-Path $distDir) { Remove-Item -Path $distDir -Recurse -Force } | |
New-Item -Path $distDir -ItemType Directory | Out-Null | |
Copy-Item -Path "build/exe.win-amd64-*\*" -Destination $distDir -Recurse -Force | |
Write-Host "Copied build files to $distDir" | |
shell: pwsh | |
- name: Create ZIP archive | |
run: | | |
$version = "${{ github.event.inputs.version }}" | |
$zipPath = "dist/PalworldSavePal-$version-windows-standalone.zip" | |
Compress-Archive -Path "dist/psp-windows-$version\*" -DestinationPath $zipPath -Force | |
Write-Host "Created ZIP archive at $zipPath" | |
shell: pwsh | |
- name: Rename MSI | |
run: | | |
$version = "${{ github.event.inputs.version }}" | |
$msiPath = "dist/PalworldSavePal-$version-windows-installer.msi" | |
Move-Item -Path "dist/*.msi" -Destination $msiPath -Force | |
Write-Host "Renamed MSI to $msiPath" | |
shell: pwsh | |
- name: Upload Windows ZIP artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows-zip | |
path: dist/*.zip | |
- name: Upload Windows MSI artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows-msi | |
path: dist/*.msi | |
build-macos: | |
runs-on: macos-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: main | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
- name: Create ui/.env file | |
run: | | |
printf "PUBLIC_WS_URL=127.0.0.1:5174/ws\nPUBLIC_DESKTOP_MODE=true" > ui/.env | |
- name: Install and build the Svelte frontend | |
run: | | |
cd ui | |
npm install | |
npm run build | |
cd .. | |
- name: Build macOS DMG | |
run: | | |
python setup.py bdist_dmg | |
- name: Rename macOS DMG | |
run: | | |
version="${{ github.event.inputs.version }}" | |
dmg_path="dist/PalworldSavePal-$version-macos-installer.dmg" | |
mv dist/*.dmg "$dmg_path" | |
echo "Renamed DMG to $dmg_path" | |
- name: Upload macOS DMG artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: macos-dmg | |
path: dist/*.dmg | |
create-release: | |
needs: [build-windows, build-macos] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ github.event.inputs.version }} | |
name: ${{ github.event.inputs.release_name }} | |
draft: ${{ github.event.inputs.draft }} | |
prerelease: ${{ github.event.inputs.prerelease }} | |
files: | | |
artifacts/windows-zip/*.zip | |
artifacts/windows-msi/*.msi | |
artifacts/macos-dmg/*.dmg | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |