CI/CD Pipeline #46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD Pipeline | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*' | |
| - 'v*.*.rc*' | |
| schedule: | |
| # <minute [0,59]> <hour [0,23]> <day of the month [1,31]> <month of the year [1,12]> <day of the week [0,6]> | |
| # https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07 | |
| # Run every Monday at 18:00:00 UTC (Monday at 10:00:00 PST) | |
| - cron: '0 18 * * 1' | |
| jobs: | |
| # test: ## RUNNING OUT OF DISK SPACE WHEN INSTALLING ON RUNNER | |
| # name: Test ${{ matrix.os }} with py${{ matrix.python-version }} | |
| # runs-on: ${{ matrix.os }} | |
| # strategy: | |
| # matrix: | |
| # os: [ubuntu-latest, windows-latest] | |
| # python-version: ['3.10'] | |
| # steps: | |
| # - name: Checkout code | |
| # uses: actions/checkout@v4 | |
| # - name: Set up Python ${{ matrix.python-version }} | |
| # uses: actions/setup-python@v5 | |
| # with: | |
| # python-version: ${{ matrix.python-version }} | |
| # - name: Cleanup before installation | |
| # if: runner.os == 'Linux' | |
| # run: | | |
| # sudo rm -rf /tmp/* /var/tmp/* # Clear temporary files | |
| # sudo apt-get clean # Clean apt cache | |
| # - name: Install dependencies | |
| # run: | | |
| # python -m pip install --upgrade pip | |
| # pip install .[test] --no-cache-dir | |
| # - name: Test with tox | |
| # uses: aganders3/headless-gui@v2 | |
| # with: | |
| # run: python -m tox | |
| # env: | |
| # PLATFORM: ${{ matrix.os }} | |
| # - name: Upload codecov | |
| # uses: codecov/codecov-action@v5 | |
| # lint-flake8: | |
| # name: Lint with flake8 | |
| # runs-on: ubuntu-latest | |
| # steps: | |
| # - name: Checkout code | |
| # uses: actions/checkout@v4 | |
| # - name: Set up Python | |
| # uses: actions/setup-python@v5 | |
| # with: | |
| # python-version: "3.10" | |
| # - name: Install dependencies | |
| # run: | | |
| # python -m pip install --upgrade pip | |
| # pip install .[test] | |
| # - name: Lint with flake8 | |
| # run: | | |
| # flake8 leonardo_toolset --count --verbose --show-source --statistics | |
| lint-black: | |
| name: Check with black | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10" | |
| - name: Install black | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install black | |
| - name: Check with black | |
| run: | | |
| black --check leonardo_toolset | |
| build: | |
| name: Build distribution | |
| needs: [lint-black] # lint-flake8, tests removed temporarily. need to fix issues first | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10" | |
| - name: Install pypa/build | |
| run: | | |
| python -m pip install build --user | |
| - name: Build a binary wheel and a source tarball | |
| run: | | |
| python -m build | |
| - name: Store the distribution packages | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| publish-to-pypi: | |
| name: Publish to PyPI | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/leonardo-toolset/ | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v4 | |
| 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: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| env: | |
| PYPI_ENVIRONMENT: pypi | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Sign the Python distribution with Sigstore | |
| uses: sigstore/gh-action-sigstore-python@v3.0.0 | |
| with: | |
| inputs: | | |
| ./dist/*.tar.gz | |
| ./dist/*.whl | |
| - name: Create a 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 }} | |
| run: >- | |
| gh release upload | |
| '${{ github.ref_name }}' dist/** | |
| --repo '${{ github.repository }}' |