This repository has been archived by the owner on Nov 19, 2024. It is now read-only.
Publish Python Package #23
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |