Skip to content

Release python package on PyPi #16

Release python package on PyPi

Release python package on PyPi #16

Workflow file for this run

# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Release python package on PyPi
on:
release:
types: [published]
permissions:
contents: read
jobs:
pypi-publish:
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python 3.x
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Check version consistency
run: |
import os
import sys
from tensorhue import __version__
github_ref = os.environ.get('GITHUB_REF')
if github_ref.startswith('refs/tags/'):
release_version = github_ref.split('/')[-1]
if release_version.startswith('v'):
release_version = release_version[1:] # Remove 'v' prefix
if release_version != __version__:
print(f"Version mismatch: GitHub release {release_version} != Package version {__version__}")
sys.exit(1)
print(f"Version {__version__} matches GitHub release tag (without 'v' prefix).")
else:
print("Not a release tag, skipping version check.")
shell: python
- name: Build package
run: python -m build
- name: Publish package on PyPi
uses: pypa/gh-action-pypi-publish@release/v1