1.93.0 #6
Workflow file for this run
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 Debian Package" | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| attach_to_release: | |
| # Use case: deb build failed for a release, manually trigger a rebuild | |
| description: 'Attach the created .deb file to the release' | |
| type: boolean | |
| default: false | |
| jobs: | |
| build-deb: | |
| runs-on: ubuntu-24.04 | |
| name: build deb | |
| timeout-minutes: 5 | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Install system packaging tools | |
| env: | |
| DEBIAN_FRONTEND: noninteractive | |
| TZ: Etc/UTC | |
| run: | | |
| sudo apt-get update -qq | |
| sudo apt-get install -qqy \ | |
| build-essential \ | |
| debhelper \ | |
| devscripts \ | |
| dh-python \ | |
| dpkg-dev \ | |
| fakeroot \ | |
| lintian | |
| - name: Install python system packaging | |
| env: | |
| DEBIAN_FRONTEND: noninteractive | |
| TZ: Etc/UTC | |
| run: | | |
| sudo apt-get update -qq | |
| sudo apt-get install -qqy \ | |
| pybuild-plugin-pyproject \ | |
| python3-all \ | |
| python3-dateutil \ | |
| python3-hatchling \ | |
| python3-jwt \ | |
| python3-paramiko \ | |
| python3-pydantic \ | |
| python3-urllib3 | |
| - name: Render debian metadata from pyproject.toml | |
| shell: bash | |
| run: | | |
| python3 .github/scripts/render_debian_files.py . | |
| - name: Generate .deb package | |
| id: generate_deb | |
| shell: bash | |
| run: | | |
| DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc -b > bdist_deb.log 2>&1 || { cat bdist_deb.log; exit 1; } | |
| mkdir -p deb_dist | |
| mv ../*.deb deb_dist/ | |
| DEB_FILE=$(find ./deb_dist -name "*.deb" | head -1) | |
| if [ -z "$DEB_FILE" ]; then | |
| echo "Error: No .deb file produced" | |
| exit 1 | |
| fi | |
| echo "DEB_FILE=$DEB_FILE" >> "$GITHUB_ENV" | |
| - name: Run lintian | |
| shell: bash | |
| run: | | |
| lintian -i -I --allow-root "$DEB_FILE" | |
| - name: Upload .deb Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: deb-package | |
| overwrite: true | |
| retention-days: 5 | |
| path: ${{ env.DEB_FILE }} | |
| test-deb: | |
| runs-on: ubuntu-24.04 | |
| needs: build-deb | |
| # We only test on Ubuntu versions that apply the PEP 668 standard (24.04 and 26.04). | |
| # Older versions (e.g. 20.04, 22.04) are not supported as they lack PEP 668 enforcement | |
| # and their older lintian/dpkg tools do not fully support the zstd-compressed .deb | |
| # archives generated by ubuntu:latest (24.04+). | |
| # Customers could use pip install globally anyway, so this should be fine. | |
| strategy: | |
| matrix: | |
| ubuntu-version: [ '24.04', '26.04' ] | |
| container: | |
| image: ubuntu:${{ matrix.ubuntu-version }} | |
| options: --user root | |
| name: test deb on ubuntu ${{ matrix.ubuntu-version }} | |
| timeout-minutes: 5 | |
| steps: | |
| - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| name: deb-package | |
| path: deb-package | |
| - name: Test DEB installation and import | |
| env: | |
| DEBIAN_FRONTEND: noninteractive | |
| shell: bash | |
| run: | | |
| apt-get update -qq | |
| DEB_FILE=$(find ./deb-package -name "*.deb" | head -1) | |
| apt-get install -y "$DEB_FILE" | |
| python3 -c "import pypureclient; print('Success! py-pure-client version:', pypureclient.__version__)" | |
| upload-to-release: | |
| name: Upload DEB to Release | |
| runs-on: ubuntu-24.04 | |
| needs: [build-deb, test-deb] | |
| # Only run if triggered by a release OR triggered manually with the checkbox checked | |
| if: | | |
| github.event_name == 'release' || | |
| (github.event_name == 'workflow_dispatch' && inputs.attach_to_release == true) | |
| permissions: | |
| contents: write # Required to upload assets to a release | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Get version and validate release | |
| id: get_version | |
| run: | | |
| VERSION=$(PYTHONPATH=. python3 -c "from pypureclient._version import __version__; print(__version__)") | |
| if [ -z "$VERSION" ]; then | |
| echo "ERROR: VERSION is empty or could not be determined" >&2 | |
| exit 1 | |
| fi | |
| if [ "${{ github.event_name }}" = "release" ] && [ "${{ github.event.release.tag_name }}" != "$VERSION" ]; then | |
| echo "::error::Version mismatch! GitHub tag is '${{ github.event.release.tag_name }}', but package version is '$VERSION'." | |
| exit 1 | |
| fi | |
| echo "VERSION: $VERSION" | |
| echo "VERSION=$VERSION" >> "$GITHUB_ENV" | |
| - name: Download DEB Artifact | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| name: deb-package | |
| path: deb-package | |
| - name: Upload to GitHub Release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| DEB_PATH=$(find ./deb-package -name "*.deb" | head -1) | |
| if [ ! -f "$DEB_PATH" ]; then | |
| echo "Error: .deb file not found in ./deb-package" | |
| exit 1 | |
| fi | |
| gh release upload "$VERSION" "$DEB_PATH" |