- sync with https://github.com/pce-devel/huc #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
# Github Actions aren't supporting anchors yet | |
# upvote here https://github.com/github/feedback/discussions/4501 | |
on: | |
push: | |
pull_request: | |
branches: | |
- master | |
# activating dispatch to allow manual runs | |
# workflow_dispatch: | |
env: | |
MSYS2_INSTALL_FOLDER: C:\msys64\ # provided by GitHub Actions VMs | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [ubuntu-18.04, ubuntu-20.04, macos-11, macos-12, windows-2022] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Check out code from the repository | |
uses: actions/checkout@v3 | |
- name: Build on Linux | |
if: startsWith(matrix.os, 'ubuntu') | |
run: | | |
make | |
echo Build Complete | |
- name: Build on Windows | |
if: startsWith(matrix.os, 'windows') | |
run: | | |
${{ env.MSYS2_INSTALL_FOLDER }}\msys2_shell.cmd -mingw64 -no-start -defterm -c "pacman -S binutils make mingw-w64-x86_64-gcc git --noconfirm" | |
${{ env.MSYS2_INSTALL_FOLDER }}\msys2_shell.cmd -mingw64 -no-start -defterm -where %CD% -c "make" | |
echo Build Complete | |
- name: Build on Mac | |
if: startsWith(matrix.os, 'macos') | |
run: | | |
brew install make # need gnumake | |
gmake | |
echo Build Complete | |
- name: Archive toolchain | |
uses: actions/upload-artifact@v3 | |
with: | |
name: toolchain-${{ matrix.os }} | |
path: | | |
bin | |
examples/**/*.iso | |
examples/**/*.pce | |
examples/**/*.sgx | |
tgemu/tgemu | |
test: | |
strategy: | |
matrix: | |
os: [ubuntu-18.04, ubuntu-20.04, macos-11, macos-12, windows-2022] | |
runs-on: ${{ matrix.os }} | |
needs: build | |
steps: | |
- name: Check out code from the repository | |
uses: actions/checkout@v3 | |
- name: Get previoulsy built artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: toolchain-${{ matrix.os }} | |
- name: Restore Execute Flags | |
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos') | |
run: | | |
chmod +x bin/* # Github Action artifacts don't keep exec flags https://github.com/actions/upload-artifact#permission-loss' | |
chmod +x tgemu/tgemu | |
- name: Run tests on Linux | |
if: startsWith(matrix.os, 'ubuntu') | |
run: | | |
sudo apt-get update && sudo apt-get install -y dos2unix | |
make check | |
make test | |
echo Test Complete | |
- name: Setup Msys2 | |
if: startsWith(matrix.os, 'windows') | |
uses: msys2/setup-msys2@v2 | |
with: | |
msystem: MINGW64 | |
update: true | |
install: coreutils make git dos2unix | |
- name: Run tests on Windows | |
if: startsWith(matrix.os, 'windows') | |
shell: msys2 {0} | |
run: | | |
make check | |
make test | |
echo Build Complete | |
- name: Run tests on Mac | |
if: startsWith(matrix.os, 'macos') | |
run: | | |
brew install make md5sha1sum dos2unix # need gnumake and md5sum to run make check | |
gmake check | |
gmake test | |
echo Build Complete | |
package: | |
strategy: | |
matrix: | |
os: [ubuntu-20.04, macos-12, windows-2022] | |
runs-on: ${{ matrix.os }} | |
needs: build | |
steps: | |
- name: Check out code from the repository | |
uses: actions/checkout@v3 | |
- name: Get previoulsy built artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: toolchain-${{ matrix.os }} | |
- name: Package ${{ matrix.os }} | |
if: startsWith(matrix.os, 'ubuntu') | |
run: | | |
make package | |
echo Package Complete | |
- name: Package ${{ matrix.os }} | |
if: startsWith(matrix.os, 'windows') | |
run: | | |
${{ env.MSYS2_INSTALL_FOLDER }}\msys2_shell.cmd -mingw64 -no-start -defterm -c "pacman -S binutils make git zip --noconfirm" | |
${{ env.MSYS2_INSTALL_FOLDER }}\msys2_shell.cmd -mingw64 -no-start -defterm -where %CD% -c "make package" | |
echo Package Complete | |
- name: Package ${{ matrix.os }} | |
if: startsWith(matrix.os, 'macos') | |
run: | | |
brew install make # need gnumake | |
gmake package | |
echo Package Complete | |
- name: Archive package | |
uses: actions/upload-artifact@v3 | |
with: | |
name: package-${{ matrix.os }} | |
path: | | |
*.zip | |
if-no-files-found: error | |
publish_package: | |
runs-on: ubuntu-latest | |
needs: [package, test] | |
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' | |
steps: | |
- name: Check out code from the repository | |
uses: actions/checkout@v3 | |
- name: Get previoulsy built artifacts win64 | |
uses: actions/download-artifact@v3 | |
with: | |
name: package-windows-2022 | |
- name: Get previoulsy built artifacts macos | |
uses: actions/download-artifact@v3 | |
with: | |
name: package-macos-12 | |
- name: Get previoulsy built artifacts linux | |
uses: actions/download-artifact@v3 | |
with: | |
name: package-ubuntu-20.04 | |
# https://github.com/pyTooling/Actions/tree/main/releaser | |
# need to use composite on windows, since docker isn't available | |
- name: publish package | |
uses: pyTooling/Actions/releaser@r0 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ github.ref_name }} | |
rm: true # do not keep old latest artifacts | |
files: | | |
*.zip | |