From fe26b645268a155f6cd4274a7194c07af34fc1ba Mon Sep 17 00:00:00 2001 From: RobertoChiosa Date: Fri, 14 Jun 2024 14:54:35 +0200 Subject: [PATCH] refactor(app) added workflows --- .github/workflows/publish-docs.yaml | 46 +++-- .github/workflows/python-publish-testpypi.yml | 160 ------------------ .github/workflows/python-pypi.yml | 88 ++++++++++ .github/workflows/python-testpypi.yml | 90 ++++++++++ 4 files changed, 197 insertions(+), 187 deletions(-) delete mode 100644 .github/workflows/python-publish-testpypi.yml create mode 100644 .github/workflows/python-pypi.yml create mode 100644 .github/workflows/python-testpypi.yml diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml index ef56dc8..2e5bfff 100644 --- a/.github/workflows/publish-docs.yaml +++ b/.github/workflows/publish-docs.yaml @@ -1,9 +1,8 @@ -name: πŸ“•Deploy docs to GitHub Pages +name: "πŸ“•Deploy docs to GitHub Pages" on: push: - branches: - - main + branches: [ main,dev ] workflow_dispatch: jobs: @@ -11,28 +10,21 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest] - python-version: [3.9] + os: [ ubuntu-latest ] + python-version: [ 3.9 ] steps: - - uses: actions/checkout@v2 - - # Install dependencies - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install -r requirements.txt - - # Build the book - - name: Build the book - run: | - jupyter-book build docs - - # Deploy the book's HTML to gh-pages branch - - name: GitHub Pages action - uses: peaceiris/actions-gh-pages@v3.6.1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: docs/_build/html \ No newline at end of file + - name: "Check out repository" + uses: actions/checkout@v2 + - name: "Set up Python ${{ matrix.python-version }}" + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: "Install dependencies" + run: pip install -r requirements.txt + - name: "Build the book" + run: jupyter-book build docs + - name: "GitHub Pages action" + uses: peaceiris/actions-gh-pages@v3.6.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: docs/_build/html \ No newline at end of file diff --git a/.github/workflows/python-publish-testpypi.yml b/.github/workflows/python-publish-testpypi.yml deleted file mode 100644 index da313d2..0000000 --- a/.github/workflows/python-publish-testpypi.yml +++ /dev/null @@ -1,160 +0,0 @@ -name: Publish Python 🐍 distribution πŸ“¦ to PyPI and TestPyPI - -on: - # release: - # types: [ published ] - # push: - # branches: [ main ] - workflow_dispatch: - -jobs: - build: - name: Build distribution πŸ“¦ - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 - 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: Store the distribution packages - uses: actions/upload-artifact@v3 - with: - name: python-package-distributions - path: dist/ - - # publish-to-pypi: - # name: >- - # Publish Python 🐍 distribution πŸ“¦ 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/ # Replace with your PyPI project name - # permissions: - # id-token: write # IMPORTANT: mandatory for trusted publishing - # - # steps: - # - name: Download all the dists - # uses: actions/download-artifact@v3 - # with: - # name: python-package-distributions - # path: dist/ - # - name: Publish distribution πŸ“¦ to PyPI - # uses: pypa/gh-action-pypi-publish@release/v1 - - # github-release: - # name: >- - # Sign the Python 🐍 distribution πŸ“¦ with Sigstore - # and upload them to GitHub Release - # needs: - # - publish-to-pypi - # runs-on: ubuntu-latest - # - # permissions: - # contents: write # IMPORTANT: mandatory for making GitHub Releases - # id-token: write # IMPORTANT: mandatory for sigstore - # - # steps: - # - name: Download all the dists - # uses: actions/download-artifact@v3 - # with: - # name: python-package-distributions - # path: dist/ - # - name: Sign the dists with Sigstore - # uses: sigstore/gh-action-sigstore-python@v1.2.3 - # with: - # inputs: >- - # ./dist/*.tar.gz - # ./dist/*.whl - # - name: Create GitHub Release - # env: - # GITHUB_TOKEN: ${{ github.token }} - # run: >- - # gh release create - # '${{ github.ref_name }}' - # --repo '${{ github.repository }}' - # --notes "" - # - name: Upload artifact signatures to GitHub Release - # env: - # GITHUB_TOKEN: ${{ github.token }} - # # Upload to GitHub Release using the `gh` CLI. - # # `dist/` contains the built packages, and the - # # sigstore-produced signatures and certificates. - # run: >- - # gh release upload - # '${{ github.ref_name }}' dist/** - # --repo '${{ github.repository }}' - - publish-to-testpypi: - name: Publish Python 🐍 distribution πŸ“¦ to TestPyPI - needs: - - build - runs-on: ubuntu-latest - - environment: - name: testpypi - url: https://test.pypi.org/p/portable-app-framework - - permissions: - id-token: write # IMPORTANT: mandatory for trusted publishing - - steps: - - name: Download all the dists - uses: actions/download-artifact@v3 - 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/ - user: __token__ - password: ${{ secrets.TESTPYPI_API_TOKEN }} - -#name: Publish to TestPyPI.org -#on: -# # release: -# # types: [ published ] -# # push: -# # branches: [ main ] -# workflow_dispatch: -# -#permissions: -# contents: read -# -#jobs: -# pypi: -# runs-on: ubuntu-latest -# steps: -# - name: Checkout -# uses: actions/checkout@v3 -# - name: Set up Python -# uses: actions/setup-python@v3 -# with: -# python-version: '3.x' -# - name: Install dependencies -# run: | -# python -m pip install --upgrade pip -# pip install build -# - name: Build package -# run: python -m build -# - name: Publish distribution to TestPyPI -# uses: pypa/gh-action-pypi-publish@release/v1 -# with: -# repository-url: https://test.pypi.org/legacy/ -# user: __token__ -# password: ${{ secrets.TESTPYPI_API_TOKEN }} -# diff --git a/.github/workflows/python-pypi.yml b/.github/workflows/python-pypi.yml new file mode 100644 index 0000000..622669b --- /dev/null +++ b/.github/workflows/python-pypi.yml @@ -0,0 +1,88 @@ +name: "Publish Python 🐍 distribution πŸ“¦ to PyPI" + +on: + push: + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + workflow_dispatch: + +jobs: + build: + name: "Build distribution πŸ“¦" + runs-on: ubuntu-latest + steps: + - name: "Checkout" + uses: actions/checkout@v4 + - name: "Set up Python" + uses: actions/setup-python@v4 + 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: "Store the distribution packages" + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + name: "Publish Python 🐍 distribution πŸ“¦ 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/project/PFB-Toolkit/ + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + steps: + - name: "Download all the dists" + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: "Publish distribution πŸ“¦ to PyPI" + uses: pypa/gh-action-pypi-publish@release/v1 + + github-release: + name: "Sign the Python 🐍 distribution πŸ“¦ with Sigstore and upload them to GitHub Release" + needs: + - publish-to-pypi + runs-on: ubuntu-latest + permissions: + contents: write # IMPORTANT: mandatory for making GitHub Releases + id-token: write # IMPORTANT: mandatory for sigstore + steps: + - name: "Download all the dists" + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: "Sign the dists with Sigstore" + uses: sigstore/gh-action-sigstore-python@v1.2.3 + with: + inputs: >- + ./dist/*.tar.gz + ./dist/*.whl + - name: "Create GitHub Release" + env: + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release create + '${{ github.ref_name }}' + --repo '${{ github.repository }}' + --notes "" + - name: "Upload artifact signatures to GitHub Release" + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. + # `dist/` contains the built packages, and the + # sigstore-produced signatures and certificates. + run: >- + gh release upload + '${{ github.ref_name }}' dist/** + --repo '${{ github.repository }}' + diff --git a/.github/workflows/python-testpypi.yml b/.github/workflows/python-testpypi.yml new file mode 100644 index 0000000..8e670ce --- /dev/null +++ b/.github/workflows/python-testpypi.yml @@ -0,0 +1,90 @@ +name: "Publish Python 🐍 distribution πŸ“¦ to TestPyPI" + +on: + push: + tags: + - '*-dev' # Push events to matching *-dev, i.e. v1.0-dev, v20.15.10-dev + workflow_dispatch: + +jobs: + build: + name: "Build distribution πŸ“¦" + runs-on: ubuntu-latest + steps: + - name: "Checkout" + uses: actions/checkout@v4 + - name: "Set up Python" + uses: actions/setup-python@v4 + 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: "Store the distribution packages" + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + publish-to-testpypi: + name: "Publish Python 🐍 distribution πŸ“¦ to TestPyPI" + needs: + - build + runs-on: ubuntu-latest + environment: + name: testpypi + url: https://test.pypi.org/project/PFB-Toolkit/ + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + steps: + - name: "Download all the dists" + uses: actions/download-artifact@v3 + 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/ + user: __token__ + password: ${{ secrets.TESTPYPI_API_TOKEN }} + + github-release: + name: "Sign the Python 🐍 distribution πŸ“¦ with Sigstore and upload them to GitHub Release" + needs: + - publish-to-pypi + runs-on: ubuntu-latest + permissions: + contents: write # IMPORTANT: mandatory for making GitHub Releases + id-token: write # IMPORTANT: mandatory for sigstore + steps: + - name: "Download all the dists" + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: "Sign the dists with Sigstore" + uses: sigstore/gh-action-sigstore-python@v1.2.3 + with: + inputs: >- + ./dist/*.tar.gz + ./dist/*.whl + - name: "Create GitHub Release" + env: + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release create + '${{ github.ref_name }}' + --repo '${{ github.repository }}' + --notes "" + - name: "Upload artifact signatures to GitHub Release" + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. + # `dist/` contains the built packages, and the + # sigstore-produced signatures and certificates. + run: >- + gh release upload + '${{ github.ref_name }}' dist/** + --repo '${{ github.repository }}'