name: Webex Connect Deploy run-name: ${{ github.triggering_actor }} is releasing @webex/webexconnect v${{ inputs.version }} # Publishes @webex/webexconnect as a GitHub Release in # webex/webexconnect-javascript-sdk. The release carries a single dist.zip asset # (the built SDK files + manifest.json). This is NOT an npm publish and it is # independent of the shared deploy.yml, which keeps excluding @webex/webexconnect. on: workflow_dispatch: inputs: version: description: 'Release version as major.minor.patch(e.g., x.x.x). Must match the first three parts of JS_SDK_VERSION in src/IMIClient.js.' required: true type: string release_notes: description: 'Release notes (used as the GitHub Release body)' required: true type: string # A single stable key, so two concurrent runs can't both pass the # already-released check below and then race on tag creation. concurrency: group: webexconnect-deploy cancel-in-progress: false env: DIST_REPO: webex/webexconnect-javascript-sdk jobs: release: name: Build & Release @webex/webexconnect runs-on: ubuntu-latest steps: # Releasing to the public distribution repo is gated behind membership of # the cypher-sdk-release-team, so the team is the single source of truth # and no usernames are hardcoded. ORG_READ_TOKEN carries the org # "Members: read" permission needed to query it. # # This lives in the publishing job and reads github.triggering_actor (the # person who started *this* attempt) rather than github.actor (frozen as # the original requester). A separate authorize job could be skipped by # re-running only the failed release job, so the gate must be re-evaluated # here on every attempt. - name: Check actor is on the release team env: GH_TOKEN: ${{ secrets.ORG_READ_TOKEN }} ACTOR: ${{ github.triggering_actor }} ORG: webex TEAM_SLUG: cypher-sdk-release-team run: | # 200 + state "active" = current member, 200 + "pending" = invited only, # 404 = not a member. Only an active membership authorizes a run. STATE=$(gh api \ "orgs/$ORG/teams/$TEAM_SLUG/memberships/$ACTOR" \ --jq '.state' 2>/dev/null) || STATE="" if [ "$STATE" != "active" ]; then echo "::error::Actor '$ACTOR' is not an active member of @$ORG/$TEAM_SLUG and is not authorized to release @webex/webexconnect." exit 1 fi echo "Actor '$ACTOR' is an active member of @$ORG/$TEAM_SLUG; authorized." - name: Validate Version Format env: VERSION: ${{ inputs.version }} run: | if ! grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' <<< "$VERSION"; then echo "::error::Version '$VERSION' is not valid. Expected a 3-part version x.y.z (e.g., 1.9.0)." exit 1 fi # Releases are immutable, so a published version can't be re-released with # different content. Check upfront rather than let the build run and have # `gh release create` reject the duplicate tag at the last step. - name: Check release does not already exist env: GH_TOKEN: ${{ secrets.WXCONN_GITHUB_TOKEN }} VERSION: ${{ inputs.version }} run: | if gh release view "v$VERSION" --repo "$DIST_REPO" >/dev/null 2>&1; then echo "::error::v$VERSION is already released in $DIST_REPO. Releases are immutable — bump JS_SDK_VERSION and release the next version instead." exit 1 fi echo "v$VERSION is not yet released in $DIST_REPO." - name: Checkout Project uses: actions/checkout@v6 - name: Setup Node uses: actions/setup-node@v6 with: node-version-file: '.nvmrc' cache: 'yarn' - name: Install Dependencies run: yarn # workflow_dispatch lets the caller pick any ref, and nothing guarantees PR # checks ran on it, so the released commit is gated on its own tests here. - name: Test package run: yarn workspace @webex/webexconnect run test - name: Build package run: yarn workspace @webex/webexconnect run build:src # A release must not ship a bundle reporting a version other than its tag. # The tag is always 3-part (v1.9.0) while JS_SDK_VERSION may carry a 4th # build segment (1.9.1.001), so compare only the first three parts. - name: Verify version matches JS_SDK_VERSION env: VERSION: ${{ inputs.version }} run: | SDK_VERSION=$(sed -nE 's/^const JS_SDK_VERSION = "([^"]+)";.*/\1/p' packages/webexconnect/src/IMIClient.js) if [ -z "$SDK_VERSION" ]; then echo "::error::Could not read JS_SDK_VERSION from packages/webexconnect/src/IMIClient.js" exit 1 fi SDK_BASE=$(cut -d. -f1-3 <<< "$SDK_VERSION") if [ "$SDK_BASE" != "$VERSION" ]; then echo "::error::Requested version '$VERSION' does not match JS_SDK_VERSION '$SDK_VERSION' (expected base $SDK_BASE)." exit 1 fi echo "Version '$VERSION' matches JS_SDK_VERSION '$SDK_VERSION'." # dist.zip layout is flat (no folders) and matches the existing releases: # the two minified bundles + manifest.json. Source maps are not shipped. - name: Package dist.zip run: | mkdir -p release cp packages/webexconnect/dist/webex-connect-sdk.min.js release/ cp packages/webexconnect/dist/sw.min.js release/ cp docs/samples/webexconnect/assets/manifest/manifest.json release/ (cd release && zip -j ../dist.zip webex-connect-sdk.min.js sw.min.js manifest.json) unzip -l dist.zip # WXCONN_GITHUB_TOKEN carries contents:write on the distribution repo. # # --target main tags the distribution repo, so the tag says nothing about # which SDK commit produced dist.zip. The notes carry the source commit and # the run that built it so every asset is traceable back to both. - name: Create GitHub Release env: GH_TOKEN: ${{ secrets.WXCONN_GITHUB_TOKEN }} VERSION: ${{ inputs.version }} RELEASE_NOTES: ${{ inputs.release_notes }} SOURCE_REPO_URL: ${{ github.server_url }}/${{ github.repository }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} run: | SOURCE_SHA=$(git rev-parse HEAD) printf '%s\n\n---\n\nSource commit: %s/commit/%s\nWorkflow run: %s\n' \ "$RELEASE_NOTES" \ "$SOURCE_REPO_URL" "$SOURCE_SHA" \ "$RUN_URL" > release-notes.md gh release create "v$VERSION" dist.zip \ --repo "$DIST_REPO" \ --target main \ --title "$VERSION" \ --notes-file release-notes.md