Skip to content

Commit

Permalink
Release package on PyPI (#125)
Browse files Browse the repository at this point in the history
## Changes

- Add a release step to publish the package on PyPI. This will help us
build kyuubi with strict deps enabled.

- The makefile relies on `sg`, which prompts for a password on Noble, so
let's use jammy for now to run integration tests
  • Loading branch information
Batalex authored Jan 16, 2025
1 parent a6ad3d8 commit 8bd96c0
Show file tree
Hide file tree
Showing 8 changed files with 659 additions and 495 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ on:
jobs:
checks:
name: Code checks
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
timeout-minutes: 5
strategy:
fail-fast: true
matrix:
python-version:
- '3.9'
- '3.10'
- "3.9"
- "3.10"
steps:
- id: checkout
name: Checkout repo
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Run Tests

on:
schedule:
- cron: '53 0 * * *' # Daily at 00:53 UTC
- cron: "53 0 * * *" # Daily at 00:53 UTC
workflow_call:

jobs:
Expand All @@ -11,14 +11,14 @@ jobs:

test:
name: Unit and Integration Tests
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
timeout-minutes: 60
strategy:
fail-fast: true
matrix:
python-version:
- '3.9'
- '3.10'
- "3.9"
- "3.10"
needs:
- checks
steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:

tests:
uses: ./.github/workflows/ci-tests.yaml

Expand All @@ -31,7 +30,7 @@ jobs:
name: Setup Python
uses: actions/setup-python@v5.3.0
with:
python-version: '3.10'
python-version: "3.10"
architecture: x64
- id: install_environment
name: Set up build environment
Expand All @@ -57,9 +56,33 @@ jobs:
package_name: ${{ steps.package_metadata.outputs.name }}
package_version: ${{ steps.package_metadata.outputs.version }}

build:
name: Build package
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.build.outputs.VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install poetry
run: pipx install poetry
- name: Check for tag and build package
id: build
run: |
VERSION=$(poetry version -s)
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
poetry build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: distfiles
path: dist/

autorelease:
name: Release the package on github
needs: [release_checks, tests]
needs: [release_checks, tests, build]
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
Expand All @@ -71,20 +94,11 @@ jobs:
with:
ref: ${{ env.BRANCH }}
fetch-depth: 0
- id: setup_python
name: Setup Python
uses: actions/setup-python@v5.3.0
- name: Download all the dists
uses: actions/download-artifact@v4
with:
python-version: '3.10'
architecture: x64
- id: install_environment
name: Set up build environment
run: |
make setup
- id: build_package
name: Build package
run: |
poetry build
name: distfiles
path: dist/
- id: artifact_names
name: Compute artifact names outputs
run: |
Expand All @@ -106,6 +120,21 @@ jobs:
wheel: ${{ steps.artifact_names.outputs.wheel }}
tarball: ${{ steps.artifact_names.outputs.tarball }}

upload-pypi:
name: Publish to PyPI
needs: [release_checks, tests, build]
runs-on: ubuntu-latest
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: distfiles
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
permissions:
id-token: write # Needed for trusted publishing (https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/)

test:
name: Test Release
runs-on: ubuntu-latest
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ endif

$(setup_tag): $(pre_deps_tag) pyproject.toml
@echo "==Setting up package environment=="
poetry config virtualenvs.prefer-active-python true
poetry lock --no-update
poetry install --with unit --no-cache
poetry lock
poetry install --with unit
touch $(setup_tag)

setup: $(setup_tag)
Expand Down
889 changes: 510 additions & 379 deletions poetry.lock

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ignore_missing_imports = true

[tool.poetry]
name = "spark8t"
version = "0.0.10"
version = "0.0.11"
description = "This project provides some utilities function and CLI commands to run Spark on K8s."
authors = [
"Canonical Data Platform <data-platform@lists.launchpad.net>"
Expand All @@ -51,6 +51,9 @@ license = "Apache-2.0"
readme = "README.md"
packages = []

[tool.poetry.requires-plugins]
poetry-plugin-export = ">=1.0"

[tool.poetry.dependencies]
python = ">3.8,<4.0"
lightkube = ">=0.11"
Expand Down
Loading

0 comments on commit 8bd96c0

Please sign in to comment.