diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 59f1ad7a..7b826502 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,8 +1,14 @@ -name: pytest +name: Testing on: + push: + branches: + - main + tags: + - "v*" pull_request: - branches: [main] + branches: + - main jobs: build: diff --git a/.github/workflows/pytest-docs.yml b/.github/workflows/pytest-docs.yml index a26ebfaa..290e0232 100644 --- a/.github/workflows/pytest-docs.yml +++ b/.github/workflows/pytest-docs.yml @@ -1,6 +1,14 @@ -name: Tests +name: Build Docs -on: [release, workflow_dispatch] +on: + push: + branches: + - main + tags: + - "v*" + pull_request: + branches: + - main jobs: build: @@ -20,18 +28,20 @@ jobs: cache: 'pip' cache-dependency-path: '**/pyproject.toml' - name: Install webdriver - run: sudo apt-get update && sudo apt-get install firefox-geckodriver + run: sudo apt-get update && sudo apt-get install chromium-chromedriver - name: Install dependencies run: | python${{ matrix.python-version }} -m pip install --upgrade pip packaging wheel python${{ matrix.python-version }} -m pip install `grep numpy== requirements/ubuntu-latest_py${{ matrix.python-version }}_extras.txt` python${{ matrix.python-version }} -m pip install -r requirements/ubuntu-latest_py${{ matrix.python-version }}_extras.txt + python${{ matrix.python-version }} -m pip install --upgrade pip python${{ matrix.python-version }} -m pip install --no-deps . - name: Build new docs run: | cd docs_rst make html - name: Detect changes + if: contains(github.ref, 'refs/heads/main') id: changes shell: bash run: | @@ -45,7 +55,3 @@ jobs: git add -A git commit -m "Automated doc build" git push - - name: pytest - env: - PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} - run: pytest --color=yes --webdriver Firefox --headless crystal_toolkit/apps/examples/tests/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6446b174..31782afd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,11 @@ name: Release -on: workflow_dispatch +on: + release: + types: [published] + +permissions: + contents: read jobs: deploy: @@ -21,32 +26,6 @@ jobs: cache: "pip" cache-dependency-path: '**/pyproject.toml' - - name: bump version and create tag - env: - DATE_FORMAT: "%Y.%m.%d" - run: | - NEXT_RELEASE=$(date "+${DATE_FORMAT}") - LAST_RELEASE=$(git tag --sort=v:refname | grep "^20[^\-]*$" | tail -n 1) - echo "Last release : ${LAST_RELEASE}" - MAJOR_LAST_RELEASE=$(echo "${LAST_RELEASE}" | awk -v l=${#NEXT_RELEASE} '{ string=substr($0, 1, l); print string; }') - echo "Last major release : ${MAJOR_LAST_RELEASE}" - if [ "${MAJOR_LAST_RELEASE}" = "${NEXT_RELEASE}" ]; then - MINOR_LAST_RELEASE="$(echo "${LAST_RELEASE}" | awk -v l=$((${#NEXT_RELEASE} + 2)) '{ string=substr($0, l); print string; }')" - NEXT_RELEASE=${MAJOR_LAST_RELEASE}.$((MINOR_LAST_RELEASE + 1)) - fi - echo "Next release: ${NEXT_RELEASE}" - git config --local user.email "github-actions@github.com" - git config --local user.name "github-actions" - python -m pip install --upgrade pip - python -m pip install --user --upgrade pip build setuptools "setuptools_scm<8" wheel - SETUPTOOLS_SCM_PRETEND_VERSION=${NEXT_RELEASE} python -m setuptools_scm - git add crystal_toolkit/_version.py - git commit -m "version bump: ${NEXT_RELEASE}" - git push - git tag ${NEXT_RELEASE} - git push --tags - echo "NEXT_RELEASE=${NEXT_RELEASE}" >> $GITHUB_ENV - - name: Install dependencies run: | python -m pip install --upgrade pip @@ -56,9 +35,10 @@ jobs: python -m pip install --no-deps .[server] - name: Build package - run: SETUPTOOLS_SCM_PRETEND_VERSION=${{env.NEXT_RELEASE}} python -m build + run: pip install build - name: Publish package + if: contains(github.ref, 'refs/heads/main') uses: pypa/gh-action-pypi-publish@release/v1.5 with: user: __token__ diff --git a/crystal_toolkit/_version.py b/crystal_toolkit/_version.py deleted file mode 100644 index 7c075029..00000000 --- a/crystal_toolkit/_version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "2023.11.4.dev18" \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index bff09b6c..9c6c1423 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -128,3 +128,7 @@ ignore-words-list = "nd,te,ois" [tool.mypy] no_implicit_optional = false + +[tool.versioningit.vcs] +default-tag = "0.0.1" +method = "git"