From 68ac385f0c21468e4cd22838f1cee919e18229a6 Mon Sep 17 00:00:00 2001 From: "P.T. Jochym" Date: Sat, 7 Dec 2024 17:05:16 +0100 Subject: [PATCH 1/9] split workflow file for dev --- .github/workflows/pypi.yml | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 66ee5bf..e8d81ce 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -1,11 +1,7 @@ name: Build, test and publish to (test)PyPI on: push: - tags: - - 'v*' # matches semantic versioning (e.g., v1.2.3) branches: - - main - - master - dev jobs: @@ -54,7 +50,6 @@ jobs: # if: ${{ github.event_name == 'push' && ( github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/master' ) }} # Run on untagged push # if: ${{ !startsWith(github.ref, 'refs/tags/') }} - if: ${{ github.ref == 'refs/heads/dev' }} needs: - build runs-on: ubuntu-latest @@ -77,28 +72,3 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 with: repository-url: https://test.pypi.org/legacy/ - - - publish-to-pypi: - name: Publish to PyPI - if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes - needs: - - build - runs-on: ubuntu-latest - - environment: - name: pypi - url: https://pypi.org/p/elastic - - permissions: - id-token: write # IMPORTANT: mandatory for trusted publishing - - steps: - - name: Download all the dists - uses: actions/download-artifact@main - with: - name: python-package-distributions - path: dist/ - - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 From 546d73f093ffc29a0974bc017a184dd86b1db859 Mon Sep 17 00:00:00 2001 From: "P.T. Jochym" Date: Sat, 7 Dec 2024 17:42:31 +0100 Subject: [PATCH 2/9] Try new scheme for versioning in dev --- setup.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index e5a4c75..58d91ec 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,13 @@ def current_version(version: ScmVersion) -> str: return version.format_next_version(guess_next_version, "{tag}"+ delim +"{distance}") +def myversion_func(version: ScmVersion) -> str: + from setuptools_scm.version import guess_next_version + + return version.format_next_version(guess_next_version, "{tag}.{distance}") + -setup(use_scm_version={"version_scheme": current_version, - "local_scheme": get_no_local_node}) +# setup(use_scm_version={"version_scheme": current_version, +# "local_scheme": get_no_local_node}) +setup(use_scm_version={"version_scheme": myversion_func}) \ No newline at end of file From 4adbc83257e2983a26b85ed78936159845396808 Mon Sep 17 00:00:00 2001 From: "P.T. Jochym" Date: Sat, 7 Dec 2024 18:03:42 +0100 Subject: [PATCH 3/9] Remove dev from distance --- setup.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index 58d91ec..7aae7ee 100644 --- a/setup.py +++ b/setup.py @@ -16,16 +16,10 @@ def current_version(version: ScmVersion) -> str: if version.branch in ("fix", "hotfix"): delim = '-post' + return version.format_next_version(guess_next_version, + "{tag}.{distance}") return version.format_next_version(guess_next_version, "{tag}"+ delim +"{distance}") -def myversion_func(version: ScmVersion) -> str: - from setuptools_scm.version import guess_next_version - - return version.format_next_version(guess_next_version, "{tag}.{distance}") - - -# setup(use_scm_version={"version_scheme": current_version, -# "local_scheme": get_no_local_node}) - -setup(use_scm_version={"version_scheme": myversion_func}) \ No newline at end of file +setup(use_scm_version={"version_scheme": current_version, + "local_scheme": get_no_local_node}) From c7e4bbc6ec6ac8c72d872a6fc12cefc82c68e6af Mon Sep 17 00:00:00 2001 From: "P.T. Jochym" Date: Sat, 7 Dec 2024 18:05:04 +0100 Subject: [PATCH 4/9] Revert to previous scheme --- setup.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/setup.py b/setup.py index 7aae7ee..0ff0ae5 100644 --- a/setup.py +++ b/setup.py @@ -16,8 +16,6 @@ def current_version(version: ScmVersion) -> str: if version.branch in ("fix", "hotfix"): delim = '-post' - return version.format_next_version(guess_next_version, - "{tag}.{distance}") return version.format_next_version(guess_next_version, "{tag}"+ delim +"{distance}") From c0426ccaa3174ae2cbd60d37123c03c6e102355b Mon Sep 17 00:00:00 2001 From: "P.T. Jochym" Date: Sat, 7 Dec 2024 18:31:02 +0100 Subject: [PATCH 5/9] Split off build workflow --- .github/workflows/build.yml | 45 +++++++++++ .github/workflows/testpypi.yml | 138 +++++++++++++++++++++++++++++++++ 2 files changed, 183 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/testpypi.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..91fc8ec --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,45 @@ +name: Build and test +on: + workflow_call: + +jobs: + build: + name: Build distribution + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@main + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@main + with: + python-version: "3.x" + + - name: Install pypa/build + run: >- + python3 -m + pip install + build + --user + + - name: Build a binary wheel and a source tarball + run: python3 -m build + + - name: Test + run: | + python3 -m pip install hypothesis + python3 -m pip install dist/elastic*.whl + elastic --version + python3 -m unittest discover -s test -b + elastic -v --cij proc tests/data/calc-cij_*/vasprun.xml + elastic -v --eos proc tests/data/calc-eos_*/vasprun.xml + + - name: Store the distribution packages + uses: actions/upload-artifact@main + with: + name: python-package-distributions + path: dist/ + + \ No newline at end of file diff --git a/.github/workflows/testpypi.yml b/.github/workflows/testpypi.yml new file mode 100644 index 0000000..22d577f --- /dev/null +++ b/.github/workflows/testpypi.yml @@ -0,0 +1,138 @@ +name: Build, test and publish to testPyPI +on: + push: + tags: + - 'v*' # matches semantic versioning (e.g., v1.2.3) + branches: + - dev + +jobs: + publish-to-testpypi: + name: Publish to TestPyPI + # Only on dev pushes + # if: ${{ github.event_name == 'push' && ( github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/master' ) }} + # Run on untagged push + # if: ${{ !startsWith(github.ref, 'refs/tags/') }} + if: ${{ github.ref == 'refs/heads/dev' }} + uses: ./.github/workflows/build.yml + runs-on: ubuntu-latest + + environment: + name: testpypi + url: https://test.pypi.org/p/elastic + + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@main + with: + name: python-package-distributions + path: dist/ + + - name: Publish distribution to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + + + publish-to-pypi: + name: Publish to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + + environment: + name: pypi + url: https://pypi.org/p/elastic + + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@main + with: + name: python-package-distributions + path: dist/ + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + +name: Build, test and publish to (test)PyPI +on: + push: + branches: + - dev + +jobs: + build: + name: Build distribution + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@main + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@main + with: + python-version: "3.x" + + - name: Install pypa/build + run: >- + python3 -m + pip install + build + --user + + - name: Build a binary wheel and a source tarball + run: python3 -m build + + - name: Test + run: | + python3 -m pip install hypothesis + python3 -m pip install dist/elastic*.whl + elastic --version + python3 -m unittest discover -s test -b + elastic -v --cij proc tests/data/calc-cij_*/vasprun.xml + elastic -v --eos proc tests/data/calc-eos_*/vasprun.xml + + - name: Store the distribution packages + uses: actions/upload-artifact@main + with: + name: python-package-distributions + path: dist/ + + publish-to-testpypi: + name: Publish to TestPyPI + # Only on dev pushes + # if: ${{ github.event_name == 'push' && ( github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/master' ) }} + # Run on tagged push + if: ${{ startsWith(github.ref, 'refs/tags/') }} + needs: + - build + runs-on: ubuntu-latest + + environment: + name: testpypi + url: https://test.pypi.org/p/elastic + + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@main + with: + name: python-package-distributions + path: dist/ + + - name: Publish distribution to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ From a608c05f8420819f148ff2b91f7cd9aaf75e8aff Mon Sep 17 00:00:00 2001 From: "P.T. Jochym" Date: Sat, 7 Dec 2024 18:32:24 +0100 Subject: [PATCH 6/9] Limit pypi to master/main --- .github/workflows/pypi.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index e8d81ce..6bf91f8 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -2,7 +2,8 @@ name: Build, test and publish to (test)PyPI on: push: branches: - - dev + - master + - main jobs: build: @@ -48,8 +49,8 @@ jobs: name: Publish to TestPyPI # Only on dev pushes # if: ${{ github.event_name == 'push' && ( github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/master' ) }} - # Run on untagged push - # if: ${{ !startsWith(github.ref, 'refs/tags/') }} + # Run on tagged push + if: ${{ startsWith(github.ref, 'refs/tags/') }} needs: - build runs-on: ubuntu-latest From 385d1ff3be86d2d0a843a8c328c2c65d86926186 Mon Sep 17 00:00:00 2001 From: "P.T. Jochym" Date: Sat, 7 Dec 2024 18:36:57 +0100 Subject: [PATCH 7/9] Correct syntax --- .github/workflows/build.yml | 3 +- .github/workflows/pypi.yml | 61 +++----------------- .github/workflows/testpypi.yml | 102 +-------------------------------- 3 files changed, 12 insertions(+), 154 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91fc8ec..c252b9d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,5 @@ name: Build and test -on: - workflow_call: +on: workflow_call jobs: build: diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 6bf91f8..08f9d68 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -1,63 +1,22 @@ name: Build, test and publish to (test)PyPI on: push: + tags: + - 'v*' # matches semantic versioning (e.g., v1.2.3) branches: - master - main jobs: - build: - name: Build distribution - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@main - with: - fetch-depth: 0 - - - name: Set up Python - uses: actions/setup-python@main - with: - python-version: "3.x" - - - name: Install pypa/build - run: >- - python3 -m - pip install - build - --user - - - name: Build a binary wheel and a source tarball - run: python3 -m build - - - name: Test - run: | - python3 -m pip install hypothesis - python3 -m pip install dist/elastic*.whl - elastic --version - python3 -m unittest discover -s test -b - elastic -v --cij proc tests/data/calc-cij_*/vasprun.xml - elastic -v --eos proc tests/data/calc-eos_*/vasprun.xml - - - name: Store the distribution packages - uses: actions/upload-artifact@main - with: - name: python-package-distributions - path: dist/ - - publish-to-testpypi: - name: Publish to TestPyPI - # Only on dev pushes - # if: ${{ github.event_name == 'push' && ( github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/master' ) }} - # Run on tagged push - if: ${{ startsWith(github.ref, 'refs/tags/') }} - needs: - - build + publish-to-pypi: + name: Publish to PyPI + # if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + uses: ./.github/workflows/build.yml runs-on: ubuntu-latest environment: - name: testpypi - url: https://test.pypi.org/p/elastic + name: pypi + url: https://pypi.org/p/elastic permissions: id-token: write # IMPORTANT: mandatory for trusted publishing @@ -69,7 +28,5 @@ jobs: name: python-package-distributions path: dist/ - - name: Publish distribution to TestPyPI + - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ diff --git a/.github/workflows/testpypi.yml b/.github/workflows/testpypi.yml index 22d577f..f0b813d 100644 --- a/.github/workflows/testpypi.yml +++ b/.github/workflows/testpypi.yml @@ -13,7 +13,7 @@ jobs: # if: ${{ github.event_name == 'push' && ( github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/master' ) }} # Run on untagged push # if: ${{ !startsWith(github.ref, 'refs/tags/') }} - if: ${{ github.ref == 'refs/heads/dev' }} + # if: ${{ github.ref == 'refs/heads/dev' }} uses: ./.github/workflows/build.yml runs-on: ubuntu-latest @@ -37,102 +37,4 @@ jobs: repository-url: https://test.pypi.org/legacy/ - publish-to-pypi: - name: Publish to PyPI - if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes - needs: - - build - runs-on: ubuntu-latest - - environment: - name: pypi - url: https://pypi.org/p/elastic - - permissions: - id-token: write # IMPORTANT: mandatory for trusted publishing - - steps: - - name: Download all the dists - uses: actions/download-artifact@main - with: - name: python-package-distributions - path: dist/ - - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - - -name: Build, test and publish to (test)PyPI -on: - push: - branches: - - dev - -jobs: - build: - name: Build distribution - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@main - with: - fetch-depth: 0 - - - name: Set up Python - uses: actions/setup-python@main - with: - python-version: "3.x" - - - name: Install pypa/build - run: >- - python3 -m - pip install - build - --user - - - name: Build a binary wheel and a source tarball - run: python3 -m build - - - name: Test - run: | - python3 -m pip install hypothesis - python3 -m pip install dist/elastic*.whl - elastic --version - python3 -m unittest discover -s test -b - elastic -v --cij proc tests/data/calc-cij_*/vasprun.xml - elastic -v --eos proc tests/data/calc-eos_*/vasprun.xml - - - name: Store the distribution packages - uses: actions/upload-artifact@main - with: - name: python-package-distributions - path: dist/ - - publish-to-testpypi: - name: Publish to TestPyPI - # Only on dev pushes - # if: ${{ github.event_name == 'push' && ( github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/master' ) }} - # Run on tagged push - if: ${{ startsWith(github.ref, 'refs/tags/') }} - needs: - - build - runs-on: ubuntu-latest - - environment: - name: testpypi - url: https://test.pypi.org/p/elastic - - permissions: - id-token: write # IMPORTANT: mandatory for trusted publishing - - steps: - - name: Download all the dists - uses: actions/download-artifact@main - with: - name: python-package-distributions - path: dist/ - - - name: Publish distribution to TestPyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ + \ No newline at end of file From 88e125843c569189297a92985de74eec626a3307 Mon Sep 17 00:00:00 2001 From: "P.T. Jochym" Date: Sat, 7 Dec 2024 18:39:49 +0100 Subject: [PATCH 8/9] Separate job for build --- .github/workflows/pypi.yml | 6 +++++- .github/workflows/testpypi.yml | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 08f9d68..64e7285 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -8,10 +8,14 @@ on: - main jobs: + build: + uses: ./.github/workflows/build.yml + publish-to-pypi: name: Publish to PyPI # if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes - uses: ./.github/workflows/build.yml + needs: + - build runs-on: ubuntu-latest environment: diff --git a/.github/workflows/testpypi.yml b/.github/workflows/testpypi.yml index f0b813d..a514ed0 100644 --- a/.github/workflows/testpypi.yml +++ b/.github/workflows/testpypi.yml @@ -7,6 +7,9 @@ on: - dev jobs: + build: + uses: ./.github/workflows/build.yml + publish-to-testpypi: name: Publish to TestPyPI # Only on dev pushes @@ -14,7 +17,8 @@ jobs: # Run on untagged push # if: ${{ !startsWith(github.ref, 'refs/tags/') }} # if: ${{ github.ref == 'refs/heads/dev' }} - uses: ./.github/workflows/build.yml + needs: + - build runs-on: ubuntu-latest environment: From 1c2d3040e98071cfe8342b64f28f9b8b57cb1928 Mon Sep 17 00:00:00 2001 From: "P.T. Jochym" Date: Sat, 7 Dec 2024 19:01:28 +0100 Subject: [PATCH 9/9] Move checking for tags into job --- .github/workflows/pypi.yml | 4 +--- .github/workflows/testpypi.yml | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 64e7285..6c2af51 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -1,8 +1,6 @@ name: Build, test and publish to (test)PyPI on: push: - tags: - - 'v*' # matches semantic versioning (e.g., v1.2.3) branches: - master - main @@ -13,7 +11,7 @@ jobs: publish-to-pypi: name: Publish to PyPI - # if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes needs: - build runs-on: ubuntu-latest diff --git a/.github/workflows/testpypi.yml b/.github/workflows/testpypi.yml index a514ed0..09632f6 100644 --- a/.github/workflows/testpypi.yml +++ b/.github/workflows/testpypi.yml @@ -1,10 +1,9 @@ name: Build, test and publish to testPyPI on: push: - tags: - - 'v*' # matches semantic versioning (e.g., v1.2.3) branches: - dev + - hotfix jobs: build: @@ -15,8 +14,7 @@ jobs: # Only on dev pushes # if: ${{ github.event_name == 'push' && ( github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/master' ) }} # Run on untagged push - # if: ${{ !startsWith(github.ref, 'refs/tags/') }} - # if: ${{ github.ref == 'refs/heads/dev' }} + if: startsWith(github.ref, 'refs/tags/') needs: - build runs-on: ubuntu-latest