Skip to content

Simplify CI workflows (DRY) with scripts #121

Simplify CI workflows (DRY) with scripts

Simplify CI workflows (DRY) with scripts #121

Workflow file for this run

name: CI
on:
push:
branches: [master, dev, development, feature/**, bugfix/**, pr/**]
pull_request:
workflow_dispatch:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
prepare:
name: General preparations
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set outputs
id: vars
run: echo "short_sha=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT
- name: Check outputs
run: echo "short_sha = ${{ steps.vars.outputs.short_sha }}"
outputs:
short_sha: ${{ steps.vars.outputs.short_sha }}
dist:
name: Distribution archives
needs: prepare
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: |
sudo apt-get update -yqq
sudo apt-get install -yqq git asciidoctor w3m
- name: Checkout
uses: actions/checkout@v4
- name: Generate Archives
env:
SHORT_SHA: ${{ needs.prepare.outputs.short_sha }}
run: |
builds/ci/adoc2man ${SHORT_SHA} < res/unix/OpenJazz.6.adoc > OpenJazz.6
git archive -o openjazz-${SHORT_SHA}.tar.gz \
--prefix=openjazz-${SHORT_SHA}/res/unix/ --add-file=OpenJazz.6 \
--prefix=openjazz-${SHORT_SHA}/ ${GITHUB_SHA}
git archive -o openjazz-${SHORT_SHA}.zip --prefix=openjazz-${SHORT_SHA}/ ${GITHUB_SHA}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: openjazz-dist
path: openjazz-*.*
linux-gcc:
name: Build (Ubuntu x86_64, GCC, SDL1.2)
needs: prepare
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: |
sudo apt-get update -yqq
sudo apt-get install -yqq build-essential libsdl1.2-dev
- name: Checkout
uses: actions/checkout@v4
- name: Build OpenJazz (normal)
run: |
export MAKEFLAGS=-j$(nproc)
make
ls -l OpenJazz
linux-clang:
name: Build (Ubuntu 20.04 LTS x86_64, Clang, SDL2)
needs: prepare
runs-on: ubuntu-20.04
steps:
- name: Install dependencies
run: |
sudo apt-get update -yqq
sudo apt-get install -yqq build-essential cmake ninja-build clang-10 \
libsdl2-dev asciidoctor w3m
- name: Checkout
uses: actions/checkout@v4
- name: Build OpenJazz (slim)
run: |
export CXX=clang++
export CXXFLAGS="-Wall -O2 -g -ffunction-sections -fdata-sections"
export LDFLAGS="-Wl,--gc-sections"
cmake --workflow --preset release
ls -l build-release/OpenJazz
build-release/OpenJazz --version
- name: Prepare artifact
env:
SHORT_SHA: ${{ needs.prepare.outputs.short_sha }}
run: |
mkdir OJ-${SHORT_SHA}
builds/ci/adoc2txt ${SHORT_SHA} < res/unix/OpenJazz.6.adoc > OJ-${SHORT_SHA}/Manual.txt
cp build-release/OpenJazz README.md COPYING licenses.txt OJ-${SHORT_SHA}/
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: openjazz-linux-glibc2.31-x86_64
path: OJ-*/
windows-mingw-gcc:
name: Build (Windows x86_64, MinGW, GCC)
needs: prepare
runs-on: windows-2019
defaults:
run:
shell: msys2 {0}
steps:
- uses: msys2/setup-msys2@v2
with:
update: true
install: |
base-devel dos2unix w3m
pacboy: |
toolchain:p cmake:p ninja:p SDL2:p asciidoctor:p
- name: Checkout
uses: actions/checkout@v4
- name: Build OpenJazz
run: |
cmake --workflow --preset release
- name: Prepare artifact
env:
SHORT_SHA: ${{ needs.prepare.outputs.short_sha }}
run: |
cmake --install build-release --prefix $PWD
cp /mingw64/bin/SDL2.dll dist/
builds/ci/adoc2html ${SHORT_SHA} < res/unix/OpenJazz.6.adoc > dist/OpenJazzManual.html
builds/ci/docs2dist dist
mv dist OJ-${SHORT_SHA}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: openjazz-windows-mingw-x86_64
path: OJ-*/
wii-devkitppc:
name: Build (Wii, devkitPPC)
needs: prepare
runs-on: ubuntu-latest
container: devkitpro/devkitppc:latest
steps:
- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -yqq ninja-build dos2unix asciidoctor w3m
- name: Checkout
uses: actions/checkout@v4
- name: Build OpenJazz
run: |
$DEVKITPRO/portlibs/wii/bin/powerpc-eabi-cmake -G Ninja -B build . -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build
- name: Prepare artifact
env:
SHORT_SHA: ${{ needs.prepare.outputs.short_sha }}
run: |
cmake --install build --prefix $PWD
builds/ci/adoc2txt ${SHORT_SHA} < res/unix/OpenJazz.6.adoc > OpenJazz/Manual.txt
builds/ci/docs2dist OpenJazz
mv OpenJazz OJ-${SHORT_SHA}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: openjazz-wii
path: OJ-*/
n3ds-devkitarm:
name: Build (3DS, devkitARM)
needs: prepare
runs-on: ubuntu-latest
container: devkitpro/devkitarm:latest
steps:
- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -yqq ninja-build dos2unix asciidoctor w3m
- name: Checkout
uses: actions/checkout@v4
- name: Build OpenJazz
run: |
$DEVKITPRO/portlibs/3ds/bin/arm-none-eabi-cmake -G Ninja -B build . -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build
- name: Prepare artifact
env:
SHORT_SHA: ${{ needs.prepare.outputs.short_sha }}
run: |
cmake --install build --prefix $PWD
builds/ci/adoc2txt ${SHORT_SHA} < res/unix/OpenJazz.6.adoc > OpenJazz/Manual.txt
builds/ci/docs2dist OpenJazz
mv OpenJazz OJ-${SHORT_SHA}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: openjazz-3ds
path: OJ-*/
riscos-gccsdk:
name: Build (RISC OS, GCCSDK 4.7)
needs: prepare
runs-on: ubuntu-latest
container: riscosdotinfo/riscos-gccsdk-4.7:latest
steps:
- name: Install dependencies
run: |
apt-get update -qq
apt-get install -yqq cmake ninja-build
- name: Prepare GCCSDK autobuilder and build SDL
run: |
cp /usr/bin/false /usr/bin/automake-1.11 # autobuilder wants this, sdl does not need it
cp /usr/bin/false /usr/bin/meson # autobuilder wants this, sdl does not need it
svn co svn://svn.riscos.info/gccsdk/trunk/autobuilder/ autobuilder # todo: maybe use snapshot
mkdir sdl-build
cd sdl-build
../autobuilder/build -v libsdl1.2debian # todo: cache?
- name: Checkout
uses: actions/checkout@v4
- name: Build OpenJazz
run: |
cmake -G Ninja -B build . -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=/home/riscos/env/toolchain-riscos.cmake -DRISCOS=ON
cmake --build build
- name: Prepare artifact
env:
SHORT_SHA: ${{ needs.prepare.outputs.short_sha }}
run: |
cmake --install build --prefix $PWD
cp README.md COPYING licenses.txt !OpenJazz/
mkdir OJ-${SHORT_SHA}
mv !OpenJazz OJ-${SHORT_SHA}/
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: openjazz-riscos
path: OJ-*/
psp-pspdev:
name: Build (PSP, pspdev)
needs: prepare
runs-on: ubuntu-latest
container: pspdev/pspdev:latest
steps:
- name: Install dependencies
run: |
apk add git cmake ninja asciidoctor w3m
- name: Checkout
uses: actions/checkout@v4
- name: Build OpenJazz
run: |
cmake --preset=psp-release -DNETWORK=OFF
cmake --build --preset=psp-release
- name: Prepare artifact
env:
SHORT_SHA: ${{ needs.prepare.outputs.short_sha }}
run: |
cmake --install build-psp-release --prefix $PWD
builds/ci/adoc2txt ${SHORT_SHA} < res/unix/OpenJazz.6.adoc > OpenJazz/Manual.txt
builds/ci/docs2dist OpenJazz
mv OpenJazz OJ-${SHORT_SHA}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: openjazz-psp
path: OJ-*/
prerelease:
name: Create Pre-release
needs:
# all
- dist
- linux-clang
- windows-mingw-gcc
- wii-devkitppc
- n3ds-devkitarm
- riscos-gccsdk
- psp-pspdev
# allow run when some platform jobs failed, but not for tags
if: always() && !startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: builds/ci
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Zip artifacts and inspect directory
run: |
mv openjazz-dist dist
builds/ci/dir2zip openjazz-*
ls -l
- name: Create Pre-release and upload artifacts
uses: softprops/action-gh-release@v1
# only on master branch
#if: github.ref == 'refs/heads/master'
with:
draft: true
prerelease: true
tag_name: continuous
generate_release_notes: true
files: |
openjazz-*.*
dist/*.*