Skip to content

Commit

Permalink
Add CI/CD pipelines using github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
baylej committed Apr 26, 2020
1 parent e65a022 commit d5eb225
Show file tree
Hide file tree
Showing 3 changed files with 267 additions and 1 deletion.
40 changes: 40 additions & 0 deletions .github/workflows/buildandtest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build and Test

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Create build dir
run: mkdir build
- name: Configure CMake
run: cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${HOME}/.local -DCMAKE_C_FLAGS='-Wall -Wextra -pedantic'
working-directory: ./build
- name: Build and Install
run: make -j2 && make install
working-directory: ./build
- name: Build and Run dumper
run: |
cmake -DCMAKE_PREFIX_PATH=${HOME}/.local &&
make || ( echo 'Build failed' && exit 1 )
cd ../data
../dumper/dumper b64zlib.tmx &&
../dumper/dumper --use-rc-mgr --fd tileset.tsx --callback pointtemplate.tx --buffer tiletemplate.tx objecttemplates.tmx
working-directory: ./examples/dumper
- name: Test C++ compatibility
run: |
cat > test.cpp <<EOF
#include <tmx.h>
int main(void) { tmx_map* map = tmx_load("map.tmx"); return 0; }
EOF
c++ -I src/ -c test.cpp
224 changes: 224 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
name: Release

on:
push:
tags:
- tmx_** # Releases

env:
# Latest (2.9.10): https://gitlab.gnome.org/GNOME/libxml2/-/issues/154
libxml2_ver: v2.9.9
LIBXML2_CONFIGURE_FLAGS: '--without-c14n --without-catalog --without-debug --without-docbook --without-ftp
--without-http --without-html --without-xpath --without-xptr --without-xinclude --without-iconv --without-icu
--without-iso8859x --without-zlib --without-lzma --without-mem_debug --without-run_debug --without-schemas
--without-schematron --without-regexps --without-modules --without-pattern --without-push --without-valid
--without-sax1 --without-legacy --without-output --without-python
--with-tree --with-writer --with-reader
--disable-shared --enable-static'
zlib_ver: v1.2.11

jobs:
linux64:
name: Linux 64 Build
runs-on: ubuntu-16.04
steps:
# context expressions lack the most basic string manipulation functions...
- name: Create distribution folder
run: |
ARTIFACT_NAME=${GITHUB_REF:10}-linux
DIST_PATH=${GITHUB_WORKSPACE}/${ARTIFACT_NAME}
echo ::set-env name=ARTIFACT_NAME::${ARTIFACT_NAME}
echo ::set-env name=DIST_PATH::${DIST_PATH}
mkdir "${DIST_PATH}"
# Build and install zlib
- name: Checkout zlib
uses: actions/checkout@v2
with:
repository: madler/zlib
path: zlib
ref: ${{ env.zlib_ver }}
- name: Build and Install zlib
run: |
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=Off -DCMAKE_INSTALL_PREFIX="${DIST_PATH}" &&
make -j2 && make install
working-directory: zlib

# Build and install libxml2
- name: Checkout libxml2
uses: actions/checkout@v2
with:
repository: GNOME/libxml2
path: libxml2
ref: ${{ env.libxml2_ver }}
- name: Build and Install libxml2
run: |
./autogen.sh --prefix="${DIST_PATH}" ${LIBXML2_CONFIGURE_FLAGS} &&
make -j2 && make install-strip
working-directory: libxml2

# Clean-up
- name: Clean-up
run: |
rm -rf "${DIST_PATH}/bin" "${DIST_PATH}/share"
find "${DIST_PATH}/lib/" -iname '*.so*' -delete
rm -f "${DIST_PATH}/lib/libxml2.la" "${DIST_PATH}/lib/xml2Conf.sh"
# Build and install libTMX
- name: Checkout libTMX
uses: actions/checkout@v2
with:
path: tmx
- name: Build and Install libTMX
run: |
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${DIST_PATH}" -DCMAKE_PREFIX_PATH="${DIST_PATH}" &&
make -j2 && make install
working-directory: tmx

# Upload
- name: Upload artifact
uses: actions/upload-artifact@v1
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.DIST_PATH }}

html5:
name: HTML5 Build
runs-on: ubuntu-latest
steps:
- name: Create distribution folder
run: |
ARTIFACT_NAME=${GITHUB_REF:10}-html5
DIST_PATH=${GITHUB_WORKSPACE}/${ARTIFACT_NAME}
echo ::set-env name=ARTIFACT_NAME::${ARTIFACT_NAME}
echo ::set-env name=DIST_PATH::${DIST_PATH}
mkdir "${DIST_PATH}"
# Build and install emscripten
- name: Checkout emsdk
uses: actions/checkout@v2
with:
repository: emscripten-core/emsdk
path: emsdk
- name: Install emscripten
run: |
./emsdk install latest &&
./emsdk activate latest &&
./emsdk construct_env ${HOME}/emenv
working-directory: emsdk
# Improvement: export PATH and ENV vars for whole job using workflow commands ::set-env and ::add-path

