Merge pull request #1662 from xwings/dev #1440
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: PyPI 📦 Distribution | |
| on: [push, pull_request] | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.13" | |
| - name: Install dependencies | |
| run: python -m pip install "poetry>=2,<3" build twine | |
| - name: Check package metadata | |
| run: poetry check --lock | |
| - name: Check release tag matches package version | |
| if: startsWith(github.ref, 'refs/tags/') | |
| env: | |
| RELEASE_TAG: ${{ github.ref_name }} | |
| run: | | |
| python - <<'PY' | |
| import os | |
| import tomllib | |
| from pathlib import Path | |
| from packaging.version import Version | |
| tag = os.environ['RELEASE_TAG'].removeprefix('v') | |
| version = tomllib.loads(Path('pyproject.toml').read_text())['tool']['poetry']['version'] | |
| if Version(tag) != Version(version): | |
| raise SystemExit(f'Release tag {tag!r} does not match package version {version!r}') | |
| PY | |
| - name: Build distribution 📦 | |
| run: python -m build | |
| - name: Check distribution metadata | |
| run: python -m twine check --strict dist/* | |
| - name: Test installed wheel | |
| run: | | |
| python -m pip install dist/*.whl | |
| python -I tests/test_qltool.py InstalledQltool_Test -v | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: distributions | |
| path: ${{ github.workspace }}/dist/* | |
| if-no-files-found: error | |
| publish-testpypi: | |
| needs: [build] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
| environment: | |
| name: testpypi | |
| url: https://test.pypi.org/p/qiling | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: distributions | |
| path: dist | |
| - name: Publish distribution 📦 to test PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| skip-existing: true | |
| publish: | |
| needs: [build, publish-testpypi] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/qiling | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: distributions | |
| path: dist | |
| - name: Publish distribution 📦 to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |