|
| 1 | +name: Build |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + ref: |
| 6 | + description: PyInstaller tag/ref |
| 7 | + required: true |
| 8 | + default: v6.15.0 |
| 9 | + type: string |
| 10 | + x64: |
| 11 | + description: Build Windows x64 / win_amd64 |
| 12 | + default: true |
| 13 | + type: boolean |
| 14 | + x86: |
| 15 | + description: Build Windows x86 / win32 |
| 16 | + default: true |
| 17 | + type: boolean |
| 18 | + arm64: |
| 19 | + description: Build Windows ARM64 / win_arm64 |
| 20 | + default: true |
| 21 | + type: boolean |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: read |
| 25 | + |
| 26 | +jobs: |
| 27 | + prepare: |
| 28 | + name: Prepare |
| 29 | + runs-on: ubuntu-latest |
| 30 | + outputs: |
| 31 | + head_sha: ${{ steps.get_target.outputs.head_sha }} |
| 32 | + matrix: ${{ steps.build_matrix.outputs.matrix }} |
| 33 | + release_title: ${{ steps.release_info.outputs.release_title }} |
| 34 | + release_tag: ${{ steps.release_info.outputs.release_tag }} |
| 35 | + release_notes: ${{ steps.release_info.outputs.release_notes }} |
| 36 | + |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v4 |
| 39 | + |
| 40 | + - name: Get target commitish |
| 41 | + id: get_target |
| 42 | + run: | |
| 43 | + echo "head_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" |
| 44 | +
|
| 45 | + - name: Build matrix |
| 46 | + id: build_matrix |
| 47 | + env: |
| 48 | + INPUTS: ${{ toJSON(inputs) }} |
| 49 | + shell: python |
| 50 | + run: | |
| 51 | + import json |
| 52 | + import os |
| 53 | + ARCHITECTURES = [{ |
| 54 | + 'name': 'x64', |
| 55 | + 'runner': 'windows-2025', |
| 56 | + 'sys': 'MINGW64', |
| 57 | + 'env': 'x86_64', |
| 58 | + 'arch': '64bit', |
| 59 | + 'compiler': 'gcc', |
| 60 | + 'wheel_tag': 'win_amd64', |
| 61 | + 'platform': 'Windows-64bit-intel', |
| 62 | + }, { |
| 63 | + 'name': 'x86', |
| 64 | + 'runner': 'windows-2025', |
| 65 | + 'sys': 'MINGW32', |
| 66 | + 'env': 'i686', |
| 67 | + 'arch': '32bit', |
| 68 | + 'compiler': 'gcc', |
| 69 | + 'wheel_tag': 'win32', |
| 70 | + 'platform': 'Windows-32bit-intel', |
| 71 | + }, { |
| 72 | + 'name': 'arm64', |
| 73 | + 'runner': 'windows-11-arm', |
| 74 | + 'sys': 'CLANGARM64', |
| 75 | + 'env': 'clang-aarch64', |
| 76 | + 'arch': '64bit-arm', |
| 77 | + 'compiler': 'clang', |
| 78 | + 'wheel_tag': 'win_arm64', |
| 79 | + 'platform': 'Windows-64bit-arm', |
| 80 | + }] |
| 81 | + INPUTS = json.loads(os.environ['INPUTS']) |
| 82 | + matrix = [arch for arch in ARCHITECTURES for k, v in INPUTS.items() if arch['name'] == k and v] |
| 83 | + print(json.dumps(matrix, indent=2)) |
| 84 | + with open(os.environ['GITHUB_OUTPUT'], 'a') as f: |
| 85 | + f.write(f'matrix={json.dumps(matrix)}') |
| 86 | +
|
| 87 | + - name: Generate release info |
| 88 | + id: release_info |
| 89 | + env: |
| 90 | + REF: ${{ inputs.ref }} |
| 91 | + MATRIX: ${{ steps.build_matrix.outputs.matrix }} |
| 92 | + shell: python |
| 93 | + run: | |
| 94 | + import datetime as dt |
| 95 | + import json |
| 96 | + import os |
| 97 | + ref = os.environ['REF'] |
| 98 | + builds = ', '.join(element['name'] for element in json.loads(os.environ['MATRIX'])) |
| 99 | + timestamp = dt.datetime.now(tz=dt.timezone.utc).strftime('%Y.%m.%d.%H%M%S') |
| 100 | + outputs = { |
| 101 | + 'release_title': f'{ref} @ {timestamp}', |
| 102 | + 'release_tag': timestamp, |
| 103 | + 'release_notes': f'PyInstaller {ref} builds for Windows {builds}', |
| 104 | + } |
| 105 | + print(json.dumps(outputs, indent=2)) |
| 106 | + with open(os.environ['GITHUB_OUTPUT'], 'a') as f: |
| 107 | + f.write('\n'.join(f'{key}={value}' for key, value in outputs.items())) |
| 108 | +
|
| 109 | + build: |
| 110 | + name: Build ${{ matrix.name }} package |
| 111 | + needs: prepare |
| 112 | + runs-on: ${{ matrix.runner }} |
| 113 | + strategy: |
| 114 | + fail-fast: false |
| 115 | + matrix: |
| 116 | + include: ${{ fromJSON(needs.prepare.outputs.matrix) }} |
| 117 | + defaults: |
| 118 | + run: |
| 119 | + shell: msys2 {0} |
| 120 | + |
| 121 | + steps: |
| 122 | + - name: Set up MinGW |
| 123 | + uses: yt-dlp/setup-msys2@v2 |
| 124 | + with: |
| 125 | + update: true |
| 126 | + msystem: ${{ matrix.sys }} |
| 127 | + install: >- |
| 128 | + base-devel |
| 129 | + mingw-w64-${{ matrix.env }}-toolchain |
| 130 | + mingw-w64-${{ matrix.env }}-python |
| 131 | + mingw-w64-${{ matrix.env }}-python-pip |
| 132 | +
|
| 133 | + - name: Checkout |
| 134 | + uses: actions/checkout@v4 |
| 135 | + with: |
| 136 | + repository: observeroftime01/pyinstaller-patch |
| 137 | + ref: ${{ inputs.ref }} |
| 138 | + |
| 139 | + - name: Build bootloader |
| 140 | + env: |
| 141 | + ARCH: ${{ matrix.arch }} |
| 142 | + COMPILER: ${{ matrix.compiler }} |
| 143 | + run: | |
| 144 | + cd bootloader |
| 145 | + python ./waf --target-arch="${ARCH}" --"${COMPILER}" distclean all |
| 146 | +
|
| 147 | + - name: Build package |
| 148 | + env: |
| 149 | + PYI_WHEEL_TAG: ${{ matrix.wheel_tag }} |
| 150 | + PYI_PLATFORM: ${{ matrix.platform }} |
| 151 | + run: | |
| 152 | + python -m pip install build |
| 153 | + python -m build --no-isolation --wheel --outdir=dist . |
| 154 | +
|
| 155 | + - name: Upload artifacts |
| 156 | + uses: actions/upload-artifact@v4 |
| 157 | + with: |
| 158 | + name: pyinstaller-${{ inputs.ref }}-${{ matrix.name }} |
| 159 | + path: | |
| 160 | + dist/* |
| 161 | + compression-level: 0 |
| 162 | + |
| 163 | + release: |
| 164 | + name: Release |
| 165 | + needs: [prepare, build] |
| 166 | + permissions: |
| 167 | + contents: write |
| 168 | + runs-on: ubuntu-latest |
| 169 | + env: |
| 170 | + HEAD_SHA: ${{ needs.prepare.outputs.head_sha }} |
| 171 | + RELEASE_TITLE: ${{ needs.prepare.outputs.release_title }} |
| 172 | + RELEASE_TAG: ${{ needs.prepare.outputs.release_tag }} |
| 173 | + RELEASE_NOTES: ${{ needs.prepare.outputs.release_notes }} |
| 174 | + |
| 175 | + steps: |
| 176 | + - uses: actions/checkout@v4 |
| 177 | + with: |
| 178 | + fetch-depth: 0 |
| 179 | + |
| 180 | + - uses: actions/download-artifact@v4 |
| 181 | + with: |
| 182 | + path: artifact |
| 183 | + pattern: pyinstaller-* |
| 184 | + merge-multiple: true |
| 185 | + |
| 186 | + - name: Publish release |
| 187 | + env: |
| 188 | + GH_TOKEN: ${{ github.token }} |
| 189 | + run: | |
| 190 | + gh release create \ |
| 191 | + --notes "${RELEASE_NOTES}" \ |
| 192 | + --target "${HEAD_SHA}" \ |
| 193 | + --title "${RELEASE_TITLE}" \ |
| 194 | + "${RELEASE_TAG}" \ |
| 195 | + artifact/* |
0 commit comments