ci: skip redundant build #8
Workflow file for this run
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: Build | |
| on: | |
| push: | |
| tags: | |
| - 'v[0-9]*.[0-9]*.[0-9]*' | |
| workflow_dispatch: | |
| inputs: | |
| force: | |
| description: 'Force rebuild even if a successful build already exists for this SHA' | |
| type: boolean | |
| default: false | |
| jobs: | |
| check: | |
| name: Check for existing build | |
| runs-on: ubuntu-latest | |
| outputs: | |
| already_built: ${{ steps.check.outputs.already_built }} | |
| steps: | |
| - name: Check for successful build run at this SHA | |
| id: check | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| COUNT=$(gh api "/repos/${{ github.repository }}/actions/runs?head_sha=${{ github.sha }}&status=success" \ | |
| --jq '[.workflow_runs[] | select(.name == "Build")] | length') | |
| if [[ "${COUNT}" -gt 0 && "${{ inputs.force }}" != 'true' ]]; then | |
| echo "Found existing successful Build run for ${{ github.sha }}, skipping." | |
| echo "already_built=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "already_built=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| build: | |
| name: ${{ matrix.os.name }} | |
| needs: check | |
| if: needs.check.outputs.already_built != 'true' | |
| runs-on: ${{ matrix.os.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - name: Linux (x64) | |
| runner: ubuntu-latest | |
| artifact: uvscem-linux-x64 | |
| bin: uvscem-linux-x64 | |
| - name: Linux (arm64) | |
| runner: ubuntu-24.04-arm | |
| artifact: uvscem-linux-arm64 | |
| bin: uvscem-linux-arm64 | |
| - name: macOS (arm64) | |
| runner: macos-latest | |
| artifact: uvscem-macos-arm64 | |
| bin: uvscem-macos-arm64 | |
| - name: Windows (x64) | |
| runner: windows-latest | |
| artifact: uvscem-windows-x64 | |
| bin: uvscem-windows-x64.exe | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Wait for tests to pass | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: bash scripts/wait-for-workflow.sh "Test" "${{ github.sha }}" "${{ github.repository }}" | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: "3.10" | |
| - name: Install runtime dependencies | |
| run: pip install . | |
| - name: Build binary | |
| uses: Nuitka/Nuitka-Action@b24f9b7859f1022afcfad039eb8b8ac3ae299e39 # v1.3 | |
| with: | |
| script-name: src/uvscem/__main__.py | |
| output-file: ${{ matrix.os.artifact }} | |
| mode: onefile | |
| include-package: uvscem | |
| - name: Smoke test binary | |
| shell: bash | |
| run: | | |
| bin="build/${{ matrix.os.bin }}" | |
| chmod +x "$bin" 2>/dev/null || true | |
| # --help should succeed | |
| "$bin" --help | |
| # missing config/bundle should fail cleanly (exit 1, no traceback) | |
| ! "$bin" install --config-name __no_such_file__.json | |
| ! "$bin" export --config-name __no_such_file__.json | |
| ! "$bin" import --bundle-path __no_such_bundle__ | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: ${{ matrix.os.artifact }} | |
| path: build/${{ matrix.os.bin }} | |
| if-no-files-found: error |