Skip to content

build-and-release

build-and-release #163

Workflow file for this run

name: Build OXCE-XP
# on:
# push:
# branches:
# - main
# pull_request:
# branches:
# - main
on:
repository_dispatch:
types: [build-and-release]
workflow_dispatch:
inputs:
oxce-ref:
description: 'The reference (branch or commit) to build from the OpenXcom repository'
required: true
default: 'oxce-plus'
mxe-version:
description: 'The MXE version to use'
required: true
default: '7e39b555dee5e906b24a44940055dc28d4056d23'
gcc-version:
description: 'The GCC version to use'
required: true
default: '11'
enable-tmate:
description: 'Enable tmate session for debugging'
required: false
default: 'false'
permissions:
contents: write
jobs:
build-mxe:
uses: ./.github/workflows/build-mxe.yml
with:
MXE_VERSION: ${{ github.event.inputs.mxe-version || '7e39b555dee5e906b24a44940055dc28d4056d23' }}
GCC_VERSION: ${{ github.event.inputs.gcc-version || '11' }}
build-oxce:
runs-on: ubuntu-22.04
needs:
- build-mxe
env:
MXE_VERSION: ${{ github.event.inputs.mxe-version || '7e39b555dee5e906b24a44940055dc28d4056d23' }}
GCC_VERSION: ${{ github.event.inputs.gcc-version || '11' }}
ENABLE_TMATE: ${{ github.event.inputs.enable-tmate || 'false' }}
steps:
- name: Get MXE from cache (${{ env.MXE_VERSION }}, gcc ${{ env.GCC_VERSION }})
id: cache-mxe
uses: actions/cache@v4
with:
path: /opt/mxe
key: ${{ runner.os }}-mxe-v${{ env.MXE_VERSION }}-gcc${{ env.GCC_VERSION }}
- name: Check if cache was restored
if: steps.cache-mxe.outputs.cache-hit != 'true'
run: |
echo "Cache not found. Failing the job."
exit 1
- name: Get build cache
id: cache-build
uses: actions/cache@v4
with:
path: oxce/build
key: ${{ runner.os }}-oxce-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-oxce-build-
- name: Build
run: |
CACHED_BUILD=0
if [ -d oxce/build ]; then
CACHED_BUILD=1
mv oxce/build _oxce_build
rm -rf oxce
fi
git clone https://github.com/MeridianOXC/OpenXcom.git oxce
if [ -d _oxce_build ]; then
rm -rf oxce/build
mv _oxce_build oxce/build
fi
cd oxce
if [ "${{ github.event_name }}" = "repository_dispatch" ]; then
git checkout ${{ github.event.client_payload.oxce-ref }}
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
git checkout ${{ github.event.inputs.oxce-ref }}
fi
rm -rf deps
if [ $CACHED_BUILD -ne 1 ]; then
mkdir build
fi
cd build
ls -al
export PATH=/opt/mxe/usr/bin:$PATH
/opt/mxe/usr/bin/i686-w64-mingw32.static-cmake -DCMAKE_BUILD_TYPE=Release -DDEV_BUILD=OFF -DBUILD_PACKAGE=OFF ..
make -j$(nproc)
ls -al
- name: Cache build directory
if: always()
uses: actions/cache@v4
with:
path: oxce/build
key: ${{ runner.os }}-oxce-build-${{ github.sha }}
- name: Zip the artifact
run: |
cd oxce/build/bin
rm libopenxcom.dll.a
zip -r ../../../oxce-winxp.zip .
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: oxce-winxp
path: |
oxce/build/bin
!oxce/build/bin/libopenxcom.dll.a
- name: Determine tag name
id: determine_tag
run: |
if [ "${{ github.event_name }}" = "repository_dispatch" ]; then
echo "tag=${{ github.event.client_payload.tag }}" >> $GITHUB_ENV
else
echo "tag=${{ github.ref_name }}" >> $GITHUB_ENV
fi
echo "value of tag = $tag"
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.tag }}
release_name: Release ${{ env.tag }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: oxce-winxp.zip
asset_name: oxce-winxp-${{ env.tag }}.zip
asset_content_type: application/zip
- name: Setup tmate session
if: failure() && env.ENABLE_TMATE == 'true'
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
timeout-minutes: 120
- name: Keep tmate session alive
if: failure() && env.ENABLE_TMATE == 'true'
run: |
echo "tmate session is active. It will stay alive for a maximum of 2 hours."
SECONDS=0
while [ $SECONDS -lt 7200 ]; do
sleep 30
done
# - name: Setup tmate session
# if: always()
# uses: mxschmitt/action-tmate@v3
# timeout-minutes: 30 if: failure() && env.ENABLE_TMATE == 'true'