xemu/.github/workflows/build.yml
2020-06-07 20:33:11 -07:00

301 lines
10 KiB
YAML

name: Build
on: [push, pull_request]
jobs:
Init:
runs-on: ubuntu-latest
steps:
- name: Create Build Tag
run: |
export BUILD_TAG=build-$(date -u +'%Y%m%d%H%M')
echo "::set-env name=BUILD_TAG::$BUILD_TAG"
mkdir -p dist
echo -n $BUILD_TAG > dist/tag
- name: Upload Artifacts
uses: actions/upload-artifact@v1
with:
name: dist
path: dist
Windows:
runs-on: windows-latest
needs: Init
strategy:
matrix:
configuration: ["Debug", "Release"]
steps:
- name: Define Build Options
shell: python
run: |
if "${{ matrix.configuration }}" == "Debug":
print('Configuring for Debug')
print('::set-env name=BUILD_PARAM::--debug')
print('::set-env name=ARTIFACT_NAME::xemu-win-debug.zip')
else:
print('Configuring for Release')
print('::set-env name=BUILD_PARAM::')
print('::set-env name=ARTIFACT_NAME::xemu-win-release.zip')
- name: Clone Tree
uses: actions/checkout@v2
- name: Clone Tree (Unshallow)
run: |
git fetch --prune --unshallow --tags
- name: Install Dependencies
run: |
echo "Downloading MSYS2 environment..."
Invoke-WebRequest -Uri "https://github.com/mborgerson/xemu-msys2/releases/latest/download/msys64.7z" -OutFile "msys64.7z"
echo "Extracting MSYS2 environment..."
7z x -y msys64.7z "-oC:\tools\"
echo "Updating MSYS2 environment..."
C:\tools\msys64\usr\bin\bash.exe -lc "pacman -Syu --noconfirm"
C:\tools\msys64\usr\bin\bash.exe -lc "pacman -S --noconfirm --needed libcurl-devel"
# - name: Initialize Compiler Cache
# id: cache
# uses: actions/cache@v1
# with:
# path: C:\tools\msys64\tmp\xemu-ccache
# key: cache-${{ runner.os }}-${{ matrix.configuration }}-${{ github.sha }}
# restore-keys: cache-${{ runner.os }}-${{ matrix.configuration }}-
- name: Compile
run: |
C:\tools\msys64\usr\bin\bash.exe -lc @"
set -e
cd `$GITHUB_WORKSPACE
# export CCACHE_DIR=/tmp/xemu-ccache
# export CCACHE_MAXSIZE=250M
# export PATH="/usr/lib/ccache/bin:/mingw64/bin:`$PATH"
export PATH="/mingw64/bin:`$PATH"
./build.sh ${{ env.BUILD_PARAM }}
# echo -e '\nCompiler Cache Stats:'
# ccache -s -c
"@
7z a ${{env.ARTIFACT_NAME}} .\dist\*
- name: Upload Build Artifact
uses: actions/upload-artifact@v1
with:
name: dist
path: ${{env.ARTIFACT_NAME}}
Ubuntu:
runs-on: ubuntu-latest
needs: Init
strategy:
matrix:
configuration: ["Debug", "Release"]
steps:
- name: Define Build Options
shell: python
run: |
if "${{ matrix.configuration }}" == "Debug":
print('Configuring for Debug')
print('::set-env name=BUILD_PARAM::--debug')
print('::set-env name=ARTIFACT_NAME::xemu-ubuntu-debug.tgz')
else:
print('Configuring for Release')
print('::set-env name=BUILD_PARAM::')
print('::set-env name=ARTIFACT_NAME::xemu-ubuntu-release.tgz')
- name: Clone Tree
uses: actions/checkout@v2
- name: Clone Tree (Unshallow)
run: |
git fetch --prune --unshallow --tags
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libepoxy-dev \
libgtk-3-dev \
libpixman-1-dev \
libsdl2-dev \
ccache \
libcurl4-gnutls-dev
- name: Initialize Compiler Cache
id: cache
uses: actions/cache@v1
with:
path: /tmp/xemu-ccache
key: cache-${{ runner.os }}-${{ matrix.configuration }}-${{ github.sha }}
restore-keys: cache-${{ runner.os }}-${{ matrix.configuration }}-
- name: Compile
run: |
export CCACHE_DIR=/tmp/xemu-ccache
export CCACHE_MAXSIZE=250M
export PATH="/usr/lib/ccache:$PATH"
./build.sh ${{ env.BUILD_PARAM }}
echo -e "\nCompiler Cache Stats:"
ccache -s -c
tar -czvf ${{env.ARTIFACT_NAME}} --transform "s#^dist#xemu#" dist
- name: Upload Build Artifact
uses: actions/upload-artifact@v1
with:
name: dist
path: ${{env.ARTIFACT_NAME}}
macOS:
runs-on: macOS-latest
needs: Init
strategy:
matrix:
configuration: ["Debug", "Release"]
steps:
- name: Define Build Options
shell: python
run: |
if "${{ matrix.configuration }}" == "Debug":
print('Configuring for Debug')
print('::set-env name=BUILD_PARAM::--debug')
print('::set-env name=ARTIFACT_NAME::xemu-macos-debug.zip')
else:
print('Configuring for Release')
print('::set-env name=BUILD_PARAM::')
print('::set-env name=ARTIFACT_NAME::xemu-macos-release.zip')
- name: Clone Tree
uses: actions/checkout@v2
- name: Clone Tree (Unshallow)
run: |
git fetch --prune --unshallow --tags
- name: Install Dependencies
run: |
brew update
brew unlink python@2
brew install \
ccache \
coreutils \
dylibbundler \
libepoxy \
pixman \
pkg-config \
sdl2
- name: Initialize Compiler Cache
id: cache
uses: actions/cache@v1
with:
path: /tmp/xemu-ccache
key: cache-${{ runner.os }}-${{ matrix.configuration }}-${{ github.sha }}
restore-keys: cache-${{ runner.os }}-${{ matrix.configuration }}-
- name: Compile
run: |
export CCACHE_DIR=/tmp/xemu-ccache
export CCACHE_MAXSIZE=250M
export PATH="/usr/local/opt/ccache/libexec:$PATH"
./build.sh ${{ env.BUILD_PARAM }}
echo -e "\nCompiler Cache Stats:"
ccache -s -c
pushd dist
zip -r ../${{env.ARTIFACT_NAME}} xemu.app
popd
- name: Upload Build Artifact
uses: actions/upload-artifact@v1
with:
name: dist
path: ${{env.ARTIFACT_NAME}}
Release:
runs-on: ubuntu-latest
needs: [Ubuntu, Windows, macOS]
env:
BUILD_TAG:
steps:
- name: Download Artifacts
uses: actions/download-artifact@v1
with:
name: dist
- name: Get Package Info
run: |
echo "::set-env name=BUILD_TAG::$(cat dist/tag)"
- name: Create Release
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.BUILD_TAG }}
release_name: ${{ env.BUILD_TAG }}
draft: false
prerelease: false
- name: Upload Release Assets (Windows Debug Build)
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
id: upload-release-asset-win-debug
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_name: xemu-win-debug.zip
asset_path: dist/xemu-win-debug.zip
asset_content_type: application/zip
- name: Upload Release Assets (Windows Release Build)
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
id: upload-release-asset-win-release
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_name: xemu-win-release.zip
asset_path: dist/xemu-win-release.zip
asset_content_type: application/zip
- name: Upload Release Assets (macOS Release Build)
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
id: upload-release-asset-macos-release
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_name: xemu-macos-release.zip
asset_path: dist/xemu-macos-release.zip
asset_content_type: application/zip
- name: Upload Release Assets (macOS Debug Build)
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
id: upload-release-asset-macos-debug
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_name: xemu-macos-debug.zip
asset_path: dist/xemu-macos-debug.zip
asset_content_type: application/zip
# Sync archive version of source (including submodule code) to the
# ppa-snapshot branch to work around limitations of the Launchpad platform,
# namely: no network egress on package build, no custom scripting in source
# package creation.
PushToPPA:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [Ubuntu, Windows, macOS]
runs-on: ubuntu-latest
steps:
- name: Clone Tree
uses: actions/checkout@v2
- name: Clone Tree (Unshallow)
run: |
git fetch --prune --unshallow --tags
- name: Create Source Archive
run: |
./scripts/archive-source.sh archive.tgz
mkdir archive
pushd archive
tar xf ../archive.tgz
popd
- name: Integrate Debian Packaging
run: |
# Clone deb branch containing packaging files
git clone --branch=deb --depth=1 https://github.com/mborgerson/xemu.git /tmp/xemu-debian
mv /tmp/xemu-debian/debian archive
# Create changelog containing current version
echo -e "xemu (1:$(cat archive/XEMU_VERSION)-0) unstable; urgency=medium\n" > archive/debian/changelog
echo -e " Built from $(cat archive/XEMU_VERSION)\n" >> archive/debian/changelog
echo " -- Matt Borgerson <contact@mborgerson.com> $(date -R)" >> archive/debian/changelog
- name: Deploy Source Archive to Branch
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./archive
publish_branch: ppa-snapshot
force_orphan: true