obelisk 0.41.5

Deterministic workflow engine
name: release-1-validate

permissions:
  attestations: write
  contents: write
  id-token: write

on:
  workflow_dispatch:
    inputs:
      ref:
        description: "The ref (branch or SHA) to process"
        required: false
        type: string
        default: "latest"
      validate_nix_dev_build:
        description: "Validate the Nix dev build"
        required: true
        type: boolean
        default: true
      dry_run:
        description: "Run cargo publish with --dry-run (requires stop_after_step_2)"
        required: true
        type: boolean
        default: false
      stop_after_step_2:
        description: "Stop after cargo publish"
        required: true
        type: boolean
        default: false
      update_latest:
        description: "Update the Docker Hub latest tag (ignored when stopping after step 2)"
        required: true
        type: boolean
        default: true

defaults:
  run:
    shell: bash -xe {0}

jobs:
  validate:
    runs-on: ubuntu-24.04
    steps:
      - name: Validate inputs
        if: ${{ inputs.dry_run && !inputs.stop_after_step_2 }}
        run: |
          echo "::error::dry_run requires stop_after_step_2"
          exit 1

      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
        with:
          ref: ${{ inputs.ref }}

      - name: Validate latest webui bump commit
        env:
          EXPECTED_PREFIX: "chore: Bump obelisk submodule to webui"
          WEBUI_REPO_URL: "https://github.com/obeli-sk/webui.git"
          WEBUI_BRANCH: "main"
        run: |
          git init webui-tmp
          cd webui-tmp
          git remote add origin "$WEBUI_REPO_URL"
          git fetch --depth=1 origin "$WEBUI_BRANCH"
          COMMIT_SUBJECT="$(git log -1 --pretty=%s FETCH_HEAD)"
          echo "Latest webui commit subject: $COMMIT_SUBJECT"
          if [[ "$COMMIT_SUBJECT" != "$EXPECTED_PREFIX"* ]]; then
            echo "::error::Latest commit in obeli-sk/webui does not start with '$EXPECTED_PREFIX'."
            exit 1
          fi

      - name: Validate activity JS runtime version reference
        run: |
          ./scripts/prerelease-check-runtime-version.sh \
            crates/activity-js-runtime \
            crates/embedded-assets/activity-js-runtime-version.txt

      - name: Validate workflow JS runtime version reference
        run: |
          ./scripts/prerelease-check-runtime-version.sh \
            crates/workflow-js-runtime \
            crates/embedded-assets/workflow-js-runtime-version.txt

      - name: Validate webhook JS runtime version reference
        run: |
          ./scripts/prerelease-check-runtime-version.sh \
            crates/webhook-js-runtime \
            crates/embedded-assets/webhook-js-runtime-version.txt

      - uses: cachix/install-nix-action@13d8dd58da0234aa297dedd986986ccb8e7f3e24 # v31.11.1
        if: ${{ inputs.validate_nix_dev_build }}

      - name: Validate Nix dev build
        run: nix build .#obeliskLibcNixDev
        if: ${{ inputs.validate_nix_dev_build }}

  call_child:
    needs: validate
    uses: ./.github/workflows/release-2-cargo-publish.yml
    secrets: inherit
    with:
      ref: ${{ inputs.ref }}
      dry_run: ${{ inputs.dry_run }}
      stop_after_step_2: ${{ inputs.stop_after_step_2 }}
      update_latest: ${{ inputs.update_latest }}