|
| 1 | +name: Create Release Artifacts |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + release_version: |
| 7 | + description: The version to set in setup.py |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + outputs: |
| 11 | + sdist: |
| 12 | + description: The source distribution filename |
| 13 | + value: ${{ jobs.package_python3.outputs.sdist }} |
| 14 | + py3_wheel: |
| 15 | + description: The Python 3 wheel filename |
| 16 | + value: ${{ jobs.package_python3.outputs.wheel }} |
| 17 | + py2_wheel: |
| 18 | + description: The Python 2 wheel filename |
| 19 | + value: ${{ jobs.package_python2.outputs.wheel }} |
| 20 | + |
| 21 | +jobs: |
| 22 | + |
| 23 | + package_python3: |
| 24 | + name: Create sdist and Python 3 Wheel |
| 25 | + runs-on: ubuntu-24.04 |
| 26 | + outputs: |
| 27 | + sdist: ${{ steps.package.outputs.sdist }} |
| 28 | + wheel: ${{ steps.package.outputs.wheel }} |
| 29 | + container: |
| 30 | + image: danielflook/python-minifier-build:python3.14-2025-08-21 |
| 31 | + permissions: |
| 32 | + contents: read |
| 33 | + steps: |
| 34 | + - name: Checkout |
| 35 | + |
| 36 | + with: |
| 37 | + fetch-depth: 1 |
| 38 | + show-progress: false |
| 39 | + persist-credentials: false |
| 40 | + |
| 41 | + - name: Set version statically |
| 42 | + env: |
| 43 | + VERSION: ${{ inputs.release_version }} |
| 44 | + run: | |
| 45 | + sed -i "s/setup_requires=.*/version='$VERSION',/; s/use_scm_version=.*//" setup.py |
| 46 | + echo "Version: $VERSION" |
| 47 | +
|
| 48 | + - name: Build distribution packages |
| 49 | + id: package |
| 50 | + run: | |
| 51 | + pip3 install --upgrade build |
| 52 | + python3 -m build |
| 53 | + |
| 54 | + echo "sdist=$(find dist -name '*.tar.gz' -printf "%f\n")" >> "$GITHUB_OUTPUT" |
| 55 | + echo "wheel=$(find dist -name '*-py3-*.whl' -printf "%f\n")" >> "$GITHUB_OUTPUT" |
| 56 | +
|
| 57 | + - name: Upload sdist artifact |
| 58 | + |
| 59 | + with: |
| 60 | + name: dist-sdist |
| 61 | + path: dist/${{ steps.package.outputs.sdist }} |
| 62 | + if-no-files-found: error |
| 63 | + |
| 64 | + - name: Upload Python 3 wheel artifact |
| 65 | + |
| 66 | + with: |
| 67 | + name: dist-py3-wheel |
| 68 | + path: dist/${{ steps.package.outputs.wheel }} |
| 69 | + if-no-files-found: error |
| 70 | + |
| 71 | + package_python2: |
| 72 | + name: Create Python 2 Wheel |
| 73 | + runs-on: ubuntu-24.04 |
| 74 | + needs: [package_python3] |
| 75 | + outputs: |
| 76 | + wheel: ${{ steps.package.outputs.wheel }} |
| 77 | + container: |
| 78 | + image: danielflook/python-minifier-build:python2.7-2025-08-21 |
| 79 | + steps: |
| 80 | + - name: Download source distribution artifact |
| 81 | + |
| 82 | + with: |
| 83 | + name: dist-sdist |
| 84 | + path: dist/ |
| 85 | + |
| 86 | + - name: Build Python 2 wheel |
| 87 | + id: package |
| 88 | + env: |
| 89 | + PYTHON3_SDIST: ${{ needs.package_python3.outputs.sdist }} |
| 90 | + run: | |
| 91 | + dnf install -y findutils |
| 92 | + pip install --upgrade wheel |
| 93 | + pip wheel dist/"$PYTHON3_SDIST" -w dist |
| 94 | + echo "wheel=$(find dist -name '*-py2-*.whl' -printf "%f\n")" >> "$GITHUB_OUTPUT" |
| 95 | +
|
| 96 | + - name: Upload Python 2 wheel artifact |
| 97 | + |
| 98 | + with: |
| 99 | + name: dist-py2-wheel |
| 100 | + path: dist/${{ steps.package.outputs.wheel }} |
| 101 | + if-no-files-found: error |
| 102 | + |
| 103 | + documentation: |
| 104 | + name: Build Documentation |
| 105 | + runs-on: ubuntu-24.04 |
| 106 | + needs: [package_python3] |
| 107 | + container: |
| 108 | + image: danielflook/python-minifier-build:python3.14-2025-08-21 |
| 109 | + permissions: |
| 110 | + contents: read |
| 111 | + steps: |
| 112 | + |
| 113 | + with: |
| 114 | + name: dist-sdist |
| 115 | + path: dist/ |
| 116 | + |
| 117 | + - name: Install package |
| 118 | + env: |
| 119 | + PYTHON3_SDIST: ${{ needs.package_python3.outputs.sdist }} |
| 120 | + run: | |
| 121 | + pip3 install dist/"$PYTHON3_SDIST" |
| 122 | + pyminify --version |
| 123 | +
|
| 124 | + - name: Checkout |
| 125 | + |
| 126 | + with: |
| 127 | + fetch-depth: 1 |
| 128 | + show-progress: false |
| 129 | + persist-credentials: false |
| 130 | + |
| 131 | + - name: Build documentation |
| 132 | + run: | |
| 133 | + pip3 install sphinx sphinxcontrib-programoutput sphinx_rtd_theme |
| 134 | + sphinx-build docs/source /tmp/build |
| 135 | +
|
| 136 | + - name: Upload documentation artifact |
| 137 | + |
| 138 | + with: |
| 139 | + path: /tmp/build |
| 140 | + |
| 141 | + test_package: |
| 142 | + name: Test Package |
| 143 | + runs-on: ubuntu-24.04 |
| 144 | + needs: [package_python2, package_python3] |
| 145 | + strategy: |
| 146 | + fail-fast: false |
| 147 | + matrix: |
| 148 | + python: ["2.7", "3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] |
| 149 | + package_type: [sdist, wheel] |
| 150 | + steps: |
| 151 | + - name: Checkout |
| 152 | + |
| 153 | + with: |
| 154 | + fetch-depth: 1 |
| 155 | + show-progress: false |
| 156 | + persist-credentials: false |
| 157 | + |
| 158 | + - name: Download distribution artifacts |
| 159 | + |
| 160 | + with: |
| 161 | + pattern: dist-* |
| 162 | + path: dist/ |
| 163 | + merge-multiple: true |
| 164 | + |
| 165 | + - name: Test |
| 166 | + uses: ./.github/actions/run-in-container |
| 167 | + with: |
| 168 | + image: danielflook/python-minifier-build:python${{ matrix.python }}-2025-08-21 |
| 169 | + run: | |
| 170 | + if [[ "${{ matrix.package_type }}" == "sdist" ]]; then |
| 171 | + pip${{ matrix.python }} install dist/${{needs.package_python3.outputs.sdist}} |
| 172 | + elif [[ "${{ matrix.python }}" == "2.7" ]]; then |
| 173 | + pip${{ matrix.python }} install dist/${{needs.package_python2.outputs.py2_wheel}} |
| 174 | + else |
| 175 | + pip${{ matrix.python }} install dist/${{needs.package_python3.outputs.py3_wheel}} |
| 176 | + fi |
| 177 | + |
| 178 | + pyminify --version |
| 179 | +
|
| 180 | + set -x |
| 181 | + cat setup.py | pyminify - |
| 182 | + pyminify setup.py > /tmp/out.min.py |
| 183 | + pyminify setup.py --output /tmp/out.min.py2 |
| 184 | + pyminify setup.py src test --in-place |
| 185 | +
|
| 186 | + test_typing: |
| 187 | + name: Test Typing |
| 188 | + runs-on: ubuntu-24.04 |
| 189 | + needs: [package_python3] |
| 190 | + strategy: |
| 191 | + matrix: |
| 192 | + package_type: [sdist, wheel] |
| 193 | + container: |
| 194 | + image: danielflook/python-minifier-build:python3.14-2025-08-21 |
| 195 | + steps: |
| 196 | + - name: Download distribution artifacts |
| 197 | + |
| 198 | + with: |
| 199 | + pattern: dist-* |
| 200 | + path: dist/ |
| 201 | + merge-multiple: true |
| 202 | + |
| 203 | + - name: Install package |
| 204 | + env: |
| 205 | + PYTHON3_SDIST: ${{ needs.package_python3.outputs.sdist }} |
| 206 | + PYTHON3_WHEEL: ${{ needs.package_python3.outputs.py3_wheel }} |
| 207 | + run: | |
| 208 | + if [[ "${{ matrix.package_type }}" == "sdist" ]]; then |
| 209 | + pip3.14 install "dist/$PYTHON3_SDIST" |
| 210 | + else |
| 211 | + pip3.14 install "dist/$PYTHON3_WHEEL" |
| 212 | + fi |
| 213 | +
|
| 214 | + - name: Checkout |
| 215 | + |
| 216 | + with: |
| 217 | + fetch-depth: 1 |
| 218 | + show-progress: false |
| 219 | + persist-credentials: false |
| 220 | + |
| 221 | + - name: Test typing |
| 222 | + run: | |
| 223 | + pip3.14 install 'mypy<1.12.0' types-setuptools |
| 224 | + mypy --strict typing_test/test_typing.py |
| 225 | +
|
| 226 | + if mypy --strict typing_test/test_badtyping.py; then |
| 227 | + echo "Bad types weren't detected" |
| 228 | + exit 1 |
| 229 | + fi |
| 230 | +
|
| 231 | + stubtest python_minifier --allowlist typing_test/stubtest-allowlist.txt |
0 commit comments