Skip to content

Commit

Permalink
Merge pull request #8 from BastiaanOlij/add_ci
Browse files Browse the repository at this point in the history
Add CI to build extension
  • Loading branch information
BastiaanOlij committed May 10, 2023
2 parents 0623962 + 2054ccf commit 8f26d23
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 0 deletions.
147 changes: 147 additions & 0 deletions .github/workflows/build-on-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Workflow to automatically compile a Linux/Windows library on commit/push
name: Build on push

# Controls when the action will run. Triggers the workflow on push or pull request
# events, but only for the master branch we'll create .zip files
on:
[push, pull_request]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This job builds the plugin for our target platforms
build:
name: Building for ${{ matrix.platform }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- name: 🐧 Linux (GCC)
os: ubuntu-20.04
platform: linux
artifact-name: gdxrreference.linux
artifact-path: demo/addons/godot_xr_reference/bin/libgdxrreference.linux.*

- name: 🏁 Windows (x86_64, MSVC)
os: windows-2019
platform: windows
artifact-name: gdxrreference.windows
artifact-path: demo/addons/godot_xr_reference/bin/libgdxrreference.windows.*

- name: 🍎 macOS (universal)
os: macos-11
platform: macos
flags: arch=universal
artifact-name: gdxrreference.macos
artifact-path: demo/addons/godot_xr_reference/bin/libgdxrreference.macos.*

- name: 🤖 Android (arm64)
os: ubuntu-20.04
platform: android
flags: ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME arch=arm64
artifact-name: gdxrreference.android
artifact-path: demo/addons/godot_xr_reference/bin/libgdxrreference.android.*

- name: 🍏 iOS (arm64)
os: macos-11
platform: ios
flags: arch=arm64
artifact-name: gdxrreference.ios
artifact-path: demo/addons/godot_xr_reference/bin/libgdxrreference.ios.*

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Setup actions
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Set up Python (for SCons)
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Linux dependencies
if: ${{ matrix.platform == 'linux' }}
run: |
sudo apt-get update -qq
sudo apt-get install -qqq build-essential pkg-config
- name: Install scons
run: |
python -m pip install scons==4.0.0
- name: Build debug build
run: |
scons platform=${{ matrix.platform }} target=template_debug ${{ matrix.flags }}
- name: Build release build
run: |
scons platform=${{ matrix.platform }} target=template_release ${{ matrix.flags }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact-name }}
path: ${{ matrix.artifact-path }}
if-no-files-found: error

# This job collects the build output and assembles the final asset (artifact)
asset:
name: Assembling the asset (artifact)
runs-on: ubuntu-20.04
needs: build
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags'))

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Setup actions
uses: actions/checkout@v3
with:
path: source
- name: Download all workflow run artifacts
uses: actions/download-artifact@v3
- name: Copy files to destination
run: |
mkdir plugin
mkdir plugin/addons
cp -r source/demo/addons/godot_xr_reference plugin/addons
cp gdxrreference.linux/*.so plugin/addons/godot_xr_reference/bin/
cp gdxrreference.windows/*.dll plugin/addons/godot_xr_reference/bin/
cp gdxrreference.android/*.so plugin/addons/godot_xr_reference/bin/
cp gdxrreference.ios/*.dylib plugin/addons/godot_xr_reference/bin/
cp -R gdxrreference.macos/libgdxrreference.macos.* plugin/addons/godot_xr_reference/bin/
- name: Calculate GIT short ref
run: |
cd source
echo "GITHUB_SHA_SHORT=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV
cd ..
if: github.ref == 'refs/heads/master'
- name: Get tag name
run: |
echo "GITHUB_SHA_SHORT=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags')
- name: Clean up extracted files
run: |
rm -rf gdxrreference.linux
rm -rf gdxrreference.windows
rm -rf gdxrreference.android
rm -rf gdxrreference.macos
rm -rf gdxrreference.ios
rm -rf source
rm -rf .git
mv plugin gdxrreference_${{ env.GITHUB_SHA_SHORT }}
- name: Zip asset
run: |
zip -qq -r gdxrreference.zip .
- name: Create and upload asset
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "gdxrreference.zip"
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
omitPrereleaseDuringUpdate : true
token: ${{ secrets.GITHUB_TOKEN }}
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
6 changes: 6 additions & 0 deletions demo/addons/godot_xr_reference/godot_xr_reference.gdextension
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ windows.debug.x86_64 = "res://addons/godot_xr_reference/bin/libgdxrreference.win
windows.release.x86_64 = "res://addons/godot_xr_reference/bin/libgdxrreference.windows.template_release.x86_64.dll"
linux.debug.x86_64 = "res://addons/godot_xr_reference/bin/libgdxrreference.linux.template_debug.x86_64.so"
linux.release.x86_64 = "res://addons/godot_xr_reference/bin/libgdxrreference.linux.template_release.x86_64.so"
android.debug.arm64 = "res://addons/godot_xr_reference/bin/libgdxrreference.android.template_debug.arm64.so"
android.release.arm64 = "res://addons/godot_xr_reference/bin/libgdxrreference.android.template_release.arm64.so"
ios.debug.arm64 = "res://addons/godot_xr_reference/bin/libgdxrreference.ios.template_debug.arm64.dylib"
ios.release.arm64 = "res://addons/godot_xr_reference/bin/libgdxrreference.ios.template_release.arm64.dylib"
macos.debug = "res://addons/godot_xr_reference/bin/libgdxrreference.macos.template_debug.framework"
macos.release = "res://addons/godot_xr_reference/bin/libgdxrreference.macos.template_release.framework"

0 comments on commit 8f26d23

Please sign in to comment.