From e88c805a278e12c425508ed716397544ab23fb94 Mon Sep 17 00:00:00 2001 From: Erik Wallinder-Mahler Date: Mon, 24 Jun 2024 20:13:44 +0200 Subject: [PATCH] It's like poetry --- .github/workflows/release.yml | 93 +++++++++++++++++++++++--------- .gitignore | 50 +++++++++++++++++ LICENSE | 0 README.md | 3 ++ poetry.lock | 22 ++++++++ pyproject.toml | 15 ++++++ test_env.py => tests/test_env.py | 0 7 files changed, 158 insertions(+), 25 deletions(-) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 poetry.lock create mode 100644 pyproject.toml rename test_env.py => tests/test_env.py (100%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9afe7c9..9653086 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,34 +1,77 @@ -name: Release +name: Publish Python Package + on: push: tags: - - 'v[0-9]+.[0-9]+.[0-9]+' #Versioning by semantic versioning + - 'v*.*.*' + pull_request: + branches: + - main + jobs: build: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Extract and Parse version info from tag + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install Poetry run: | - VERSION=${GITHUB_REF:11} - MAJOR=$(echo "$VERSION" | cut -d. -f1) - MINOR=$(echo "$VERSION" | cut -d. -f2) - PATCH=$(echo "$VERSION" | cut -d. -f3) - echo "version=$VERSION" >> $GITHUB_ENV - echo "version_major=$MAJOR" >> $GITHUB_ENV - echo "version_minor=$MINOR" >> $GITHUB_ENV - echo "version_patch=$PATCH" >> $GITHUB_ENV - - name: Build and Push Docker Image + curl -sSL https://install.python-poetry.org | python3 - + echo "${HOME}/.local/bin" >> $GITHUB_PATH + + - name: Configure Poetry run: | - IMG=ghcr.io/${{ github.repository }} - docker build \ - --tag $IMG:${{ env.version }} \ - --tag $IMG:${{ env.version_major }}.${{ env.version_minor }}.${{ env.version_patch }} \ - --tag $IMG:${{ env.version_major }}.${{ env.version_minor }}.latest \ - --tag $IMG:${{ env.version_major }}.latest \ - --tag $IMG:latest \ - . - docker push --all-tags $IMG - - name: Registry Login (ghcr.io) + poetry config virtualenvs.create false + + - name: Install dependencies + run: poetry install + + publish: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install Poetry run: | - echo "${{ secrets.GH_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + curl -sSL https://install.python-poetry.org | python3 - + echo "${HOME}/.local/bin" >> $GITHUB_PATH + + + - name: Install dependencies + run: poetry install + + - name: Build package + run: poetry build + + - name: Publish package to PyPI + env: + POETRY_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + run: poetry publish --username __token__ --password $POETRY_PYPI_TOKEN + + release: + needs: [build, publish] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Create GitHub Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..45d959c --- /dev/null +++ b/.gitignore @@ -0,0 +1,50 @@ +dist/ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# Distribution / packaging +build/ +dist/ +*.egg-info/ +.eggs/ + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Test / coverage reports +.coverage +.tox/ +.nox/ +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ + +# Jupyter Notebook +.ipynb_checkpoints + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# PyCharm +.idea/ + +# VS Code +.vscode/ + +# mypy +.mypy_cache/ + +# Pytest +.pytest_cache/ \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md new file mode 100644 index 0000000..7d07edf --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Versioning tool for REMLA frontend + +Installs using Poetry \ No newline at end of file diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..a76ed4e --- /dev/null +++ b/poetry.lock @@ -0,0 +1,22 @@ +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. + +[[package]] +name = "setuptools" +version = "69.5.1" +description = "Easily download, build, install, upgrade, and uninstall Python packages" +optional = false +python-versions = ">=3.8" +files = [ + {file = "setuptools-69.5.1-py3-none-any.whl", hash = "sha256:c636ac361bc47580504644275c9ad802c50415c7522212252c033bd15f301f32"}, + {file = "setuptools-69.5.1.tar.gz", hash = "sha256:6c1fccdac05a97e598fb0ae3bbed5904ccb317337a51139dcd51453611bbb987"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier"] +testing = ["build[virtualenv]", "filelock (>=3.4.0)", "importlib-metadata", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "mypy (==1.9)", "packaging (>=23.2)", "pip (>=19.1)", "pytest (>=6,!=8.1.1)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-home (>=0.5)", "pytest-mypy", "pytest-perf", "pytest-ruff (>=0.2.1)", "pytest-timeout", "pytest-xdist (>=3)", "tomli", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] +testing-integration = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.2)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] + +[metadata] +lock-version = "2.0" +python-versions = "^3.11" +content-hash = "03f656a90ba659995e78308ee24f242472583a9a440b06d1e6cea79554c01f83" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4e66063 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,15 @@ +[tool.poetry] +name = "remlaversionutilpy" +version = "0.1.2" +description = "Versioning for REMLA frontend" +authors = ["Erik Wallinder-Mahler "] +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.11" +setuptools = "69.5.1" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" diff --git a/test_env.py b/tests/test_env.py similarity index 100% rename from test_env.py rename to tests/test_env.py