Skip to content

Commit

Permalink
add github workflow to build and publish
Browse files Browse the repository at this point in the history
  • Loading branch information
liyaka committed Sep 1, 2024
1 parent 8d6699e commit 5b0fb8a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/build_and_publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "Build and Publish"
run-name: "Build ${{ github.ref_name }} by @${{ github.actor }}"

on:
workflow_dispatch:
inputs:
version:
type: string
required: true
description: Version

jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
with:
submodules: true
fetch-tags: true

- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: 3.9

- name: Build pip package
run: |
pip3 install -U pip build
export VERSION="${{inputs.version}}"
python3 -m build --sdist --wheel --outdir dist/ .
- name: Create git tag
run: |
set -x
git config --local user.email "[email protected]"
git config --local user.name "github-actions"
git tag ${{inputs.version}}
git push --no-verify origin ${{inputs.version}}
- name: Publish package distributions to PyPI
uses: pypa/[email protected]
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: dist
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ classifiers = [
"Intended Audience :: Developers",
"Operating System :: OS Independent",
]
dynamic = ["version"]
dynamic = ["version", "readme"]
dependencies = [
"ansible_runner==2.3.3",
"ansible>=6.7",
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# setup.py
import subprocess
from setuptools import setup
import os


def get_version():
Expand All @@ -12,5 +13,7 @@ def get_version():


setup(
version=get_version(), # Dynamically set the version
version=os.environ.get('VERSION', get_version()), # Dynamically set the version
long_description=open('README.md',encoding="utf-8").read(),
long_description_content_type='text/markdown',
)

0 comments on commit 5b0fb8a

Please sign in to comment.