Update GitHub Action Versions #680
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
| # Infos on current github runners: | |
| # https://docs.github.com/en/free-pro-team@latest/actions/reference/specifications-for-github-hosted-runners#about-github-hosted-runners | |
| name: CI/CD | |
| on: | |
| pull_request: | |
| push: | |
| branches: ["main"] | |
| tags: ["v*"] | |
| workflow_dispatch: | |
| inputs: | |
| refToBuild: | |
| description: "Branch, tag or commit SHA1 to build" | |
| required: true | |
| type: string | |
| concurrency: | |
| group: cicd-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test: | |
| name: Lint & Test | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [macos-14, macos-15, windows-2022, windows-2025, ubuntu-22.04, ubuntu-24.04] | |
| steps: | |
| # Setup environment | |
| - uses: actions/checkout@v6.0.2 | |
| if: ${{ github.event_name != 'workflow_dispatch' }} | |
| - uses: actions/checkout@v6.0.2 | |
| if: ${{ github.event_name == 'workflow_dispatch' }} | |
| with: | |
| ref: ${{ inputs.refToBuild }} | |
| - uses: ./.github/actions/setup-python-uv | |
| - name: Prepare Linux | |
| if: startsWith(matrix.os, 'ubuntu') | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install \ | |
| python3-pil \ | |
| tesseract-ocr \ | |
| tesseract-ocr-eng \ | |
| tesseract-ocr-jpn \ | |
| tesseract-ocr-chi-sim \ | |
| xclip | |
| sudo apt-get install \ | |
| xvfb \ | |
| libxkbcommon-x11-0 \ | |
| libxcb-icccm4 \ | |
| libxcb-image0 \ | |
| libxcb-keysyms1 \ | |
| libxcb-randr0 \ | |
| libxcb-render-util0 \ | |
| libxcb-xinerama0 \ | |
| libxcb-xfixes0 \ | |
| libxcb-shape0 \ | |
| libxcb-cursor0 \ | |
| libegl1 \ | |
| libegl1-mesa-dev | |
| sudo apt-get install \ | |
| ca-certificates | |
| echo "XDG_SESSION_TYPE=gnome" >> $GITHUB_ENV | |
| echo "QT_DEBUG_PLUGINS=1" >> $GITHUB_ENV | |
| echo "QT_QPA_PLATFORM=xcb" >> $GITHUB_ENV | |
| - name: Prepare macOS | |
| if: startsWith(matrix.os, 'macos') | |
| run: | | |
| brew install tesseract tesseract-lang dylibbundler | |
| brew info tesseract | |
| - name: Prepare Windows | |
| if: startsWith(matrix.os, 'windows') | |
| run: | | |
| $url = "https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-w64-setup-5.4.0.20240606.exe" | |
| Invoke-WebRequest -Uri $url -OutFile "tesseract_installer.exe" | |
| 7z x tesseract_installer.exe -O"C:\Program Files\Tesseract-OCR" | |
| $chi_sim_url = "https://github.com/tesseract-ocr/tessdata_fast/raw/main/chi_sim.traineddata" | |
| Invoke-WebRequest -Uri $chi_sim_url -OutFile "C:\Program Files\Tesseract-OCR\tessdata\chi_sim.traineddata" | |
| $jpn_url = "https://github.com/tesseract-ocr/tessdata_fast/raw/main/jpn.traineddata" | |
| Invoke-WebRequest -Uri $jpn_url -OutFile "C:\Program Files\Tesseract-OCR\tessdata\jpn.traineddata" | |
| $tesseract = "C:\Program Files\Tesseract-OCR\" | |
| echo "$tesseract" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| echo "TESSDATA_PREFIX=$tesseract\tessdata" >> $env:GITHUB_ENV | |
| Set-DisplayResolution -Width 1920 -Height 1080 -Force | |
| - name: Test tesseract | |
| run: | | |
| tesseract --version | |
| tesseract --list-langs | |
| - name: Run project checks | |
| run: | | |
| uv run poe cicd-check | |
| env: | |
| QT_DEBUG_PLUGINS: 1 | |
| - name: Coveralls Parallel | |
| if: github.repository_owner == 'dynobo' | |
| uses: coverallsapp/github-action@v2.3.6 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| flag-name: ${{ matrix.os }} | |
| path-to-lcov: coverage.lcov | |
| parallel: true | |
| test-python-package: | |
| name: Test Python package build | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [macos-14, macos-15, windows-2025, ubuntu-24.04] | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| - uses: ./.github/actions/setup-python-uv | |
| - name: Test build python package | |
| run: uv build | |
| test-flatpak: | |
| name: Test flatpak build | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| - uses: actions/setup-python@v6.2.0 | |
| with: | |
| python-version: "3.13" | |
| - name: Install flatpak | |
| run: | | |
| sudo apt update && sudo apt install -y flatpak flatpak-builder | |
| flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo | |
| - name: Clone git clone | |
| run: | | |
| git clone https://github.com/flathub/com.github.dynobo.normcap.git | |
| - name: Run build script | |
| run: | | |
| cd com.github.dynobo.normcap | |
| python update.py --keep --bundle ${{ github.head_ref || github.ref_name }} | |
| - name: Draft internal release | |
| uses: ./.github/actions/draft-internal-release | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| test-briefcase: | |
| name: Test Briefcase build | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [macos-14, macos-15, windows-2025, ubuntu-24.04] | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| - uses: ./.github/actions/setup-python-uv | |
| - name: Test build briefcase package | |
| shell: bash -l {0} | |
| run: uv run poe bundle-dev | |
| - name: Print briefcase log in case of error | |
| if: failure() | |
| shell: bash -l {0} | |
| run: | | |
| (cat logs/briefcase*) || true | |
| find build/normcap || true | |
| - name: Draft internal release | |
| uses: ./.github/actions/draft-internal-release | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| test-documentation: | |
| name: Test documentation build | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| - uses: ./.github/actions/setup-python-uv | |
| - name: Build documentation | |
| run: uv run poe docs-build | |
| coveralls: | |
| name: Upload coverage | |
| needs: test | |
| if: github.repository_owner == 'dynobo' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| - name: Coveralls Finished | |
| uses: coverallsapp/github-action@v2.3.6 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| parallel-finished: true | |
| codeql: | |
| name: CodeQL | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| actions: read | |
| contents: read | |
| security-events: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| language: ["python"] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6.0.2 | |
| - name: Initialize CodeQL | |
| uses: github/codeql-action/init@v4.32.4 | |
| with: | |
| languages: ${{ matrix.language }} | |
| queries: security-extended | |
| - name: Autobuild | |
| uses: github/codeql-action/autobuild@v4.32.4 | |
| - name: Perform CodeQL Analysis | |
| uses: github/codeql-action/analyze@v4.32.4 | |
| deploy-briefcase: | |
| name: Briefcase build & draft release | |
| needs: | |
| - test | |
| - test-briefcase | |
| - test-flatpak | |
| - test-python-package | |
| if: | | |
| startsWith(github.ref, 'refs/tags/v') | |
| && github.repository_owner == 'dynobo' | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [macos-14, macos-15, windows-2025, ubuntu-24.04] | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| - uses: ./.github/actions/setup-python-uv | |
| - name: Build package briefcase | |
| shell: bash -l {0} | |
| run: uv run poe bundle | |
| - name: Draft release | |
| if: github.repository == 'dynobo/normcap' | |
| uses: ncipollo/release-action@v1.20.0 | |
| with: | |
| body: | |
| See [CHANGELOG](https://github.com/dynobo/normcap/blob/main/CHANGELOG) for | |
| details. | |
| artifacts: "*/*.+(dmg|AppImage|msi|zip)" | |
| artifactErrorsFailBuild: false | |
| allowUpdates: true | |
| draft: true | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: FTP upload windows package | |
| if: startsWith(matrix.os, 'windows') && github.repository == 'dynobo/normcap' | |
| uses: SamKirkland/FTP-Deploy-Action@v4.3.6 | |
| with: | |
| server: ${{ secrets.WEBGO_FTP_HOST }} | |
| username: ${{ secrets.WEBGO_FTP_USER }} | |
| password: ${{ secrets.WEBGO_FTP_PASS }} | |
| protocol: ftps | |
| local-dir: ./bundle/ | |
| exclude: | | |
| **/platforms/** | |
| **/imgs/** | |
| **/*.py | |
| **/*.wxs | |
| **/*.wxs | |
| **/metainfo | |
| deploy-pypi: | |
| name: Publish to PyPi | |
| needs: deploy-briefcase | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| # Used to authenticate to PyPI via OIDC. | |
| # Used to sign the release's artifacts with sigstore-python. | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| - uses: ./.github/actions/setup-python-uv | |
| - name: Build Python package | |
| run: uv build | |
| - name: Publish to PyPi | |
| uses: pypa/gh-action-pypi-publish@v1.13.0 | |
| with: | |
| verbose: true | |
| print-hash: true | |
| release-documentation: | |
| name: Deploy github pages | |
| needs: | |
| - test | |
| - test-documentation | |
| if: | | |
| (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') | |
| && github.repository_owner == 'dynobo' | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| - uses: ./.github/actions/setup-python-uv | |
| - name: Build documentation | |
| run: uv run poe docs-build | |
| - name: Deploy pages | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./site |