|
| 1 | +name: Build and Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: ['v*'] |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + |
| 11 | + steps: |
| 12 | + |
| 13 | + - name: Install dependencies |
| 14 | + run: | |
| 15 | + sudo apt-get update |
| 16 | + sudo apt-get install -y ninja-build pandoc mingw-w64 wine64 zip |
| 17 | + pip3 install --user meson |
| 18 | +
|
| 19 | + - uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + submodules: recursive |
| 22 | + |
| 23 | + - name: Build and test (native, meson fallback) |
| 24 | + run: | |
| 25 | + meson setup build |
| 26 | + meson compile -C build |
| 27 | + meson test -C build --print-errorlogs |
| 28 | +
|
| 29 | + - name: Cross-compile for Windows |
| 30 | + run: | |
| 31 | + cat > /tmp/cross-mingw64.ini <<'EOF' |
| 32 | + [binaries] |
| 33 | + c = 'x86_64-w64-mingw32-gcc' |
| 34 | + cpp = 'x86_64-w64-mingw32-g++' |
| 35 | + ar = 'x86_64-w64-mingw32-ar' |
| 36 | + strip = 'x86_64-w64-mingw32-strip' |
| 37 | + windres = 'x86_64-w64-mingw32-windres' |
| 38 | + exe_wrapper = 'wine' |
| 39 | + pkg-config = 'pkg-config' |
| 40 | +
|
| 41 | + [built-in options] |
| 42 | + default_library = 'shared' |
| 43 | +
|
| 44 | + [properties] |
| 45 | + sys_root = '/usr/x86_64-w64-mingw32' |
| 46 | + pkg_config_libdir = '/nonexistent' |
| 47 | +
|
| 48 | + [host_machine] |
| 49 | + system = 'windows' |
| 50 | + cpu_family = 'x86_64' |
| 51 | + cpu = 'x86_64' |
| 52 | + endian = 'little' |
| 53 | + EOF |
| 54 | + meson setup buildwin --cross-file /tmp/cross-mingw64.ini --buildtype=release -Ddebug=true |
| 55 | + meson compile -C buildwin |
| 56 | +
|
| 57 | + - name: Test Windows build under wine |
| 58 | + run: meson test -C buildwin --print-errorlogs |
| 59 | + |
| 60 | + - name: Extract version |
| 61 | + id: version |
| 62 | + run: | |
| 63 | + ver=$(meson introspect build --projectinfo | python3 -c 'import sys,json; print(json.load(sys.stdin)["version"])') |
| 64 | + echo "version=${ver}" >> "$GITHUB_OUTPUT" |
| 65 | + echo "project=parse_args-${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT" |
| 66 | +
|
| 67 | + - name: Create source tarball |
| 68 | + run: | |
| 69 | + project="${{ steps.version.outputs.project }}" |
| 70 | + # Generate README.md from docs |
| 71 | + meson compile -C build readme |
| 72 | + cp build/doc/README.md README.md |
| 73 | + # Copy workspace dereferencing symlinks, then strip build artifacts |
| 74 | + cp -aL . "/tmp/${project}" |
| 75 | + find "/tmp/${project}" -name '.git' -exec rm -rf {} + |
| 76 | + rm -rf "/tmp/${project}/.github" |
| 77 | + rm -rf "/tmp/${project}/build" "/tmp/${project}/buildwin" |
| 78 | + rm -rf "/tmp/${project}/subprojects/packagecache" |
| 79 | + rm -rf "/tmp/${project}/subprojects/tcl" |
| 80 | + rm -rf "/tmp/${project}/subprojects/libtommath-"* |
| 81 | + rm -rf "/tmp/${project}/subprojects/.wraplock" |
| 82 | + tar czf "/tmp/${project}.tar.gz" -C /tmp "${project}" |
| 83 | + cd /tmp && zip -rq "${project}-source.zip" "${project}" |
| 84 | +
|
| 85 | + - name: Package Windows binaries |
| 86 | + run: | |
| 87 | + pkg_dir="parse_args-${{ steps.version.outputs.version }}" |
| 88 | + mkdir -p "/tmp/win/${pkg_dir}" |
| 89 | + cp buildwin/teabase/libparse_args.dll "/tmp/win/${pkg_dir}/" |
| 90 | + cp buildwin/teabase/pkgIndex.tcl "/tmp/win/${pkg_dir}/" |
| 91 | + cp buildwin/doc/parse_args.html "/tmp/win/${pkg_dir}/parse_args.html" |
| 92 | + cd /tmp/win |
| 93 | + zip -r "/tmp/${{ steps.version.outputs.project }}-windows-x86_64.zip" "${pkg_dir}" |
| 94 | +
|
| 95 | + - name: Upload artifacts |
| 96 | + uses: actions/upload-artifact@v4 |
| 97 | + with: |
| 98 | + name: release-artifacts |
| 99 | + path: | |
| 100 | + /tmp/${{ steps.version.outputs.project }}.tar.gz |
| 101 | + /tmp/${{ steps.version.outputs.project }}-source.zip |
| 102 | + /tmp/${{ steps.version.outputs.project }}-windows-x86_64.zip |
| 103 | +
|
| 104 | + - name: Create GitHub Release |
| 105 | + uses: softprops/action-gh-release@v1 |
| 106 | + with: |
| 107 | + draft: false |
| 108 | + prerelease: false |
| 109 | + generate_release_notes: true |
| 110 | + files: | |
| 111 | + /tmp/${{ steps.version.outputs.project }}.tar.gz |
| 112 | + /tmp/${{ steps.version.outputs.project }}-source.zip |
| 113 | + /tmp/${{ steps.version.outputs.project }}-windows-x86_64.zip |
0 commit comments