Skip to content

Commit 8bd96c0

Browse files
authored
Release package on PyPI (#125)
## 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
1 parent a6ad3d8 commit 8bd96c0

8 files changed

+659
-495
lines changed

.github/workflows/ci-checks.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ on:
66
jobs:
77
checks:
88
name: Code checks
9-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-22.04
1010
timeout-minutes: 5
1111
strategy:
1212
fail-fast: true
1313
matrix:
1414
python-version:
15-
- '3.9'
16-
- '3.10'
15+
- "3.9"
16+
- "3.10"
1717
steps:
1818
- id: checkout
1919
name: Checkout repo

.github/workflows/ci-tests.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Run Tests
22

33
on:
44
schedule:
5-
- cron: '53 0 * * *' # Daily at 00:53 UTC
5+
- cron: "53 0 * * *" # Daily at 00:53 UTC
66
workflow_call:
77

88
jobs:
@@ -11,14 +11,14 @@ jobs:
1111

1212
test:
1313
name: Unit and Integration Tests
14-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-22.04
1515
timeout-minutes: 60
1616
strategy:
1717
fail-fast: true
1818
matrix:
1919
python-version:
20-
- '3.9'
21-
- '3.10'
20+
- "3.9"
21+
- "3.10"
2222
needs:
2323
- checks
2424
steps:

.github/workflows/release_github.yaml .github/workflows/release.yaml

+46-17
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ on:
77
push:
88
# Sequence of patterns matched against refs/tags
99
tags:
10-
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
10+
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
1111

1212
jobs:
13-
1413
tests:
1514
uses: ./.github/workflows/ci-tests.yaml
1615

@@ -31,7 +30,7 @@ jobs:
3130
name: Setup Python
3231
uses: actions/setup-python@v5.3.0
3332
with:
34-
python-version: '3.10'
33+
python-version: "3.10"
3534
architecture: x64
3635
- id: install_environment
3736
name: Set up build environment
@@ -57,9 +56,33 @@ jobs:
5756
package_name: ${{ steps.package_metadata.outputs.name }}
5857
package_version: ${{ steps.package_metadata.outputs.version }}
5958

59+
build:
60+
name: Build package
61+
runs-on: ubuntu-latest
62+
outputs:
63+
VERSION: ${{ steps.build.outputs.VERSION }}
64+
steps:
65+
- name: Checkout
66+
uses: actions/checkout@v4
67+
with:
68+
fetch-depth: 0
69+
- name: Install poetry
70+
run: pipx install poetry
71+
- name: Check for tag and build package
72+
id: build
73+
run: |
74+
VERSION=$(poetry version -s)
75+
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
76+
poetry build
77+
- name: Store the distribution packages
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: distfiles
81+
path: dist/
82+
6083
autorelease:
6184
name: Release the package on github
62-
needs: [release_checks, tests]
85+
needs: [release_checks, tests, build]
6386
runs-on: ubuntu-latest
6487
timeout-minutes: 5
6588
strategy:
@@ -71,20 +94,11 @@ jobs:
7194
with:
7295
ref: ${{ env.BRANCH }}
7396
fetch-depth: 0
74-
- id: setup_python
75-
name: Setup Python
76-
uses: actions/setup-python@v5.3.0
97+
- name: Download all the dists
98+
uses: actions/download-artifact@v4
7799
with:
78-
python-version: '3.10'
79-
architecture: x64
80-
- id: install_environment
81-
name: Set up build environment
82-
run: |
83-
make setup
84-
- id: build_package
85-
name: Build package
86-
run: |
87-
poetry build
100+
name: distfiles
101+
path: dist/
88102
- id: artifact_names
89103
name: Compute artifact names outputs
90104
run: |
@@ -106,6 +120,21 @@ jobs:
106120
wheel: ${{ steps.artifact_names.outputs.wheel }}
107121
tarball: ${{ steps.artifact_names.outputs.tarball }}
108122

123+
upload-pypi:
124+
name: Publish to PyPI
125+
needs: [release_checks, tests, build]
126+
runs-on: ubuntu-latest
127+
steps:
128+
- name: Download all the dists
129+
uses: actions/download-artifact@v4
130+
with:
131+
name: distfiles
132+
path: dist/
133+
- name: Publish to PyPI
134+
uses: pypa/gh-action-pypi-publish@release/v1
135+
permissions:
136+
id-token: write # Needed for trusted publishing (https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/)
137+
109138
test:
110139
name: Test Release
111140
runs-on: ubuntu-latest

Makefile

+2-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ endif
6060

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

6867
setup: $(setup_tag)

poetry.lock

+510-379
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ ignore_missing_imports = true
4242

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

54+
[tool.poetry.requires-plugins]
55+
poetry-plugin-export = ">=1.0"
56+
5457
[tool.poetry.dependencies]
5558
python = ">3.8,<4.0"
5659
lightkube = ">=0.11"

0 commit comments

Comments
 (0)