diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml deleted file mode 100644 index 97ab48d9..00000000 --- a/.github/workflows/merge.yml +++ /dev/null @@ -1,100 +0,0 @@ -name: Build and upload to PyPI - -on: - push: - branches: - - 'main' - pull_request: - branches: - - 'main' - pull_request_review: - types: [submitted] -permissions: - contents: write - -jobs: - update_version: - name: update version - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v4 - with: - fetch-depth: "0" - - name: Update version on merge - run: | - python tools/version.py "beta" - - name: Store changes - uses: actions/upload-artifact@v3 - with: - name: pyproject - path: pyproject.toml - - build: - name: Build wheels and src - runs-on: ubuntu-latest - needs: [update_version] - steps: - - name: checkout - uses: actions/checkout@v3 - with: - fetch-depth: "0" - - uses: actions/download-artifact@v3 - with: - name: pyproject - - name: install build - run: python -m pip install build - - name: build wheel - run: python -m build --sdist --wheel - - name: upload wheel - uses: actions/upload-artifact@v3 - with: - path: dist/ - - upload_pypi: - needs: [build] - runs-on: ubuntu-latest - permissions: - id-token: write - steps: - - name: mint API token - id: mint - uses: tschm/token-mint-action@v1.0.2 - - - uses: actions/download-artifact@v3 - with: - name: artifact - path: dist - - - name: Publish package distribution to PYPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ steps.mint.outputs.api-token }} - - update_setup: - needs: [upload_pypi] - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: checkout - uses: actions/checkout@v4 - with: - fetch-depth: "0" - repository: ${{github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - - - uses: actions/download-artifact@v3 - with: - name: pyproject - - name: check - run: | - cat pyproject.toml - echo ${{github.event.pull_request.head.repo.full_name }} - - name: Commit on merge - run: | - git config user.name github-actions - git config user.email github-actions@github.com - git add pyproject.toml - git commit -m "update version number" - git push diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5ef808be..ad447bf4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,8 +18,6 @@ jobs: run: python -m pip install build pytest --user - name: build wheel run: python -m build --sdist --wheel - - name: test wheel - run: python -m pytest - name: upload wheel uses: actions/upload-artifact@v3 with: diff --git a/tools/version.py b/tools/version.py deleted file mode 100644 index 646db4bc..00000000 --- a/tools/version.py +++ /dev/null @@ -1,82 +0,0 @@ -import argparse -import sys - - -VERSION_STRING = "version = " -VERSION_MARKS = '"' -ORDER = ['major', 'minor', 'patch', 'beta'] -VERSION_SEP = ['.', '.', 'b', ''] - - -def make_str(version): - """ - Simple function to convert version dict into a string - """ - txt = VERSION_MARKS - for j in range(len(ORDER)): - txt += version[ORDER[j]] + VERSION_SEP[j] - txt += VERSION_MARKS + '\n' - return txt - - -def update_version_str(txt: str, bump: str) -> str: - """ - Extracts the version from text and then applies - an appropriate bump - """ - tmp = txt.split(VERSION_MARKS) - tmp = tmp[1] - version = {} - - version[ORDER[0]] = tmp.split(VERSION_SEP[0])[0] - version[ORDER[1]] = tmp.split(VERSION_SEP[1])[1] - version[ORDER[2]] = tmp.split(VERSION_SEP[2])[0].split(VERSION_SEP[1])[2] - version[ORDER[3]] = tmp.split(VERSION_SEP[2])[1] - - version[bump] = str(int(version[bump]) + 1) - index = ORDER.index(bump) - # reset below current bump - for j in range(index+1, len(ORDER)): - version[ORDER[j]] = str(0) - return VERSION_STRING + make_str(version) - - -def update_version(file_name: str, bump: str): - """ - Reads the file and then updates the version - according to the specified bump - """ - if bump not in ORDER: - raise ValueError("Specified bump is not allowed") - - lines = [] - with open(file_name, 'r') as file: - lines = file.readlines() - - with open(file_name, 'w') as file: - for txt in lines: - if VERSION_STRING in txt: - txt = update_version_str(txt, bump) - file.write(txt) - - -def get_input(): - """ - get the bump for the version from the command line arg - :returns the bump for the version - """ - parser = argparse.ArgumentParser() - parser.add_argument('bump', - help='the bump to the setup file', type=str) - args = parser.parse_args() - print(args) - return args.bump - - -if __name__ == "__main__": - try: - bump = get_input() - update_version('pyproject.toml', bump) - except ValueError: - error = sys.exc_info()[1] - print(error)