build: add README #5
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 | |
| on: | |
| push: | |
| pull_request: | |
| # release: | |
| # types: [released] | |
| workflow_dispatch: | |
| env: | |
| DEFAULT_PYTHON: "3.12" | |
| jobs: | |
| build: | |
| name: 🔨 Build distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: 🏗 Set up Python ${{ env.DEFAULT_PYTHON }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "${{ env.DEFAULT_PYTHON }}" | |
| - name: 🔨 Build distribution | |
| uses: OctoPrint/actions/build-dist@main | |
| with: | |
| artifact: dist | |
| pre-commit: | |
| name: 🧹 Pre-commit | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: 🏗 Set up Python ${{ env.DEFAULT_PYTHON }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "${{ env.DEFAULT_PYTHON }}" | |
| - name: 🏗 Set up dev dependencies | |
| run: | | |
| pip install -e .[develop] | |
| - name: 🚀 Run pre-commit | |
| run: | | |
| pre-commit run --all-files --show-diff-on-failure | |
| test-unit: | |
| name: 🧪 Unit tests | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: 🏗 Set up Python ${{ matrix.python }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: 🏗 Set up test dependencies | |
| run: | | |
| pip install -e .[develop] | |
| - name: 🚀 Run test suite | |
| run: | | |
| pytest | tee report.txt | |
| # generate summary | |
| python=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:3])))') | |
| today=$(date +'%Y-%m-%d') | |
| now=$(date +'%H:%M') | |
| summary=$(tail -n1 report.txt | sed 's/^=*\s//g' | sed 's/\s=*$//g') | |
| cat << EOF >> $GITHUB_STEP_SUMMARY | |
| ### Test Report | |
| *generated on $today at $now under Python $python* | |
| <details> | |
| <summary>$summary</summary> | |
| \`\`\` | |
| $(cat report.txt) | |
| \`\`\` | |
| </details> | |
| EOF | |
| test-install: | |
| name: 🧪 Installation test | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: 🏗 Set up Python ${{ matrix.python }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: 🚀 Run test install | |
| run: | | |
| pip install -e . | |
| publish-on-testpypi: | |
| name: 📦 Publish on TestPyPI | |
| if: github.event_name == 'release' | |
| needs: | |
| - build | |
| - pre-commit | |
| - test-install | |
| - test-unit | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: testpypi | |
| url: https://test.pypi.org/p/gcode-thumbnail-tool | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: ⬇ Download build result | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist | |
| - name: 🧹 Remove some stuff that won't make it through twine check | |
| run: | | |
| rm dist/*.source.tar.gz | |
| rm dist/sha512sums.txt | |
| - name: 📦 Publish to index | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| publish-on-pypi: | |
| name: 📦 Publish tagged releases to PyPI | |
| if: github.event_name == 'release' | |
| needs: publish-on-testpypi | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/gcode-thumbnail-tool | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: ⬇ Download build result | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist | |
| - name: 🧹 Remove some stuff that won't make it through twine check | |
| run: | | |
| rm dist/*.source.tar.gz | |
| rm dist/sha512sums.txt | |
| - name: 📦 Publish to index | |
| uses: pypa/gh-action-pypi-publish@release/v1 |