Skip to content

Commit

Permalink
Update Github Actions to GDExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
2shady4u committed Mar 12, 2024
1 parent 8320b70 commit 9e2586e
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 55 deletions.
107 changes: 52 additions & 55 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 🌈 All Builds
on:
push:
branches: [ master, main ]
branches: [ master, main, feature/update-to-gdextension ]
tags:
- "v*"

Expand All @@ -10,42 +10,48 @@ env:
PROJECT_FOLDER: .
TARGET_PATH: demo/addons/godot-krita-importer/bin/
TARGET_NAME: libkra_importer
TARGET: release
VAR_PATH: .github/workflows/build_var.json
SCONS_CACHE: ${{ github.workspace }}/.scons-cache/

jobs:
matrix:
name: Generate build matrix
runs-on: ubuntu-latest
outputs:
matrix-json: ${{ steps.set-matrix.outputs.matrix }}

steps:
- uses: actions/checkout@v4
- id: set-matrix
shell: pwsh
# Use a small PowerShell script to generate the build matrix
run: "& .github/workflows/create-build-matrix.ps1"

build:
name: ${{ matrix.name }}
needs: [ matrix ]
name: ${{ matrix.name }} - ${{ matrix.target == 'template_debug' && 'Debug' || 'Release' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: Windows Compilation
os: "windows-latest"
artifact-name: windows
artifact-extension: dll
additional-python-packages: pywin32

- name: Ubuntu Compilation
os: "ubuntu-20.04"
artifact-name: linux
artifact-extension: so

- name: MacOS Compilation
os: "macos-11"
artifact-name: osx
artifact-extension: dylib
matrix:
include: ${{ fromJson(needs.matrix.outputs.matrix-json) }}

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
lfs: true
submodules: recursive

- name: Setup Godot build cache
uses: ./godot-cpp/.github/actions/godot-cache
with:
cache-name: ${{ matrix.cache-name }}-${{ matrix.target }}
continue-on-error: true

# Use python 3.x release (works cross platform; best to keep self contained in it's own step)
- name: Set up Python 3.x
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
# Semantic version range syntax or exact version of a Python version
python-version: '3.x'
Expand All @@ -60,7 +66,6 @@ jobs:
python --version
scons --version
# The prebuilt pnglib configuration has to be copied to the base folder!
- name: Windows Compilation
if: runner.os == 'Windows'
run: |
Expand All @@ -69,66 +74,58 @@ jobs:
mkdir ${{ env.PROJECT_FOLDER }}\${{ env.TARGET_PATH }}
}
cd ${{ env.PROJECT_FOLDER }}
cd godot-cpp
scons platform=windows bits=64 target=${{ env.TARGET }} generate_bindings=yes -j4
cd ..
scons platform=windows target=${{ env.TARGET }} target_path=${{ env.TARGET_PATH }} target_name=${{ env.TARGET_NAME }}
scons platform=windows target=${{ matrix.target }} target_path=${{ env.TARGET_PATH }} target_name=${{ env.TARGET_NAME }} -j6 ${{ matrix.flags }}
# The prebuilt pnglib configuration has to be copied to the base folder!
- name: Linux or MacOS Compilation
if: runner.os == 'Linux' || runner.os == 'macOS'
run: |
mkdir -v -p ${{ env.PROJECT_FOLDER }}/${{ env.TARGET_PATH }}
cd ${{ env.PROJECT_FOLDER }}
cd godot-cpp
scons platform=${{ matrix.artifact-name }} bits=64 target=${{ env.TARGET }} generate_bindings=yes -j4
cd ..
scons platform=${{ matrix.artifact-name }} target=${{ env.TARGET }} target_path=${{ env.TARGET_PATH }} target_name=${{ env.TARGET_NAME }}
scons platform=${{ matrix.platform }} target=${{ matrix.target }} target_path=${{ env.TARGET_PATH }} target_name=${{ env.TARGET_NAME }} -j6 ${{ matrix.flags }}
- name: Upload Artifact
env:
ARTIFACT_FOLDER: ${{ env.PROJECT_FOLDER }}/${{ env.TARGET_PATH }}/${{ matrix.artifact-name }}
ARTIFACT_FOLDER: ${{ env.PROJECT_FOLDER }}/${{ env.TARGET_PATH }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact-name }}
path: ${{ env.ARTIFACT_FOLDER }}/*.${{ matrix.artifact-extension }}
name: ${{ matrix.platform }}
path: ${{ env.ARTIFACT_FOLDER }}*.${{ matrix.artifact-extension }}
if-no-files-found: error

release:
name: Release
runs-on: "ubuntu-20.04"
needs: [build]
needs: [ build ]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: recursive
lfs: true
submodules: recursive

- name: Download Artifacts
id: download
uses: actions/download-artifact@v3
with:
path: demo/addons/godot-krita-importer/bin
path: artifacts

- name: Compress Release Assets
- name: Copy Artifacts to bin/-folder
run: |
mkdir -v -p ${{ env.PROJECT_FOLDER }}/${{ env.TARGET_PATH }}
cd ${{ env.PROJECT_FOLDER }}
cp -r ${{steps.download.outputs.download-path}}/**/* ${{ env.TARGET_PATH }}
zip -r demo.zip demo/
cd demo/
zip -r addons.zip addons/
- name: Create Release & Upload Assets
cd ${{ env.TARGET_PATH }}/..
zip -r bin.zip bin/
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref }}
name: Release ${{ github.ref }}
body: |
Changes in this Release
- First Change
- Second Change
draft: false
prerelease: false
token: ${{ secrets.PAT }} # Use a personal access token such that the asetlib_sync.yml is triggered by this release!
body_path: ${{ env.PROJECT_FOLDER }}/.github/workflows/release_template.md
files: |
demo.zip
demo/addons.zip
${{ env.PROJECT_FOLDER }}/demo.zip
${{ env.PROJECT_FOLDER }}/${{ env.TARGET_PATH }}/../bin.zip
draft: true
prerelease: true
40 changes: 40 additions & 0 deletions .github/workflows/build_var.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"targets": [
"template_debug",
"template_release"
],
"jobs": [
{
"name": "Windows (x86_64, MSVC)",
"os": "windows-latest",
"platform": "windows",
"artifact-extension": "dll",
"additional-python-packages": "pywin32",
"cache-name": "win-x86_64-msvc",
"skip": true
},
{
"name": "Windows (x86_64, MinGW)",
"os": "windows-latest",
"platform": "windows",
"artifact-extension": "dll",
"flags": "use_mingw=yes",
"cache-name": "win-x86_64-mingw"
},
{
"name": "Ubuntu (GCC)",
"os": "ubuntu-20.04",
"platform": "linux",
"artifact-extension": "so",
"cache-name": "linux-x86_64"
},
{
"name": "MacOS (universal)",
"os": "macos-11",
"platform": "macos",
"artifact-extension": "framework",
"flags": "arch=universal",
"cache-name": "macos-universal"
}
]
}
21 changes: 21 additions & 0 deletions .github/workflows/create-build-matrix.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
$RawMatrix = Get-Content -Raw -Path .github/workflows/build_var.json | ConvertFrom-Json

$Targets = $RawMatrix.targets
$Jobs = $RawMatrix.jobs

$Matrix = @()
foreach ($job in $Jobs)
{
if ($job.skip -eq $true) {
continue
}
foreach ($target in $Targets)
{
$MatrixJob = $job.PsObject.Copy()
$MatrixJob | Add-Member -MemberType NoteProperty -Name 'target' -Value $target
$Matrix += $MatrixJob
}
}

Write-Host (ConvertTo-JSON -InputObject $Matrix)
Write-Output "matrix=$(ConvertTo-JSON -InputObject $Matrix -Compress)" >> $env:GITHUB_OUTPUT
14 changes: 14 additions & 0 deletions .github/workflows/release_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Download the demo-project and/or the necessary binaries below.

### Dependencies Versions

Godot vxx.xx.xx

### Supported Operating Systems:
- Mac OS X (universal)
- Linux
- Windows

#### What's new?
- First new thing
- Second new thing

0 comments on commit 9e2586e

Please sign in to comment.