Skip to content

Commit

Permalink
[DOP-11677] - add workflow for dev-release in test-pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
maxim-lixakov committed Feb 13, 2024
1 parent d0b6077 commit 51eda65
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 9 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/dev-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Dev release

on:
push:
branches-ignore:
- dependabot/**
- pre-commit-ci-update-config
- master
workflow_dispatch:

env:
DEFAULT_PYTHON: '3.12'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
wait-code-analysis:
name: Dev release package
runs-on: ubuntu-latest
if: github.repository == 'MobileTeleSystems/horizon-hwm-store' # prevent running on forks

environment:
name: test-pypi
url: https://test.pypi.org/p/horizon-hwm-store
permissions:
id-token: write # to auth in Test PyPI

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v5
with:
python-version: ${{ env.DEFAULT_PYTHON }}

- name: Upgrade pip
run: python -m pip install --upgrade pip setuptools wheel

- name: Build package
run: python setup.py sdist bdist_wheel

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
17 changes: 8 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@


def get_version():
if "CI_COMMIT_TAG" in os.environ:
return os.environ["CI_COMMIT_TAG"]
if os.getenv("GITHUB_REF_TYPE", "branch") == "tag":
return os.environ["GITHUB_REF_NAME"]

version_file = here / "horizon_hwm_store" / "VERSION"
version = version_file.read_text().strip() # noqa: WPS410

build_num = os.environ.get("CI_PIPELINE_IID", "")
branch_name = os.environ.get("CI_COMMIT_REF_SLUG", "")
branches_protect = ["master", "develop"]
build_num = os.environ.get("GITHUB_RUN_ID", "0")
branch_name = os.environ.get("GITHUB_REF_NAME", "")

if not branch_name or branch_name in branches_protect:
return f"{version}.dev{build_num}"
if not branch_name:
return version

return f"{version}.dev{build_num}+{branch_name}"
return f"{version}.dev{build_num}"


def parse_requirements(file: Path) -> list[str]:
Expand All @@ -48,7 +47,6 @@ def parse_requirements(file: Path) -> list[str]:
url="https://github.com/MobileTeleSystems/horizon-hwm-store",
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Data engineers",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
Expand All @@ -59,6 +57,7 @@ def parse_requirements(file: Path) -> list[str]:
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries",
"Typing :: Typed",
],
Expand Down

0 comments on commit 51eda65

Please sign in to comment.