diff --git a/.github/bump_version.py b/.github/bump_version.py deleted file mode 100644 index 4c570dcad..000000000 --- a/.github/bump_version.py +++ /dev/null @@ -1,23 +0,0 @@ -# SPDX-FileCopyrightText: 2017-2023 Contributors to the OpenSTEF project # noqa E501 -# -# SPDX-License-Identifier: MPL-2.0 - -import re - -with open("setup.py", "r") as file: - version_content = file.read() -# Match regex for pattern -old_semantic_version = re.findall( - r'version="(\d+\.\d+\.[a-zA-Z0-9]+)",', version_content -) -major_version, minor_version, patch_version = old_semantic_version[0].split(".") -patch_version = int(re.findall(r"\d+", patch_version)[0]) -new_semantic_version = f"{major_version}.{minor_version}.{patch_version + 1}" -regex_bumped_patch_version = f"\g<1>{new_semantic_version}" -# Match regex for pattern -bumped_version_content = re.sub( - r'(version=")\d+\.\d+\.[a-zA-Z0-9]+', regex_bumped_patch_version, version_content -) -with open("setup.py", "w") as file: - file.write(bumped_version_content) -print(new_semantic_version) # Print is required for release in github action diff --git a/.github/workflows/python-upload-package.yaml b/.github/workflows/python-upload-package.yaml index dc2c11bd6..7ea14b914 100644 --- a/.github/workflows/python-upload-package.yaml +++ b/.github/workflows/python-upload-package.yaml @@ -1,16 +1,27 @@ # SPDX-FileCopyrightText: 2017-2023 Contributors to the OpenSTEF project # noqa E501 # # SPDX-License-Identifier: MPL-2.0 -name: Python Upload Package +name: Release V3 + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true on: - - release + release: + types: [published] + workflow_dispatch: + inputs: + version: + description: 'Version tag to release (e.g., v3.4.19 or 3.4.19). Prefixing with v is optional.' + required: true + default: "" jobs: deploy: runs-on: ubuntu-latest environment: release - if: startsWith(github.event.release.tag_name, 'v3.') + if: ${{ startsWith(github.event.release.tag_name, 'v3.') || (github.event_name == 'workflow_dispatch' && (startsWith(github.event.inputs.version, '3') || startsWith(github.event.inputs.version, 'v3'))) }} permissions: # IMPORTANT: this permission is mandatory for trusted publishing id-token: write @@ -23,6 +34,27 @@ jobs: uses: actions/setup-python@v5 with: python-version: '3.x' + # Set version from release tag + - name: Set version + id: ver + env: + RELEASE_TAG: ${{ github.event.release.tag_name }} + INPUT_VERSION: ${{ github.event.inputs.version }} + run: | + if [ -n "$RELEASE_TAG" ]; then + VERSION="$RELEASE_TAG" + elif [ -n "$INPUT_VERSION" ]; then + VERSION="$INPUT_VERSION" + else + echo "No version provided, aborting" + exit 1 + fi + VERSION="${VERSION#v}" + echo "Release version: $VERSION" + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" + # Apply version to setup.py + - name: Apply version + run: sed -i "s/version=\"[^\"]*\"/version=\"${{ steps.ver.outputs.version }}\"/" setup.py # Install (packaging) dependencies - name: Install dependencies run: | diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index 06dcb804e..000000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,52 +0,0 @@ -# SPDX-FileCopyrightText: 2017-2023 Contributors to the OpenSTEF project # noqa E501 -# -# SPDX-License-Identifier: MPL-2.0 - -name: Release - -# Trigger when a python file is changed on main branch either from pull request or push -# but not when only setup.py is changed due to version bump -on: - push: - branches: - - 'main' - paths: - - '**.py' - - '!setup.py' - - 'requirements.txt' - workflow_dispatch: - -jobs: - # Releases new Python version when Pull Requests are merged into "main" - release: - runs-on: ubuntu-latest - steps: - # Checkout - - name: Checkout - uses: actions/checkout@v4 - with: - persist-credentials: false - # Setup - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - # Bump and commit version. The upload to pypi step happens after github release. - - name: Bump version and commit bumped version back to branch - env: - GITHUB_ACCESS_TOKEN: ${{ secrets.OPENSTEF_GITHUB_TOKEN }} - id: version - run: | - version=$(python .github/bump_version.py) - git config --global user.name 'bump_version' - git config --global user.email 'action@github.com' - git remote set-url origin "https://$GITHUB_ACCESS_TOKEN@github.com/$GITHUB_REPOSITORY" - git commit --signoff -am "Bumped minor version" - git push - echo "BUMPED_VERSION=$(echo v$version)" >> $GITHUB_ENV - echo "New version: $version" - # Create new release (does not work with standard github token, but needs PAT) - - name: Create Release - run: gh release create ${{ env.BUMPED_VERSION }} --generate-notes - env: - GITHUB_TOKEN: ${{ secrets.OPENSTEF_GITHUB_TOKEN }} diff --git a/setup.py b/setup.py index 7e1df2832..2852b3e1e 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ def read_long_description_from_readme(): setup( name="openstef", - version="3.4.92", + version="0.0.0", packages=find_packages(include=["openstef", "openstef.*"]), description="Open short term energy forecaster", long_description=read_long_description_from_readme(),