add WSL to CI build #244
This file contains hidden or 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 | |
| on: [push, pull_request] | |
| jobs: | |
| param: | |
| name: Determine parameter | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - id: param | |
| run: | | |
| python3 <<EOF >"$GITHUB_OUTPUT" | |
| import json | |
| all_branch = ['16', '15', '14', '13'] | |
| common_profile = [ | |
| '64-mcf', '64-win32', '64-ucrt', '64-msvcrt', | |
| '32-mcf', '32-win32', '32-ucrt', '32-msvcrt', | |
| # profile variants for micro architectures | |
| '64_v2-mcf', '64_v2-win32', '64_v2-ucrt', '64_v2-msvcrt', | |
| ] | |
| all_old_profile = [ | |
| '64-ucrt_ws2003', '64-msvcrt_ws2003', | |
| '32-ucrt_winxp', '32-msvcrt_win2000', | |
| '32_686-msvcrt_win98', | |
| '32_486-msvcrt_win98', | |
| '32_386-msvcrt_win95', | |
| ] | |
| release_old_profile = [ | |
| '32-msvcrt_win2000', | |
| '32_686-msvcrt_win98', | |
| '32_486-msvcrt_win98', | |
| ] | |
| wsl_branch = ['16', '15'] | |
| wsl_profile = ['64_v2-mcf', '64_v2-ucrt'] | |
| sat_group = [ | |
| { | |
| 'name': '64-nt6x', | |
| 'profile': json.dumps(['64-mcf', '64-win32', '64-ucrt', '64-msvcrt']), | |
| 'pattern': '{mingw64-mcf-*,mingw64-win32-*,mingw64-ucrt-*,mingw64-msvcrt-*}', | |
| 'dict': '512m', | |
| }, | |
| { | |
| 'name': '64_v2-nt6x', | |
| 'profile': json.dumps(['64_v2-mcf', '64_v2-win32', '64_v2-ucrt', '64_v2-msvcrt']), | |
| 'pattern': '{mingw64_v2-mcf-*,mingw64_v2-win32-*,mingw64_v2-ucrt-*,mingw64_v2-msvcrt-*}', | |
| 'dict': '512m', | |
| }, | |
| { | |
| 'name': '32-nt6x', | |
| 'profile': json.dumps(['32-mcf', '32-win32', '32-ucrt', '32-msvcrt']), | |
| 'pattern': '{mingw32-mcf-*,mingw32-win32-*,mingw32-ucrt-*,mingw32-msvcrt-*}', | |
| 'dict': '512m', | |
| }, | |
| { | |
| 'name': '64-nt52', | |
| 'profile': json.dumps(['64-ucrt_ws2003', '64-msvcrt_ws2003']), | |
| 'pattern': '{mingw64-ucrt_ws2003-*,mingw64-msvcrt_ws2003-*}', | |
| 'dict': '256m', | |
| }, | |
| { | |
| 'name': '32-nt5x', | |
| 'profile': json.dumps(['32-ucrt_winxp', '32-msvcrt_win2000']), | |
| 'pattern': '{mingw32-ucrt_winxp-*,mingw32-msvcrt_win2000-*}', | |
| 'dict': '256m', | |
| }, | |
| { | |
| 'name': '32_686-9x', | |
| 'profile': json.dumps(['32_686-msvcrt_win98']), | |
| 'pattern': 'mingw32_686-*', | |
| 'dict': '128m', | |
| }, | |
| { | |
| 'name': '32_486-9x', | |
| 'profile': json.dumps(['32_486-msvcrt_win98']), | |
| 'pattern': 'mingw32_486-*', | |
| 'dict': '128m', | |
| }, | |
| { | |
| 'name': '32_386-9x', | |
| 'profile': json.dumps(['32_386-msvcrt_win95']), | |
| 'pattern': 'mingw32_386-*', | |
| 'dict': '128m', | |
| }, | |
| ] | |
| if '${{ github.ref_type }}' == 'tag': | |
| current_branch = '${{ github.ref_name }}'.split('-')[0].split('.')[0] | |
| branch = [current_branch] | |
| profile = common_profile + release_old_profile | |
| release = True | |
| prerelease = int(current_branch) >= 16 | |
| release_xmake = release_old_profile | |
| else: | |
| branch = all_branch | |
| profile = common_profile + all_old_profile | |
| release = False | |
| prerelease = True | |
| release_xmake = all_old_profile | |
| print(f'branch={json.dumps(branch)}') | |
| print(f'profile={json.dumps(profile)}') | |
| print(f'wsl_branch={json.dumps(wsl_branch)}') | |
| print(f'wsl_profile={json.dumps(wsl_profile)}') | |
| print(f'release={json.dumps(release)}') | |
| print(f'prerelease={json.dumps(prerelease)}') | |
| print(f'release_xmake={json.dumps(release_xmake)}') | |
| print(f'sat_group={json.dumps(sat_group)}') | |
| EOF | |
| outputs: | |
| branch: ${{ steps.param.outputs.branch }} | |
| profile: ${{ steps.param.outputs.profile }} | |
| wsl_branch: ${{ steps.param.outputs.wsl_branch }} | |
| wsl_profile: ${{ steps.param.outputs.wsl_profile }} | |
| release: ${{ steps.param.outputs.release }} | |
| prerelease: ${{ steps.param.outputs.prerelease }} | |
| release_xmake: ${{ steps.param.outputs.release_xmake }} | |
| sat_group: ${{ steps.param.outputs.sat_group }} | |
| download_source: | |
| name: Download source | |
| runs-on: ubuntu-24.04 | |
| needs: param | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| branch: ${{ fromJson(needs.param.outputs.branch) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download source | |
| run: | | |
| ./main.py --branch ${{ matrix.branch }} --profile 64-mcf --download-only | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: src-${{ matrix.branch }} | |
| path: | | |
| assets | |
| build_container: | |
| name: Build container | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build container | |
| run: | | |
| podman build -t mingw-lite/buildenv support/buildenv | |
| mkdir assets | |
| podman save mingw-lite/buildenv:latest | zstd -o assets/buildenv.tar.zst | |
| - name: Upload container | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: buildenv | |
| path: assets/buildenv.tar.zst | |
| build: | |
| name: Build | |
| needs: [param, download_source, build_container] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| branch: ${{ fromJson(needs.param.outputs.branch) }} | |
| profile: ${{ fromJson(needs.param.outputs.profile) }} | |
| uses: ./.github/workflows/build_single.yml | |
| with: | |
| branch: ${{ matrix.branch }} | |
| profile: ${{ matrix.profile }} | |
| wsl_build_container: | |
| name: Build container (WSL) | |
| needs: [param] | |
| if: ${{ ! fromJson(needs.param.outputs.release) }} | |
| runs-on: windows-2025 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build container (WSL) | |
| run: | | |
| Copy-Item -Path support/wsl/.wslconfig -Destination "$env:USERPROFILE/.wslconfig" | |
| Invoke-WebRequest ` | |
| -Uri https://cdimages.ubuntu.com/ubuntu-wsl/noble/daily-live/current/noble-wsl-amd64.wsl ` | |
| -OutFile noble-wsl-amd64.wsl | |
| wsl --import mingw-lite-buildenv . noble-wsl-amd64.wsl | |
| wsl --distribution mingw-lite-buildenv --exec ` | |
| apt update | |
| wsl --distribution mingw-lite-buildenv --exec ` | |
| env DEBIAN_FRONTEND=noninteractive ` | |
| apt-get install --no-install-recommends -y ` | |
| autoconf automake build-essential cmake flex gettext libtool meson texinfo xmake ` | |
| 7zip ca-certificates curl file gawk libarchive-tools python3 python3-packaging zstd | |
| wsl --distribution mingw-lite-buildenv --exec ` | |
| sync | |
| wsl --shutdown | |
| mkdir assets | |
| wsl --export mingw-lite-buildenv assets/buildenv.vhdx --format vhd | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: wsl-buildenv | |
| path: assets/buildenv.vhdx | |
| wsl_build: | |
| name: Build (WSL) | |
| needs: [param, download_source, wsl_build_container] | |
| if: ${{ ! fromJson(needs.param.outputs.release) }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| branch: ${{ fromJson(needs.param.outputs.wsl_branch) }} | |
| profile: ${{ fromJson(needs.param.outputs.wsl_profile) }} | |
| uses: ./.github/workflows/wsl_build_single.yml | |
| with: | |
| branch: ${{ matrix.branch }} | |
| profile: ${{ matrix.profile }} | |
| release: | |
| name: Release | |
| needs: [param, build] | |
| if: ${{ fromJson(needs.param.outputs.release) }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| branch: ${{ fromJson(needs.param.outputs.branch) }} | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: ConorMacBride/install-package@v1 | |
| with: | |
| apt: 7zip jq libarchive-tools | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: mingw* | |
| path: dist | |
| merge-multiple: true | |
| - name: 7z archive | |
| run: | | |
| cd dist | |
| jobs=$(nproc) | |
| mingw_list=( | |
| $(echo '${{ needs.param.outputs.profile }}' | jq -r '.[]') | |
| ) | |
| xmake_list=( | |
| $(echo '${{ needs.param.outputs.release_xmake }}' | jq -r '.[]') | |
| ) | |
| for pn in ${mingw_list[@]} ; do | |
| { | |
| dn=mingw$pn-${{ matrix.branch }} | |
| fn=$(ls mingw$pn-*.tar.zst) | |
| bn=$(basename $fn .tar.zst) | |
| bsdtar -xf $fn | |
| 7z a -t7z -mx9 -ms=on -m0=LZMA:d=64m:fb64 $bn.7z $dn | |
| rm -rf $dn | |
| } & | |
| while [[ $(jobs -r -p | wc -l) -ge $jobs ]] ; do | |
| sleep 1 | |
| done | |
| done | |
| wait | |
| for pn in ${xmake_list[@]} ; do | |
| { | |
| dn=mingw$pn-${{ matrix.branch }} | |
| fn=$(ls xmake-mingw$pn-*.tar.zst) | |
| bn=$(basename $fn .tar.zst) | |
| bsdtar -xf $fn | |
| 7z a -t7z -mx9 -ms=on -m0=LZMA:d=64m:fb64 $bn.7z $dn | |
| rm -rf $dn | |
| } & | |
| while [[ $(jobs -r -p | wc -l) -ge $jobs ]] ; do | |
| sleep 1 | |
| done | |
| done | |
| wait | |
| - name: Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| prerelease: ${{ needs.param.outputs.prerelease }} | |
| make_latest: 'false' | |
| files: | | |
| dist/mingw*.tar.zst | |
| dist/mingw*.7z | |
| dist/x-mingw*.tar.zst | |
| dist/xmake-mingw*.7z | |
| sat_archive: | |
| name: Semi-automated testing archive | |
| if: ${{ ! fromJson(needs.param.outputs.release) }} | |
| runs-on: ubuntu-24.04 | |
| needs: [param, build_container, build] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJson(needs.param.outputs.sat_group) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ConorMacBride/install-package@v1 | |
| with: | |
| apt: jq libarchive-tools | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: buildenv | |
| path: assets | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: ${{ matrix.pattern }} | |
| path: dist | |
| merge-multiple: true | |
| - name: Load container | |
| run: | | |
| zstdcat assets/buildenv.tar.zst | podman load | |
| - name: Create test archive | |
| run: | | |
| branch=( | |
| $(echo '${{ needs.param.outputs.branch }}' | jq -r '.[]') | |
| ) | |
| profile=( | |
| $(echo '${{ matrix.profile }}' | jq -r '.[]') | |
| ) | |
| mkdir layer | |
| mkdir pkg | |
| for p in ${profile[@]} ; do | |
| # filename can differ from branch name when a a new branch is just created | |
| for archive in $(ls dist/x-mingw$p-*.tar.zst) ; do | |
| bsdtar -C layer -xf $archive | |
| done | |
| done | |
| rm dist/x-mingw*.tar.zst | |
| for b in ${branch[@]} ; do | |
| for p in ${profile[@]} ; do | |
| podman run --rm --cap-add=sys_admin \ | |
| -v $PWD:/mnt -w /mnt \ | |
| -v $PWD/layer:/tmp/layer \ | |
| -v $PWD/pkg:/tmp/pkg \ | |
| mingw-lite/buildenv \ | |
| ./sat.py --branch $b --profile $p | |
| rm -rf layer/mingw$p-$b | |
| done | |
| done | |
| ( | |
| cd pkg | |
| 7z a -t7z -mx9 -ms=on -mqs -m0=LZMA:d=${{ matrix.dict }}:fb64 ../dist/sat${{ matrix.name }}.7z sat* | |
| ) | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: sat${{ matrix.name }} | |
| path: dist/sat${{ matrix.name }}.7z |