Skip to content

Publish Python Package #23

Publish Python Package

Publish Python Package #23

Workflow file for this run

name: Publish Python Package
on:
workflow_dispatch:
jobs:
deploy:
needs:
- set_version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Setup Python
run: uv python install
- name: Create Github Release
id: create_release
uses: softprops/action-gh-release@v2
with:
draft: false
prerelease: false
tag_name: v${{ needs.set_version.outputs.version }}
generate_release_notes: true
- name: Build and publish on private PyPI
run: |
uv build
# TODO: Uncomment when flask-utils had been freed from pypi
# uvx twine upload dist/*
- name: Upload .whl artifact to GitHub release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/Flask_Utils-${{ needs.set_version.outputs.version }}-py3-none-any.whl
asset_name: flask_utils-${{ needs.set_version.outputs.version }}-py3-none-any.whl
asset_content_type: application/zip
- name: Upload .tar.gz artifact to GitHub release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/flask_utils-${{ needs.set_version.outputs.version }}.tar.gz
asset_name: flask_utils-${{ needs.set_version.outputs.version }}.tar.gz
asset_content_type: application/gzip
set_version:
name: Set the version of the release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set version
id: set_version
run: |
echo version=$( sed -e 's/__version__ = "\(.*\)"/\1/g' <<< $(grep -E '__version__ = ' flask_utils/__init__.py)) >> "$GITHUB_OUTPUT"
outputs:
version: ${{ steps.set_version.outputs.version }}