# Libraries are compiled with flag -flto to generate LLVM bytecode (to later benefit from LTO)
# See: https://emscripten.org/docs/optimizing/Optimizing-Code.html#lto

# Build and install libxml2
- name: Checkout libxml2
uses: actions/checkout@v2
with:
repository: GNOME/libxml2
path: libxml2
ref: ${{ env.libxml2_ver }}
- name: Build and Install libxml2
run: |
. ${HOME}/emenv
emconfigure ./autogen.sh --prefix="${DIST_PATH}" ${LIBXML2_CONFIGURE_FLAGS} &&
emmake make -j2 CFLAGS='-flto' && make install
working-directory: libxml2

# Clean-up
- name: Clean-up
run: rm -rf "${DIST_PATH}/bin" "${DIST_PATH}/share" "${DIST_PATH}/lib/libxml2.la" "${DIST_PATH}/lib/xml2Conf.sh"

# Build and install libTMX
- name: Checkout libTMX
uses: actions/checkout@v2
with:
path: tmx
- name: Build and Install libTMX
run: |
. ${HOME}/emenv
emcmake cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${DIST_PATH}" \
-DCMAKE_PREFIX_PATH="${DIST_PATH}" -DCMAKE_FIND_ROOT_PATH="${DIST_PATH}" \
-DCMAKE_C_FLAGS='-flto' &&
make -j2 && make install
working-directory: tmx

# Upload
- name: Upload artifact
uses: actions/upload-artifact@v1
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.DIST_PATH }}

windows:
name: Windows Build
runs-on: windows-2016
steps:
- name: Create distribution folder
run: |
$ARTIFACT_NAME=$($Env:GITHUB_REF).substring(10) + "-win"
echo "::set-env name=ARTIFACT_NAME::$ARTIFACT_NAME"
$DIST_PATH="$($Env:GITHUB_WORKSPACE)\$ARTIFACT_NAME"
echo "::set-env name=DIST_PATH::$DIST_PATH"
mkdir "$DIST_PATH"
# Build and install zlib
- name: Checkout zlib
uses: actions/checkout@v2
with:
repository: madler/zlib
path: zlib
ref: ${{ env.zlib_ver }}
- name: Build and Install zlib
run: |
cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=Off `
-DCMAKE_INSTALL_PREFIX="$($Env:DIST_PATH)" &&
mingw32-make -j2 && mingw32-make install
working-directory: zlib

# Build and install libxml2
- name: Checkout libxml2
uses: actions/checkout@v2
with:
repository: GNOME/libxml2
path: libxml2
ref: ${{ env.libxml2_ver }}
- name: Build and Install libxml2
run: |
cscript configure.js prefix="$($Env:DIST_PATH)" compiler=mingw `
c14n=no catalog=no debug=no docb=no ftp=no http=no html=no xpath=no xptr=no xinclude=no iconv=no `
icu=no iso8859x=no zlib=no lzma=no xml_debug=no mem_debug=no run_debug=no schemas=no schematron=no `
regexps=no modules=no pattern=no valid=no sax1=no legacy=no python=no walker=no `
push=yes tree=yes output=yes writer=yes reader=yes &&
mingw32-make -f Makefile.mingw -j2 &&
Move-Item -Path bin.mingw\libxml2.a -Destination "$($Env:DIST_PATH)\lib" &&
New-Item -Path "$($Env:DIST_PATH)\include" -Name "libxml2" -ItemType "directory" &&
New-Item -Path "$($Env:DIST_PATH)\include\libxml2" -Name "libxml" -ItemType "directory" &&
Move-Item -Path "..\include\libxml\*.h" -Destination "$($Env:DIST_PATH)\include\libxml2\libxml"
working-directory: libxml2/win32

# Clean-up
- name: Clean-up
run: |
Remove-Item -Path "$($Env:DIST_PATH)/share" -Recurse
Remove-Item -Path "$($Env:DIST_PATH)/bin" -Recurse
Remove-Item -Path "$($Env:DIST_PATH)/lib/libzlib.dll.a"
# Build and install libTMX
- name: Checkout libTMX
uses: actions/checkout@v2
with:
path: tmx
- name: Build and Install libTMX
run: |
cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$($Env:DIST_PATH)" `
-DCMAKE_PREFIX_PATH="$($Env:DIST_PATH)" &&
mingw32-make -j2 && mingw32-make install
working-directory: tmx

# Upload
- name: Upload artifact
uses: actions/upload-artifact@v1
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.DIST_PATH }}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

---

![Build and Test](https://github.com/baylej/tmx/workflows/Build%20and%20Test/badge.svg)

## About

A portable C library to load [tiled](http://mapeditor.org) maps in your games.

## Dependencies

This project depends on [Zlib](http://zlib.net/) and [LibXml2](http://xmlsoft.org).
This project depends on (optional) [Zlib](http://zlib.net/) and (compulsory) [LibXml2](http://xmlsoft.org).

## Usage

Expand Down

0 comments on commit d5eb225

Please sign in to comment.