Skip to content

Fix attempt 2

Fix attempt 2 #1231

Workflow file for this run

name: MBINCompiler
permissions:
contents: read
on:
# Run on all branches except for the gh-pages branch
push:
paths-ignore:
- '*.md'
branches-ignore:
- 'gh-pages'
pull_request:
paths-ignore:
- '*.md'
branches-ignore:
- 'gh-pages'
create:
jobs:
build_test:
name: Build artefacts - ${{ matrix.os.name }}/${{ matrix.dotnet.framework }}
runs-on: ${{ matrix.os.name }}-latest
strategy:
fail-fast: false
matrix:
# `bin` is the name the built executable is published/uploaded under. On
# Windows/Ubuntu it keeps the historical `.exe` name; macOS ships a plain
# `MBINCompiler` (a `.exe` on a native macOS binary is misleading).
os:
- {name: 'Ubuntu', runtime: 'linux-x64', bin: 'MBINCompiler'}
- {name: 'Windows', runtime: 'win-x64', bin: 'MBINCompiler.exe'}
- {name: 'macOS', runtime: 'osx-arm64', bin: 'MBINCompiler'}
dotnet: [{framework: 'net10.0', version: '10.0.0'}, {framework: 'net8.0', version: '8.0.0'}]
# We only ship a .NET 8 build for macOS.
exclude:
- os: {name: 'macOS', runtime: 'osx-arm64', bin: 'MBINCompiler'}
dotnet: {framework: 'net10.0', version: '10.0.0'}
steps:
- uses: actions/checkout@v7
- uses: actions/setup-dotnet@v5
with:
# Install both sdk versions.
dotnet-version: |
8.0.100
10.0.100
- name: Build ${{ matrix.os.name }}-dotnet ${{ matrix.dotnet.framework }} binaries
# Pin the runtime patch version via an MSBuild property rather than
# editing the csproj with `sed`. This avoids GNU-vs-BSD `sed -i`
# incompatibilities (the macOS runner ships BSD sed) and is equivalent.
run: |
dotnet publish libMBIN-DLL --no-self-contained -c Release -f ${{ matrix.dotnet.framework }} -r ${{ matrix.os.runtime }} -p:RuntimeFrameworkVersion=${{ matrix.dotnet.version }}
dotnet publish MBINCompiler --no-self-contained -c Release -f ${{ matrix.dotnet.framework }} -r ${{ matrix.os.runtime }} -p:RuntimeFrameworkVersion=${{ matrix.dotnet.version }}
- name: Move the binary so the tests can find it
shell: bash
run: |
mkdir -p binaries
cp "Build/Release/${{ matrix.dotnet.framework }}/${{ matrix.os.runtime }}/publish/${{ matrix.os.bin }}" "binaries/${{ matrix.os.bin }}"
cp "Build/Release/${{ matrix.dotnet.framework }}/${{ matrix.os.runtime }}/publish/libMBIN.dll" binaries/libMBIN.dll
chmod +x "binaries/${{ matrix.os.bin }}"
- name: Set up Python 3.10
uses: actions/setup-python@v6
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip uv
uv sync
- name: Run tests
run: uv run python -m pytest --mbincompiler_path="./binaries/${{ matrix.os.bin }}" --tb=no --report
- name: Upload ${{ matrix.os.name }} binaries
uses: actions/upload-artifact@v7
with:
name: MBINCompiler-${{ matrix.os.name }}-${{ matrix.dotnet.framework }}
if-no-files-found: error
path: |
Build/Release/${{ matrix.dotnet.framework }}/${{ matrix.os.runtime }}/publish/${{ matrix.os.bin }}
Build/Release/${{ matrix.dotnet.framework }}/${{ matrix.os.runtime }}/publish/libMBIN.dll
if: ${{ matrix.os.name != 'macOS' }}
- name: Package macOS archive (CLI + droplet + Quick Action)
# Assemble on macOS so `ditto` preserves the droplet .app bundle (its exec
# bits / signature would be lost if zipped by the Windows release job or by
# the loose-file artifact uploader). libMBIN is embedded in the single-file
# binary, so it is NOT bundled in the zip — it ships separately (like the
# other platforms) for anyone who wants the library on its own.
run: |
PUB="Build/Release/${{ matrix.dotnet.framework }}/${{ matrix.os.runtime }}/publish"
STAGE="MBINCompiler-macOS"
rm -rf "$STAGE"; mkdir -p "$STAGE"
cp "$PUB/MBINCompiler" "$STAGE/MBINCompiler"
cp packaging/macos/install-cli.sh "$STAGE/install.sh"
cp -R packaging/macos/MBINCompiler-QuickAction.workflow "$STAGE/"
osacompile -o "$STAGE/MBINCompiler Droplet.app" packaging/macos/droplet.applescript
chmod +x "$STAGE/MBINCompiler" "$STAGE/install.sh"
ditto -c -k --keepParent "$STAGE" MBINCompiler-macOS.zip
if: ${{matrix.os.name == 'macOS' }}
- name: Upload macOS archive
uses: actions/upload-artifact@v7
with:
name: MBINCompiler-${{ matrix.os.name }}-${{ matrix.dotnet.framework }}
if-no-files-found: error
path: |
MBINCompiler-macOS.zip
Build/Release/${{ matrix.dotnet.framework }}/${{ matrix.os.runtime }}/publish/libMBIN.dll
if: ${{ matrix.os.name == 'macOS' }}
- name: Upload report
uses: actions/upload-artifact@v7
with:
name: MBINCompiler-report
if-no-files-found: error
path: report.json
if: ${{matrix.os.name == 'Windows' && matrix.dotnet.framework == 'net8.0'}}
save_mapping:
name: Build save file mapping and generate mapping
runs-on: Windows-latest
steps:
- uses: actions/checkout@v7
- name: Build SaveFileMapping binary
run: dotnet publish SaveFileMapping -c Release -f net8.0 -r win-x64 -o Build/Release/net8/
- name: Generate save data mapping
run : Build/Release/net8/SaveFileMapping.exe
shell: bash
- name: Upload report
uses: actions/upload-artifact@v7
with:
name: savedata-mapping
if-no-files-found: error
path: mapping.json
release:
name: Release MBINCompiler binaries and other data
# Only run this job if the commit was tagged.
if: ${{ startsWith(github.ref, 'refs/tags/') }}
runs-on: windows-latest
needs: [build_test, save_mapping]
permissions:
contents: write
steps:
- name: Download files for release
uses: actions/download-artifact@v8
- name: Rename files for release
run: |
mv MBINCompiler-Windows-net10.0/MBINCompiler.exe MBINCompiler-dotnet10.exe
mv MBINCompiler-Windows-net10.0/libMBIN.dll libMBIN-dotnet10.dll
mv MBINCompiler-Windows-net8.0/MBINCompiler.exe MBINCompiler.exe
mv MBINCompiler-Windows-net8.0/libMBIN.dll libMBIN.dll
mv MBINCompiler-Ubuntu-net10.0/MBINCompiler MBINCompiler-linux-dotnet10
mv MBINCompiler-Ubuntu-net10.0/libMBIN.dll libMBIN-linux-dotnet10.so
mv MBINCompiler-Ubuntu-net8.0/MBINCompiler MBINCompiler-linux
mv MBINCompiler-Ubuntu-net8.0/libMBIN.dll libMBIN-linux.so
mv MBINCompiler-macOS-net8.0/MBINCompiler-macOS.zip MBINCompiler-macOS.zip
mv MBINCompiler-macOS-net8.0/Build/Release/net8.0/osx-arm64/publish/libMBIN.dll libMBIN-mac.dll
mv savedata-mapping/mapping.json mapping.json
mv MBINCompiler-report/report.json report.json
- name: Get MBINCompiler tag version
run: |
echo "VERSION=$(./MBINCompiler.exe version | awk '{print $2}')" >> $GITHUB_ENV
echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
shell: bash
- name: Upload resources if version matches
if: env.VERSION == env.TAG
uses: softprops/action-gh-release@v3
with:
name: "${{ env.TAG }}"
tag_name: ${{ env.TAG }}
prerelease: true
files: |
MBINCompiler.exe
libMBIN.dll
MBINCompiler-dotnet10.exe
libMBIN-dotnet10.dll
MBINCompiler-linux
libMBIN-linux.so
MBINCompiler-linux-dotnet10
libMBIN-linux-dotnet10.so
MBINCompiler-macOS.zip
libMBIN-mac.dll
report.json
mapping.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check if tag doesn't match version
if: env.VERSION != env.TAG
run: |
echo "There is a version mismatch between the tag and MBINCompiler version!"
echo "MBINCompiler version: ${{ env.VERSION }}"
echo "Tag version: ${{ env.TAG }}"
exit 1
shell: bash