feat: added ci that push to pypi
This commit is contained in:
parent
b9258d530f
commit
5f1c796003
40
.github/workflows/pypi.yaml
vendored
Normal file
40
.github/workflows/pypi.yaml
vendored
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
name: Publish to Pypi
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
name: Publish to PyPI
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Install Python3
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install python3 python3-pip
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install setuptools wheel twine
|
||||||
|
|
||||||
|
- name: Extract tag name
|
||||||
|
run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3)
|
||||||
|
|
||||||
|
- name: Set version to tag
|
||||||
|
run: |
|
||||||
|
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" osdk/const.py
|
||||||
|
|
||||||
|
- name: Build a binary wheel
|
||||||
|
run: |
|
||||||
|
python setup.py sdist bdist_wheel
|
||||||
|
|
||||||
|
- name: Publish a Python distribution to PyPI
|
||||||
|
uses: pypa/gh-action-pypi-publish@release/v1
|
||||||
|
with:
|
||||||
|
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
@ -145,7 +145,7 @@ cmds += [Cmd("h", "help", "Show this help message", helpCmd)]
|
||||||
|
|
||||||
|
|
||||||
def versionCmd(args: Args):
|
def versionCmd(args: Args):
|
||||||
print(f"OSDK v{const.VERSION}\n")
|
print(f"OSDK v{const.get_version()}\n")
|
||||||
|
|
||||||
|
|
||||||
cmds += [Cmd("v", "version", "Show current version", versionCmd)]
|
cmds += [Cmd("v", "version", "Show current version", versionCmd)]
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import subprocess
|
||||||
|
|
||||||
VERSION = "0.4.0"
|
VERSION = "{{VERSION_PLACEHOLDER}}"
|
||||||
MODULE_DIR = os.path.dirname(os.path.realpath(__file__))
|
MODULE_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||||
ARGV0 = os.path.basename(sys.argv[0])
|
ARGV0 = os.path.basename(sys.argv[0])
|
||||||
OSDK_DIR = ".osdk"
|
OSDK_DIR = ".osdk"
|
||||||
|
|
|
@ -2,6 +2,8 @@ from typing import Any, TypeVar, cast
|
||||||
import json
|
import json
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
|
from osdk import shell, const
|
||||||
|
|
||||||
T = TypeVar('T')
|
T = TypeVar('T')
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,3 +58,10 @@ def asList(i: T | list[T] | None) -> list[T]:
|
||||||
if isinstance(i, list):
|
if isinstance(i, list):
|
||||||
return cast(list[T], i)
|
return cast(list[T], i)
|
||||||
return [i]
|
return [i]
|
||||||
|
|
||||||
|
|
||||||
|
def get_version() -> str:
|
||||||
|
if const.VERSION == "{{VERSION_PLACEHOLDER}}":
|
||||||
|
return str(int(shell.popen(*["git", "rev-parse", "--short", "HEAD"])[:-1], 16))
|
||||||
|
else:
|
||||||
|
return const.VERSION
|
4
setup.py
4
setup.py
|
@ -1,9 +1,9 @@
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
from osdk.const import VERSION
|
from osdk.utils import get_version
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="osdk",
|
name="osdk",
|
||||||
version=VERSION,
|
version=get_version(),
|
||||||
python_requires='>=3.10',
|
python_requires='>=3.10',
|
||||||
description="Operating System Development Kit",
|
description="Operating System Development Kit",
|
||||||
author="The DEVSE Community",
|
author="The DEVSE Community",
|
||||||
|
|
Loading…
Reference in a new issue