name: Appium iOS Automated Release on: push: branches: - main # Manual/recovery runs live in this file too: npm's trusted publisher (OIDC) matches the # top-level workflow file, so a reusable-workflow wrapper can't publish. workflow_dispatch: inputs: dry_run: description: 'Dry run (no publishing or tagging)' required: true type: boolean default: true recover_missing_only: description: 'Recovery mode: skip version bump, publish only packages missing on npm at their current package.json version' required: true type: boolean default: false permissions: contents: write pull-requests: write issues: write id-token: write # to enable use of OIDC for trusted publishing and npm provenance # Avoid two releases racing each other; queue rather than cancel a publish in progress. concurrency: group: release cancel-in-progress: false jobs: # Figures out which packages this run will publish, so the expensive native prebuilds and the # release job itself only run when needed. detect-packages: # Manual runs are limited to maintainers on main; everything downstream needs this job. if: ${{ github.event_name != 'workflow_dispatch' || (github.ref == 'refs/heads/main' && contains(fromJSON('["mykola-mokhnach", "jlipps", "eglitise", "KazuCocoa"]'), github.actor)) }} runs-on: ubuntu-latest outputs: any: ${{ steps.detect.outputs.any }} tuntap: ${{ steps.detect.outputs.tuntap }} coresim: ${{ steps.detect.outputs.coresim }} media-proxy: ${{ steps.detect.outputs.media-proxy }} steps: - name: Checkout repository uses: actions/checkout@v7 with: fetch-depth: 0 # full history + tags, for `lerna changed` - name: Setup Node and install deps (no build) uses: ./.github/actions/setup-build with: node-version: lts/* # Scoped to skip packages/tuntap's native (node-gyp) install - lerna only needs # package.json/git metadata. install-command: npm ci --workspace=packages/xcode --workspace=packages/uicatalog --include-workspace-root run-build: 'false' - name: Detect packages to release id: detect env: RECOVER_MISSING_ONLY: ${{ inputs.recover_missing_only || false }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # `gh release view` for asset-less releases run: node scripts/detect-release-packages.mjs # Build tuntap's native addon for every platform only when tuntap itself is being published - # publishing it via lerna without this would ship a package with no prebuilds. prebuild-tuntap: needs: detect-packages if: ${{ needs.detect-packages.outputs.tuntap == 'true' }} uses: ./.github/workflows/tuntap-prebuild.yml with: upload-artifacts: true # Same for coresim's native addon: only built when coresim itself is being published. prebuild-coresim: needs: detect-packages if: ${{ needs.detect-packages.outputs.coresim == 'true' }} uses: ./.github/workflows/coresim-prebuild.yml with: upload-artifacts: true # Same for media-proxy's native addon (with its bundled FFmpeg libs). prebuild-media-proxy: needs: detect-packages if: ${{ needs.detect-packages.outputs.media-proxy == 'true' }} uses: ./.github/workflows/media-proxy-prebuild.yml with: upload-artifacts: true # Prebuilds can take long enough for main to move on. `lerna publish` then fails with EBEHIND, # so a push-triggered run that is no longer at the head of main bows out; the queued run for # the newer commit re-detects and releases everything this one would have. check-head: needs: - detect-packages - prebuild-tuntap - prebuild-coresim - prebuild-media-proxy if: ${{ !cancelled() && !failure() && needs.detect-packages.outputs.any == 'true' }} runs-on: ubuntu-latest outputs: stale: ${{ steps.head.outputs.stale }} steps: - name: Compare with the current head of main id: head env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} EVENT_NAME: ${{ github.event_name }} run: | stale=false if [ "$EVENT_NAME" = "push" ]; then head_sha="$(gh api "repos/${GITHUB_REPOSITORY}/commits/main" --jq .sha)" if [ "$head_sha" != "$GITHUB_SHA" ]; then stale=true echo "::notice::main moved to ${head_sha} since ${GITHUB_SHA}; skipping, the run for the newer commit will release" fi fi echo "stale=${stale}" >> "$GITHUB_OUTPUT" release: needs: - detect-packages - check-head if: ${{ !cancelled() && !failure() && needs.check-head.outputs.stale != 'true' && needs.detect-packages.outputs.any == 'true' }} runs-on: ubuntu-latest outputs: # "@" (lerna's independent-mode tag format) if ios-uicatalog was # published this run, empty otherwise - see the lerna-release action. uicatalog_release_tag: ${{ steps.run-lerna-publish.outputs.uicatalog_release_tag }} # Same for appium-webdriveragent, whose prebuilt runner archives get attached to its release. webdriveragent_release_tag: ${{ steps.run-lerna-publish.outputs.webdriveragent_release_tag }} steps: - name: Checkout repository uses: actions/checkout@v7 with: fetch-depth: 0 - name: Configure git user run: | git config user.name "github-actions" git config user.email "github-actions@github.com" - name: Download tuntap prebuild artifacts if: ${{ needs.detect-packages.outputs.tuntap == 'true' }} uses: actions/download-artifact@v8 with: pattern: tuntap-prebuild-* path: tuntap-prebuild-staging - name: Merge tuntap prebuilds if: ${{ needs.detect-packages.outputs.tuntap == 'true' }} run: | mkdir -p packages/tuntap/prebuilds for dir in tuntap-prebuild-staging/tuntap-prebuild-*/; do cp -R "${dir}"* packages/tuntap/prebuilds/ done find packages/tuntap/prebuilds -type f -name '*.node' | sort - name: Download coresim prebuild artifact if: ${{ needs.detect-packages.outputs.coresim == 'true' }} uses: actions/download-artifact@v8 with: name: coresim-prebuild-darwin-arm64 path: packages/coresim/prebuilds - name: Download media-proxy prebuild artifacts if: ${{ needs.detect-packages.outputs.media-proxy == 'true' }} uses: actions/download-artifact@v8 with: pattern: media-proxy-prebuild-* path: media-proxy-prebuild-staging - name: Merge media-proxy prebuilds if: ${{ needs.detect-packages.outputs.media-proxy == 'true' }} run: | mkdir -p packages/media-proxy/prebuilds for dir in media-proxy-prebuild-staging/media-proxy-prebuild-*/; do cp -R "${dir}"* packages/media-proxy/prebuilds/ done find packages/media-proxy/prebuilds -type f | sort - name: Setup Node and install deps (LTS) uses: ./.github/actions/setup-build with: node-version: lts/* # Full install, unscoped. When tuntap is released its prebuilds are already in place # above, so its node-gyp-build install hook is a cheap no-op; otherwise the hook would # compile it, which is wasted time since it isn't published - hence --ignore-scripts # unless a prebuild was downloaded. coresim's install script no-ops on this # (non-macOS) runner regardless. install-command: ${{ needs.detect-packages.outputs.tuntap == 'true' && 'npm ci' || 'npm ci --ignore-scripts' }} run-build: 'true' - name: Run Lerna publish id: run-lerna-publish uses: ./.github/actions/lerna-release with: github-token: ${{ secrets.GITHUB_TOKEN }} dry_run: ${{ inputs.dry_run || false }} recover_missing_only: ${{ inputs.recover_missing_only || false }} release-uicatalog-app: name: Build and upload UIKitCatalog app needs: release # Native prebuilds may be skipped upstream; override the implicit success() check. if: ${{ !cancelled() && !failure() && needs.release.result == 'success' && needs.release.outputs.uicatalog_release_tag != '' }} uses: ./.github/workflows/uicatalog-build-app.yml with: upload_release_artifacts: true release_tag: ${{ needs.release.outputs.uicatalog_release_tag }} checkout_ref: ${{ needs.release.outputs.uicatalog_release_tag }} release-webdriveragent-assets: name: Build and upload WebDriverAgent archives needs: release # Native prebuilds may be skipped upstream; override the implicit success() check. if: ${{ !cancelled() && !failure() && needs.release.result == 'success' && needs.release.outputs.webdriveragent_release_tag != '' }} uses: ./.github/workflows/webdriveragent-build-assets.yml with: release_tag: ${{ needs.release.outputs.webdriveragent_release_tag }} checkout_ref: ${{ needs.release.outputs.webdriveragent_release_tag }}