Build Spec-Hops #18
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: Release SpaceBoom | |
on: | |
release: | |
types: [created] | |
jobs: | |
build: | |
name: Build on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
include: | |
- os: ubuntu-latest | |
output_name: SpaceBoom-linux | |
- os: macos-latest | |
output_name: SpaceBoom-macos | |
- os: windows-latest | |
output_name: SpaceBoom-windows.exe | |
steps: | |
- name: Checkout repository and submodules | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Install dependencies (Ubuntu) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y cmake ninja-build libgl1-mesa-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev | |
- name: Install dependencies (macOS) | |
if: matrix.os == 'macos-latest' | |
run: | | |
brew install cmake ninja | |
- name: Install dependencies (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
choco install cmake ninja | |
- name: Configure CMake | |
run: | | |
mkdir build | |
cd build | |
cmake -GNinja .. | |
- name: Build | |
run: | | |
cd build | |
ninja | |
- name: Prepare release package | |
run: | | |
mkdir release | |
cp build/OpenGL/SpaceBoom${{ matrix.os == 'windows-latest' && '.exe' || '' }} release/${{ matrix.output_name }} | |
cp -r OpenGL/res release/res | |
- name: Create release artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ matrix.output_name }} | |
path: release | |
upload: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v2 | |
- name: Create release archives | |
run: | | |
for dir in */; do | |
zip -r "${dir%/}.zip" "$dir" | |
done | |
- name: Upload release assets | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const fs = require('fs').promises; | |
const { repo: { owner, repo }, sha } = context; | |
const release = await github.rest.repos.getReleaseByTag({ | |
owner, | |
repo, | |
tag: process.env.GITHUB_REF.replace('refs/tags/', '') | |
}); | |
const assets = await fs.readdir('.'); | |
for (const asset of assets) { | |
if (asset.endsWith('.zip')) { | |
await github.rest.repos.uploadReleaseAsset({ | |
owner, | |
repo, | |
release_id: release.data.id, | |
name: asset, | |
data: await fs.readFile(asset) | |
}); | |
} | |
} |