Skip to content

fix(ci): disable debug-toolbar publish, fix litestar wheel build #9

fix(ci): disable debug-toolbar publish, fix litestar wheel build

fix(ci): disable debug-toolbar publish, fix litestar wheel build #9

Workflow file for this run

name: Publish
on:
push:
tags:
- 'v*'
permissions:
contents: write
id-token: write
jobs:
# ==================================================================================== #
# BUILD
# ==================================================================================== #
build:
name: Build Package (${{ matrix.package-name }})
runs-on: ubuntu-latest
strategy:
matrix:
include:
# TODO: Re-enable after PEP 541 name request is processed
# - package-name: debug-toolbar
# artifact-name: dist-debug-toolbar
- package-name: litestar-debug-toolbar
artifact-name: dist-litestar-debug-toolbar
steps:
- name: Checkout code
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: false
- name: Set up uv
uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v6
with:
enable-cache: true
version: "0.9.12"
- name: Build package (debug-toolbar)
if: matrix.package-name == 'debug-toolbar'
run: uv build
- name: Build package (litestar-debug-toolbar)
if: matrix.package-name == 'litestar-debug-toolbar'
run: |
# Build the primary package first
uv build
# Rename the distributions to litestar-debug-toolbar
cd dist
for f in debug_toolbar-*.whl; do
new_name=$(echo "$f" | sed 's/debug_toolbar/litestar_debug_toolbar/')
# Unpack, modify metadata, repack
unzip -q "$f" -d tmp_wheel
# Rename dist-info directory
old_dist_info=$(ls -d tmp_wheel/*.dist-info)
new_dist_info=$(echo "$old_dist_info" | sed 's/debug_toolbar/litestar_debug_toolbar/')
mv "$old_dist_info" "$new_dist_info"
# Update METADATA
sed -i 's/^Name: debug-toolbar$/Name: litestar-debug-toolbar/' "$new_dist_info/METADATA"
# Update RECORD with new paths
sed -i 's/debug_toolbar-/litestar_debug_toolbar-/g' "$new_dist_info/RECORD"
cd tmp_wheel
zip -q -r "../$new_name" .
cd ..
rm -rf tmp_wheel "$f"
done
for f in debug_toolbar-*.tar.gz; do
new_name=$(echo "$f" | sed 's/debug_toolbar/litestar_debug_toolbar/' | sed 's/debug-toolbar/litestar-debug-toolbar/')
# For sdist, we need to extract, modify, and repack
mkdir -p tmp_sdist
tar -xzf "$f" -C tmp_sdist
cd tmp_sdist/*/
sed -i 's/name = "debug-toolbar"/name = "litestar-debug-toolbar"/' pyproject.toml
sed -i 's/"debug-toolbar\[/"litestar-debug-toolbar[/g' pyproject.toml
cd ..
# Rename directory
old_dir=$(ls -d */ | head -1 | tr -d '/')
new_dir=$(echo "$old_dir" | sed 's/debug_toolbar/litestar_debug_toolbar/')
mv "$old_dir" "$new_dir"
tar -czf "../$new_name" "$new_dir"
cd ..
rm -rf tmp_sdist "$f"
done
- name: Upload dist artifacts
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v4
with:
name: ${{ matrix.artifact-name }}
path: dist/
retention-days: 7
# ==================================================================================== #
# SIGN
# ==================================================================================== #
sign:
name: Sign Distributions (${{ matrix.package-name }})
runs-on: ubuntu-latest
needs: [build]
strategy:
matrix:
include:
# TODO: Re-enable after PEP 541 name request is processed
# - package-name: debug-toolbar
# artifact-name: dist-debug-toolbar
# signed-artifact-name: dist-debug-toolbar-signed
- package-name: litestar-debug-toolbar
artifact-name: dist-litestar-debug-toolbar
signed-artifact-name: dist-litestar-debug-toolbar-signed
steps:
- name: Download dist artifacts
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v4
with:
name: ${{ matrix.artifact-name }}
path: dist/
- name: Sign distributions with Sigstore
uses: sigstore/gh-action-sigstore-python@f832326173235dcb00dd5d92cd3f353de3188e6c # v3.1.0
with:
inputs: ./dist/*
- name: Upload signed artifacts
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v4
with:
name: ${{ matrix.signed-artifact-name }}
path: dist/
retention-days: 7
# ==================================================================================== #
# DRAFT RELEASE
# ==================================================================================== #
draft-release:
name: Create Draft Release
runs-on: ubuntu-latest
needs: [sign]
steps:
# TODO: Re-enable after PEP 541 name request is processed
# - name: Download debug-toolbar signed artifacts
# uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v4
# with:
# name: dist-debug-toolbar-signed
# path: dist/debug-toolbar/
- name: Download litestar-debug-toolbar signed artifacts
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v4
with:
name: dist-litestar-debug-toolbar-signed
path: dist/litestar-debug-toolbar/
- name: Create GitHub Release (Draft)
uses: softprops/action-gh-release@5be0e66d93ac7ed76da52eca8bb058f665c3a5fe # v2
with:
draft: true
files: |
dist/**/*
generate_release_notes: true
# ==================================================================================== #
# PUBLISH TO PYPI - debug-toolbar
# TODO: Re-enable after PEP 541 name request is processed
# ==================================================================================== #
# publish-debug-toolbar:
# name: Publish debug-toolbar to PyPI
# runs-on: ubuntu-latest
# needs: [draft-release]
# environment:
# name: pypi
# url: https://pypi.org/project/debug-toolbar/
# steps:
# - name: Download dist artifacts
# uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v4
# with:
# name: dist-debug-toolbar
# path: dist/
#
# - name: Publish to PyPI
# uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1
# with:
# print-hash: true
# attestations: true
# ==================================================================================== #
# PUBLISH TO PYPI - litestar-debug-toolbar
# ==================================================================================== #
publish-litestar-debug-toolbar:
name: Publish litestar-debug-toolbar to PyPI
runs-on: ubuntu-latest
needs: [draft-release]
environment:
name: pypi-litestar
url: https://pypi.org/project/litestar-debug-toolbar/
steps:
- name: Download dist artifacts
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v4
with:
name: dist-litestar-debug-toolbar
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1
with:
print-hash: true
attestations: true
# ==================================================================================== #
# FINALIZE RELEASE
# ==================================================================================== #
publish-release:
name: Publish Release
runs-on: ubuntu-latest
# TODO: Add publish-debug-toolbar back after PEP 541 name request is processed
needs: [publish-litestar-debug-toolbar]
steps:
- name: Mark Release as Published
uses: softprops/action-gh-release@5be0e66d93ac7ed76da52eca8bb058f665c3a5fe # v2
with:
draft: false
# ==================================================================================== #
# CLEANUP ON FAILURE
# ==================================================================================== #
cleanup-draft:
name: Cleanup Draft Release
runs-on: ubuntu-latest
# TODO: Add publish-debug-toolbar back after PEP 541 name request is processed
needs: [publish-litestar-debug-toolbar]
if: failure()
steps:
- name: Delete Draft Release
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v7
with:
script: |
const releases = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo
});
const draft = releases.data.find(r => r.draft && r.tag_name === context.ref.replace('refs/tags/', ''));
if (draft) {
await github.rest.repos.deleteRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: draft.id
});
}