Skip to content

release: Merge latest prod-staging changes to prod-stable (#4) #1

release: Merge latest prod-staging changes to prod-stable (#4)

release: Merge latest prod-staging changes to prod-stable (#4) #1

Workflow file for this run

name: publish-pypi
# Publish to PyPI via Trusted Publishing (OIDC) when a version tag is pushed,
# e.g. `git tag v0.1.0 && git push origin v0.1.0`. No API token is stored; the
# `pypi` GitHub Environment must be configured as a trusted publisher for the
# `unikraft-cloud` project on PyPI.
on:
push:
tags:
- "v*"
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: Check the tag and the package agree on the version
env:
TAG: ${{ github.ref_name }}
run: |
# The version is static in `pyproject.toml`, so a tag pushed without
# bumping it would build, and try to publish, the previous release.
version="$(uv version --short)"
if [ "${TAG#v}" != "${version}" ]; then
echo "::error::Tag ${TAG} does not match the packaged version ${version}." \
"Bump the version and retag."
exit 1
fi
exported="$(sed -n 's/^__version__ = "\(.*\)"$/\1/p' src/unikraft_cloud/__init__.py)"
if [ "${exported}" != "${version}" ]; then
echo "::error::The package reports __version__ ${exported}, but it is built as ${version}."
exit 1
fi
- name: Build sdist and wheel
run: uv build
- name: Check metadata
run: uvx twine check dist/*
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
publish:
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/unikraft-cloud
permissions:
id-token: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1