diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c252b9d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,44 @@ +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/pypi.yml b/.github/workflows/pypi.yml index 66ee5bf..6c2af51 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -1,89 +1,19 @@ name: Build, test and publish to (test)PyPI on: push: - tags: - - 'v*' # matches semantic versioning (e.g., v1.2.3) branches: - - main - master - - dev + - 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 untagged push - # if: ${{ !startsWith(github.ref, 'refs/tags/') }} - if: ${{ github.ref == 'refs/heads/dev' }} - 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/ - + 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 needs: - - build + - build runs-on: ubuntu-latest environment: diff --git a/.github/workflows/testpypi.yml b/.github/workflows/testpypi.yml new file mode 100644 index 0000000..09632f6 --- /dev/null +++ b/.github/workflows/testpypi.yml @@ -0,0 +1,42 @@ +name: Build, test and publish to testPyPI +on: + push: + branches: + - dev + - hotfix + +jobs: + build: + uses: ./.github/workflows/build.yml + + 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/') + 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 diff --git a/setup.py b/setup.py index e5a4c75..0ff0ae5 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,5 @@ def current_version(version: ScmVersion) -> str: return version.format_next_version(guess_next_version, "{tag}"+ delim +"{distance}") - setup(use_scm_version={"version_scheme": current_version, "local_scheme": get_no_local_node}) -