From 3c57b609cef562a89f15477cdeebbbb3e3689679 Mon Sep 17 00:00:00 2001 From: Philip Loche Date: Thu, 5 Dec 2024 07:47:59 +0100 Subject: [PATCH] Add CI for doing a release (#113) --- .github/workflows/build-release.yml | 38 +++++++++++++++++++++++++++++ .github/workflows/build.yml | 26 -------------------- .github/workflows/docs.yml | 22 ++++++----------- .github/workflows/lint.yml | 2 -- .github/workflows/tests.yml | 6 ----- 5 files changed, 45 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/build-release.yml delete mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml new file mode 100644 index 00000000..3bb7cfd8 --- /dev/null +++ b/.github/workflows/build-release.yml @@ -0,0 +1,38 @@ +name: Build and Release + +on: + push: + branches: [main] + pull_request: + # Check all PR + +jobs: + build: + name: Build distribution + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/torch-pme + permissions: + id-token: write + + steps: + - uses: actions/checkout@v4 + - name: setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + - run: python -m pip install tox + - name: Build package + run: tox -e build + - name: Publish distribution to PyPI + if: startsWith(github.ref, 'refs/tags/v') + uses: pypa/gh-action-pypi-publish@release/v1 + - name: Publish to GitHub release + if: startsWith(github.ref, 'refs/tags/v') + uses: softprops/action-gh-release@v2 + with: + files: | + dist/*.tar.gz + dist/*.whl + prerelease: ${{ contains(github.ref, '-rc') }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 608be0e8..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,26 +0,0 @@ -# This workflow builds and checks the package for release -name: Build - -on: - pull_request: - branches: [main] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Set up Python - if: ${{ false }} - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - run: pip install tox - - - name: Test build integrity - if: ${{ false }} - run: tox -e build - env: - # Use the CPU only version of torch when building/running the code - PIP_EXTRA_INDEX_URL: https://download.pytorch.org/whl/cpu diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 31822bdc..2c0da4a3 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -16,17 +16,11 @@ jobs: uses: actions/setup-python@v5 with: python-version: "3.12" - - name: install dependencies run: | python -m pip install tox - - name: build documentation run: tox -e docs - env: - # Use the CPU only version of torch when building/running the code - PIP_EXTRA_INDEX_URL: https://download.pytorch.org/whl/cpu - - name: put documentation in the website run: | git clone https://oauth2:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY --branch gh-pages gh-pages @@ -41,12 +35,10 @@ jobs: rm -rf latest mv ../docs/build/html latest fi - - # TODO: enable once repo is public - # - name: deploy to gh-pages - # if: github.event_name == 'push' - # uses: peaceiris/actions-gh-pages@v4 - # with: - # github_token: ${{ secrets.GITHUB_TOKEN }} - # publish_dir: ./gh-pages/ - # force_orphan: true + - name: deploy to gh-pages + if: github.event_name == 'push' + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./gh-pages/ + force_orphan: true diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 53a22c58..b91b518b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,12 +10,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.12" - run: pip install tox - - name: Lint the code run: tox -e lint diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1f57f9b0..ef478bb8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,22 +23,16 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - run: pip install tox coverage[toml] - - name: run Python tests run: | tox -e tests-min tox -e tests coverage xml - env: - # Use the CPU only version of torch when building/running the code - PIP_EXTRA_INDEX_URL: https://download.pytorch.org/whl/cpu - - name: upload to codecov.io uses: codecov/codecov-action@v4 with: