Skip to content

Commit

Permalink
Simplify CI workflows (DRY) with scripts
Browse files Browse the repository at this point in the history
Create a prerelease from each action run
  • Loading branch information
carstene1ns committed Nov 17, 2023
1 parent 41a0896 commit 049122a
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 61 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ CMakeLists.txt text

# distribution archives
/.github export-ignore
/builds/ci export-ignore
168 changes: 107 additions & 61 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,71 @@ defaults:
shell: bash

jobs:
linux-gcc:
name: Build (Ubuntu 20.04 LTS x86_64, GCC, SDL1.2)
runs-on: ubuntu-20.04
prepare:
name: General preparations
runs-on: ubuntu-latest
outputs:
short_sha: ${{ steps.vars.outputs.short_sha }}
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 ${{ 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 build-essential libsdl1.2-dev
sudo apt-get install -yqq git asciidoctor w3m
- name: Checkout
uses: actions/checkout@v4

- name: Prepare Environment
- name: Generate Archives
env:
SHORT_SHA: ${{ needs.prepare.outputs.short_sha }}
run: |
echo "SHORT_SHA=${GITHUB_SHA:0:10}" >> $GITHUB_ENV
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
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
Expand All @@ -47,10 +88,6 @@ jobs:
sudo apt-get install -yqq build-essential cmake ninja-build clang-10 \
libsdl2-dev asciidoctor w3m
- name: Prepare Environment
run: |
echo "SHORT_SHA=${GITHUB_SHA:0:10}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4

Expand All @@ -59,16 +96,17 @@ jobs:
export CXX=clang++
export CXXFLAGS="-Wall -O2 -g -ffunction-sections -fdata-sections"
export LDFLAGS="-Wl,--gc-sections"
cmake -G Ninja -B build . -DCMAKE_BUILD_TYPE=Release
cmake --build build
ls -l build/OpenJazz
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}
asciidoctor -o OpenJazzManual.html -a oj_version=${SHORT_SHA} res/unix/OpenJazz.6.adoc
w3m -dump -cols 2147483647 -s OpenJazzManual.html > OJ-${SHORT_SHA}/Manual.txt
cp build/OpenJazz README.md COPYING licenses.txt 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
Expand All @@ -78,6 +116,7 @@ jobs:

windows-mingw-gcc:
name: Build (Windows x86_64, MinGW, GCC)
needs: prepare
runs-on: windows-2019
defaults:
run:
Expand All @@ -91,10 +130,6 @@ jobs:
pacboy: |
toolchain:p cmake:p ninja:p SDL2:p asciidoctor:p
- name: Prepare Environment
run: |
echo "SHORT_SHA=${GITHUB_SHA:0:10}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4

Expand All @@ -103,15 +138,13 @@ jobs:
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/
asciidoctor -o OpenJazzManual.html -a oj_version=${SHORT_SHA} res/unix/OpenJazz.6.adoc
w3m -dump -cols 2147483647 -s OpenJazzManual.html > dist/Manual.txt
cp README.md dist/README.txt
cp COPYING dist/COPYING.txt
cp licenses.txt dist/
unix2dos dist/*.txt
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
Expand All @@ -122,6 +155,7 @@ jobs:

wii-devkitppc:
name: Build (Wii, devkitPPC)
needs: prepare
runs-on: ubuntu-latest
container: devkitpro/devkitppc:latest
steps:
Expand All @@ -130,10 +164,6 @@ jobs:
sudo apt-get update -qq
sudo apt-get install -yqq ninja-build dos2unix asciidoctor w3m
- name: Prepare Environment
run: |
echo "SHORT_SHA=${GITHUB_SHA:0:10}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4

Expand All @@ -143,14 +173,12 @@ jobs:
cmake --build build
- name: Prepare artifact
env:
SHORT_SHA: ${{ needs.prepare.outputs.short_sha }}
run: |
cmake --install build --prefix $PWD
asciidoctor -o OpenJazzManual.html -a oj_version=${SHORT_SHA} res/unix/OpenJazz.6.adoc
w3m -dump -cols 2147483647 -s OpenJazzManual.html > OpenJazz/Manual.txt
cp README.md OpenJazz/README.txt
cp COPYING OpenJazz/COPYING.txt
cp licenses.txt OpenJazz/
unix2dos OpenJazz/*.txt
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
Expand All @@ -161,6 +189,7 @@ jobs:

n3ds-devkitarm:
name: Build (3DS, devkitARM)
needs: prepare
runs-on: ubuntu-latest
container: devkitpro/devkitarm:latest
steps:
Expand All @@ -169,10 +198,6 @@ jobs:
sudo apt-get update -qq
sudo apt-get install -yqq ninja-build dos2unix asciidoctor w3m
- name: Prepare Environment
run: |
echo "SHORT_SHA=${GITHUB_SHA:0:10}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4

Expand All @@ -182,14 +207,12 @@ jobs:
cmake --build build
- name: Prepare artifact
env:
SHORT_SHA: ${{ needs.prepare.outputs.short_sha }}
run: |
cmake --install build --prefix $PWD
asciidoctor -o OpenJazzManual.html -a oj_version=${SHORT_SHA} res/unix/OpenJazz.6.adoc
w3m -dump -cols 2147483647 -s OpenJazzManual.html > OpenJazz/Manual.txt
cp README.md OpenJazz/README.txt
cp COPYING OpenJazz/COPYING.txt
cp licenses.txt OpenJazz/
unix2dos OpenJazz/*.txt
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
Expand All @@ -200,6 +223,7 @@ jobs:

riscos-gccsdk:
name: Build (RISC OS, GCCSDK 4.7)
needs: prepare
runs-on: ubuntu-latest
container: riscosdotinfo/riscos-gccsdk-4.7:latest
steps:
Expand All @@ -208,10 +232,6 @@ jobs:
apt-get update -qq
apt-get install -yqq cmake ninja-build
- name: Prepare Environment
run: |
echo "SHORT_SHA=${GITHUB_SHA:0:10}" >> $GITHUB_ENV
- 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
Expand All @@ -231,6 +251,8 @@ jobs:
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/
Expand All @@ -245,17 +267,14 @@ jobs:

psp-pspdev:
name: Build (PSP, pspdev)
needs: prepare
runs-on: ubuntu-latest
container: pspdev/pspdev:latest
steps:
- name: Install dependencies
run: |
apk add cmake ninja asciidoctor w3m
- name: Prepare Environment
run: |
echo "SHORT_SHA=${GITHUB_SHA:0:10}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4

Expand All @@ -265,18 +284,45 @@ jobs:
cmake --build --preset=psp-release
- name: Prepare artifact
env:
SHORT_SHA: ${{ needs.prepare.outputs.short_sha }}
run: |
cmake --install build-psp-release --prefix $PWD
asciidoctor -o OpenJazzManual.html -a oj_version=${SHORT_SHA} res/unix/OpenJazz.6.adoc
w3m -dump -cols 2147483647 -s OpenJazzManual.html > OpenJazz/Manual.txt
cp README.md OpenJazz/README.txt
cp COPYING OpenJazz/COPYING.txt
cp licenses.txt OpenJazz/
unix2dos OpenJazz/*.txt
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
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v3

- name: Inspect directory after downloading artifacts
run: ls -alFR

- name: Create release (on master branch) and upload artifacts
#if: github.ref == 'refs/heads/master'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CHANGELOG_TYPE: standard
run: |
wget -q https://github.com/TheAssassin/pyuploadtool/releases/download/continuous/pyuploadtool-x86_64.AppImage
chmod +x pyuploadtool-x86_64.AppImage
./pyuploadtool-x86_64.AppImage OpenJazz-*.*
5 changes: 5 additions & 0 deletions builds/ci/adoc2html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

test -z $1 && exit 1

exec asciidoctor -a oj_version=$release -b html5 -
5 changes: 5 additions & 0 deletions builds/ci/adoc2man
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

test -z $1 && exit 1

exec asciidoctor -a oj_version=$release -b manpage -
6 changes: 6 additions & 0 deletions builds/ci/adoc2txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

test -z $1 && exit 1

exec asciidoctor -a oj_version=$release -b html5 - | \
w3m -dump -cols 2147483647 -s -T text/html
8 changes: 8 additions & 0 deletions builds/ci/docs2dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

test -z $1 && exit 1

cp README.md $1/README.txt
cp COPYING $1/COPYING.txt
cp licenses.txt $1/
unix2dos $1/*.txt

0 comments on commit 049122a

Please sign in to comment.