diff --git a/.github/workflows/build-doc.yml b/.github/workflows/build-doc.yml new file mode 100644 index 00000000..335bd7dc --- /dev/null +++ b/.github/workflows/build-doc.yml @@ -0,0 +1,38 @@ +# Build RidePy docs +name: docs + +on: + push: + workflow_call: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Checkout submodules + run: git submodule update --init --recursive + - name: Setup Pages + uses: actions/configure-pages@v3 + - name: Set up Python 3.9 + uses: actions/setup-python@v4 + with: + python-version: '3.9' + - name: Cache python environment + uses: actions/cache@v3 + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ hashFiles('pyproject.toml') }} + - name: Install system dependencies using apt + run: | + sudo apt-get update && sudo apt-get -y install libboost-all-dev build-essential + - name: Install Dependencies + run: | + pip install -U pip + pip install .[doc] + - name: Build doc + run: sphinx-build -b html ./doc/ ./_site + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 diff --git a/.github/workflows/build-pypi-sdist.yml b/.github/workflows/build-sdist.yml similarity index 62% rename from .github/workflows/build-pypi-sdist.yml rename to .github/workflows/build-sdist.yml index 658e8209..381e09b1 100644 --- a/.github/workflows/build-pypi-sdist.yml +++ b/.github/workflows/build-sdist.yml @@ -1,16 +1,11 @@ name: sdist on: - push: - branches: - - package_staging - release: - types: [published] + workflow_call: jobs: - build_deploy: + build: runs-on: ubuntu-latest - environment: pypi steps: - name: Checkout repository and submodules uses: actions/checkout@v3 @@ -36,16 +31,5 @@ jobs: run: python -m build --sdist - uses: actions/upload-artifact@v3 with: - name: Source package + name: sdist path: dist/*.tar.gz - - name: Publish to TestPyPI - env: - TWINE_USERNAME: ${{ secrets.TESTPYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.TESTPYPI_PASSWORD }} - run: twine upload -r testpypi dist/*.tar.gz - - name: Publish to PyPI - if: ${{ github.ref == 'refs/heads/master' }} - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: twine upload dist/*.tar.gz diff --git a/.github/workflows/build-pypi-wheel.yml b/.github/workflows/build-wheel.yml similarity index 64% rename from .github/workflows/build-pypi-wheel.yml rename to .github/workflows/build-wheel.yml index 97acbaed..9c658c2a 100644 --- a/.github/workflows/build-pypi-wheel.yml +++ b/.github/workflows/build-wheel.yml @@ -1,16 +1,11 @@ name: wheel on: - push: - branches: - - package_staging - release: - types: [published] + workflow_call: jobs: - build_deploy: + build: runs-on: ubuntu-latest - environment: pypi steps: - name: Checkout repository and submodules uses: actions/checkout@v3 @@ -40,16 +35,5 @@ jobs: # pip-wheel-args: '-w ./dist --no-deps' - uses: actions/upload-artifact@v3 with: - name: Manylinux wheels + name: wheel-manylinux path: dist/*-manylinux*.whl - - name: Publish sdist to TestPyPI - env: - TWINE_USERNAME: ${{ secrets.TESTPYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.TESTPYPI_PASSWORD }} - run: twine upload -r testpypi dist/*-manylinux*.whl - - name: Publish to PyPI - if: ${{ github.ref == 'refs/heads/master' }} - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: twine upload -r testpypi dist/*-manylinux*.whl diff --git a/.github/workflows/deploy-doc.yml b/.github/workflows/deploy-doc.yml new file mode 100644 index 00000000..f1ec6862 --- /dev/null +++ b/.github/workflows/deploy-doc.yml @@ -0,0 +1,32 @@ +# Deploy ridepy docs to GitHub Pages +name: deploy-docs + +on: + workflow_call: + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + build-doc: + uses: ./.github/workflows/build-doc.yml + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build-doc + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 diff --git a/.github/workflows/deploy-pypi.yml b/.github/workflows/deploy-pypi.yml new file mode 100644 index 00000000..f893706a --- /dev/null +++ b/.github/workflows/deploy-pypi.yml @@ -0,0 +1,40 @@ +name: pypi + +on: + release: + types: [published] + +concurrency: + group: "pypi" + cancel-in-progress: false + +jobs: + sdist: + uses: ./.github/workflows/build-sdist.yml + wheel: + uses: ./.github/workflows/build-wheel.yml + test: + uses: ./.github/workflows/python-testing.yml + deploy-doc: + uses: ./.github/workflows/deploy-doc.yml + deploy: + runs-on: ubuntu-latest + environment: pypi + needs: [sdist, wheel, test, deploy-doc] + steps: + - uses: actions/download-artifact@v3 + with: + name: sdist + path: dist + - uses: actions/download-artifact@v3 + with: + name: wheel-manylinux + path: dist + - name: Show what is being published + run: ls -lah + working-directory: dist + - name: Publish package to PyPI + if: startsWith(github.ref, 'refs/tags/v') # just to be safe + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/deploy-testpypi.yml b/.github/workflows/deploy-testpypi.yml new file mode 100644 index 00000000..82ed0455 --- /dev/null +++ b/.github/workflows/deploy-testpypi.yml @@ -0,0 +1,42 @@ +name: testpypi + +on: + push: + branches: + - master + - package_staging + +concurrency: + group: "testpypi" + cancel-in-progress: false + +jobs: + sdist: + uses: ./.github/workflows/build-sdist.yml + wheel: + uses: ./.github/workflows/build-wheel.yml + test: + uses: ./.github/workflows/python-testing.yml + doc: + uses: ./.github/workflows/build-doc.yml + deploy: + runs-on: ubuntu-latest + environment: pypi + needs: [sdist, wheel, test, doc] + steps: + - uses: actions/download-artifact@v3 + with: + name: sdist + path: dist + - uses: actions/download-artifact@v3 + with: + name: wheel-manylinux + path: dist + - name: Show what is being published + run: ls -lah + working-directory: dist + - name: Publish package to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository-url: https://test.pypi.org/legacy/ \ No newline at end of file diff --git a/.github/workflows/docs-gh-pages.yml b/.github/workflows/docs-gh-pages.yml deleted file mode 100644 index 47f1d7e5..00000000 --- a/.github/workflows/docs-gh-pages.yml +++ /dev/null @@ -1,69 +0,0 @@ -# Build RidePy doc and deploy to GitHub Pages -name: docs - -on: - # Runs on pushes targeting the default branch - push: - branches: - - master - release: - types: [published] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. -concurrency: - group: "pages" - cancel-in-progress: false - -jobs: - # Build job - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Checkout submodules - run: git submodule update --init --recursive - - name: Setup Pages - uses: actions/configure-pages@v3 - - name: Set up Python 3.9 - uses: actions/setup-python@v4 - with: - python-version: '3.9' - - name: Cache python environment - uses: actions/cache@v3 - with: - path: ${{ env.pythonLocation }} - key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ hashFiles('pyproject.toml') }} - - name: Install system dependencies using apt - run: | - sudo apt-get update && sudo apt-get -y install libboost-all-dev build-essential - - name: Install Dependencies - run: | - pip install -U pip - pip install .[doc] - - name: Build doc - run: sphinx-build -b html ./doc/ ./_site - - name: Upload artifact - uses: actions/upload-pages-artifact@v1 - - # Deployment job - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v2 diff --git a/.github/workflows/python-testing.yml b/.github/workflows/python-testing.yml index 1867b38f..44043a6d 100644 --- a/.github/workflows/python-testing.yml +++ b/.github/workflows/python-testing.yml @@ -4,7 +4,10 @@ name: tests -on: [push, pull_request] +on: + push: + pull_request: + workflow_call: jobs: test: