You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "jason810496 (via GitHub)" <gi...@apache.org> on 2026/08/19 15:13:45 UTC

[PR] Publish TypeScript SDK with trusted credentials [airflow]

jason810496 opened a new pull request, #71843:
URL: https://github.com/apache/airflow/pull/71843

   ## Why
   
   Publishing the TypeScript SDK with a long-lived npm token would expose a reusable credential and would not establish verifiable build provenance.
   
   ## How
   
   - Require a manually dispatched, semver-matching `ts-sdk/<version>` tag.
   - Require approval through the protected `ts-sdk-npm` GitHub environment.
   - Publish from a GitHub-hosted runner through npm trusted publishing and OIDC.
   - Publish prereleases under `next` and stable versions under `latest`.
   - Configure public scoped-package access and document the required npm trusted-publisher setup.
   
   The actual publish step requires the `apache/airflow` GitHub environment and npm trusted-publisher configuration described in the documentation.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [x] Yes, with help of Codex GPT-5 following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Publish TypeScript SDK with trusted credentials [airflow]

Posted by "phanikumv (via GitHub)" <gi...@apache.org>.
phanikumv commented on code in PR #71843:
URL: https://github.com/apache/airflow/pull/71843#discussion_r3859972810


##########
ts-sdk/scripts/validate-release-inputs.mjs:
##########
@@ -0,0 +1,152 @@
+#!/usr/bin/env node
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import console from "node:console";
+import { appendFileSync, readFileSync } from "node:fs";
+import process from "node:process";
+import { URL, pathToFileURL } from "node:url";
+
+const PACKAGE_NAME = JSON.parse(
+  readFileSync(new URL("../package.json", import.meta.url), "utf8"),
+).name;
+const SEMVER_PATTERN =
+  /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?$/;
+const NPM_TAG_PATTERN = /^[a-z][a-z0-9._-]*$/;
+
+function parseVersion(version) {
+  const match = SEMVER_PATTERN.exec(version);
+  if (match === null) {
+    throw new Error(`Release version ${JSON.stringify(version)} is not valid SemVer`);
+  }
+  return {
+    version,
+    major: BigInt(match[1]),
+    minor: BigInt(match[2]),
+    patch: BigInt(match[3]),
+    prerelease: match[4]?.split(".") ?? [],
+  };
+}
+
+function compareIdentifiers(left, right) {
+  if (left === right) {
+    return 0;
+  }
+  const leftIsNumeric = /^\d+$/.test(left);
+  const rightIsNumeric = /^\d+$/.test(right);
+  if (leftIsNumeric && rightIsNumeric) {
+    return BigInt(left) < BigInt(right) ? -1 : 1;
+  }
+  if (leftIsNumeric) {
+    return -1;
+  }
+  if (rightIsNumeric) {
+    return 1;
+  }
+  return left < right ? -1 : 1;
+}
+
+function compareVersions(left, right) {
+  for (const field of ["major", "minor", "patch"]) {
+    if (left[field] !== right[field]) {
+      return left[field] < right[field] ? -1 : 1;
+    }
+  }
+  if (left.prerelease.length === 0 || right.prerelease.length === 0) {
+    return right.prerelease.length - left.prerelease.length;
+  }
+  const length = Math.max(left.prerelease.length, right.prerelease.length);
+  for (let index = 0; index < length; index += 1) {
+    const leftIdentifier = left.prerelease[index];
+    const rightIdentifier = right.prerelease[index];
+    if (leftIdentifier === undefined) {
+      return -1;
+    }
+    if (rightIdentifier === undefined) {
+      return 1;
+    }
+    const difference = compareIdentifiers(leftIdentifier, rightIdentifier);
+    if (difference !== 0) {
+      return difference;
+    }
+  }
+  return 0;
+}
+
+function getPrereleaseChannel(prerelease) {
+  return prerelease[0]?.match(/^[A-Za-z]+/)?.[0].toLowerCase();
+}
+
+export function validateReleaseInputs({ releaseTag, npmTag, currentDistTagVersion = "" }) {
+  if (!releaseTag.startsWith("ts-sdk/")) {
+    throw new Error("Release tag must have the form ts-sdk/<semver>");
+  }
+  const version = releaseTag.slice("ts-sdk/".length);
+  const parsedVersion = parseVersion(version);
+
+  if (!NPM_TAG_PATTERN.test(npmTag)) {
+    throw new Error(`npm tag ${JSON.stringify(npmTag)} is invalid`);
+  }
+  if (parsedVersion.prerelease.length === 0 && npmTag !== "latest") {
+    throw new Error("Stable releases must use the latest npm dist-tag");
+  }
+  if (parsedVersion.prerelease.length > 0) {
+    const channel = getPrereleaseChannel(parsedVersion.prerelease);
+    if (npmTag !== "next" && npmTag !== channel) {
+      const allowedTags = channel === undefined ? "next" : `${channel} or next`;

Review Comment:
    ```suggestion
          const allowedTags = channel === undefined || channel === "next" ? "next" : `${channel} or next`;
     ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Publish TypeScript SDK with trusted credentials [airflow]

Posted by "phanikumv (via GitHub)" <gi...@apache.org>.
phanikumv commented on code in PR #71843:
URL: https://github.com/apache/airflow/pull/71843#discussion_r3859972810


##########
ts-sdk/scripts/validate-release-inputs.mjs:
##########
@@ -0,0 +1,152 @@
+#!/usr/bin/env node
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import console from "node:console";
+import { appendFileSync, readFileSync } from "node:fs";
+import process from "node:process";
+import { URL, pathToFileURL } from "node:url";
+
+const PACKAGE_NAME = JSON.parse(
+  readFileSync(new URL("../package.json", import.meta.url), "utf8"),
+).name;
+const SEMVER_PATTERN =
+  /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?$/;
+const NPM_TAG_PATTERN = /^[a-z][a-z0-9._-]*$/;
+
+function parseVersion(version) {
+  const match = SEMVER_PATTERN.exec(version);
+  if (match === null) {
+    throw new Error(`Release version ${JSON.stringify(version)} is not valid SemVer`);
+  }
+  return {
+    version,
+    major: BigInt(match[1]),
+    minor: BigInt(match[2]),
+    patch: BigInt(match[3]),
+    prerelease: match[4]?.split(".") ?? [],
+  };
+}
+
+function compareIdentifiers(left, right) {
+  if (left === right) {
+    return 0;
+  }
+  const leftIsNumeric = /^\d+$/.test(left);
+  const rightIsNumeric = /^\d+$/.test(right);
+  if (leftIsNumeric && rightIsNumeric) {
+    return BigInt(left) < BigInt(right) ? -1 : 1;
+  }
+  if (leftIsNumeric) {
+    return -1;
+  }
+  if (rightIsNumeric) {
+    return 1;
+  }
+  return left < right ? -1 : 1;
+}
+
+function compareVersions(left, right) {
+  for (const field of ["major", "minor", "patch"]) {
+    if (left[field] !== right[field]) {
+      return left[field] < right[field] ? -1 : 1;
+    }
+  }
+  if (left.prerelease.length === 0 || right.prerelease.length === 0) {
+    return right.prerelease.length - left.prerelease.length;
+  }
+  const length = Math.max(left.prerelease.length, right.prerelease.length);
+  for (let index = 0; index < length; index += 1) {
+    const leftIdentifier = left.prerelease[index];
+    const rightIdentifier = right.prerelease[index];
+    if (leftIdentifier === undefined) {
+      return -1;
+    }
+    if (rightIdentifier === undefined) {
+      return 1;
+    }
+    const difference = compareIdentifiers(leftIdentifier, rightIdentifier);
+    if (difference !== 0) {
+      return difference;
+    }
+  }
+  return 0;
+}
+
+function getPrereleaseChannel(prerelease) {
+  return prerelease[0]?.match(/^[A-Za-z]+/)?.[0].toLowerCase();
+}
+
+export function validateReleaseInputs({ releaseTag, npmTag, currentDistTagVersion = "" }) {
+  if (!releaseTag.startsWith("ts-sdk/")) {
+    throw new Error("Release tag must have the form ts-sdk/<semver>");
+  }
+  const version = releaseTag.slice("ts-sdk/".length);
+  const parsedVersion = parseVersion(version);
+
+  if (!NPM_TAG_PATTERN.test(npmTag)) {
+    throw new Error(`npm tag ${JSON.stringify(npmTag)} is invalid`);
+  }
+  if (parsedVersion.prerelease.length === 0 && npmTag !== "latest") {
+    throw new Error("Stable releases must use the latest npm dist-tag");
+  }
+  if (parsedVersion.prerelease.length > 0) {
+    const channel = getPrereleaseChannel(parsedVersion.prerelease);
+    if (npmTag !== "next" && npmTag !== channel) {
+      const allowedTags = channel === undefined ? "next" : `${channel} or next`;

Review Comment:
    ```suggestion
           const allowedTags = channel === undefined || channel === "next" ? "next" : `${channel} or next`;
     ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Publish TypeScript SDK with trusted credentials [airflow]

Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 merged PR #71843:
URL: https://github.com/apache/airflow/pull/71843


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Publish TypeScript SDK with trusted credentials [airflow]

Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on code in PR #71843:
URL: https://github.com/apache/airflow/pull/71843#discussion_r3860251372


##########
.github/workflows/ts-sdk-release.yml:
##########
@@ -0,0 +1,199 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+---
+name: Release TypeScript SDK
+
+on:  # yamllint disable-line rule:truthy
+  workflow_dispatch:
+    inputs:
+      release_type:
+        description: "Stage the package for review or publish it directly"
+        required: true
+        type: choice
+        options:
+          - staged
+          - formal
+      tag:
+        description: "TypeScript SDK release tag (ts-sdk/<version>)"
+        required: true
+        type: string
+      npm_tag:
+        description: "npm dist-tag (for example: beta or latest)"
+        required: true
+        type: string
+
+permissions:
+  contents: read
+
+concurrency:
+  group: ts-sdk-npm-release
+  cancel-in-progress: false
+
+jobs:
+  build:
+    name: Verify and package release
+    runs-on: ubuntu-latest
+    outputs:
+      artifact_name: ${{ steps.package.outputs.artifact_name }}
+      package_file: ${{ steps.release.outputs.package_file }}
+      sha256: ${{ steps.package.outputs.sha256 }}
+      version: ${{ steps.release.outputs.version }}
+    steps:
+      - name: Checkout dispatched release tag
+        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1  # v7.0.1
+        with:
+          fetch-depth: 0
+          persist-credentials: false
+      - name: Set up Node.js
+        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020  # v7.0.0
+        with:
+          node-version: "24.19.0"
+          registry-url: "https://registry.npmjs.org"
+          package-manager-cache: false
+      - name: Enable the pinned pnpm version
+        run: corepack enable
+      - name: Validate release inputs
+        id: release
+        working-directory: ts-sdk
+        env:
+          NPM_TAG: ${{ inputs.npm_tag }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: node scripts/validate-release-inputs.mjs
+      - name: Confirm dispatch and checkout use the release tag
+        env:
+          DISPATCH_REF: ${{ github.ref }}
+          DISPATCH_SHA: ${{ github.sha }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: |
+          set -euo pipefail
+          test "${DISPATCH_REF}" = "refs/tags/${RELEASE_TAG}"
+          test "${DISPATCH_SHA}" = "$(git rev-parse HEAD)"
+          test "$(git rev-parse "refs/tags/${RELEASE_TAG}^{commit}")" = "$(git rev-parse HEAD)"
+          git merge-base --is-ancestor HEAD "$(git rev-parse refs/remotes/origin/main)"
+      - name: Confirm release advances the npm dist-tag
+        working-directory: ts-sdk
+        env:
+          NPM_TAG: ${{ inputs.npm_tag }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: |
+          set -euo pipefail
+          error_file="${RUNNER_TEMP}/npm-view-error.log"
+          set +e
+          current_version="$(npm view apache-airflow-ts-sdk "dist-tags.${NPM_TAG}" 2>"${error_file}")"

Review Comment:
   Addressed in f50a748b.



##########
ts-sdk/README.md:
##########


Review Comment:
   Addressed in 955acd09.



##########
.github/workflows/ts-sdk-release.yml:
##########
@@ -0,0 +1,199 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+---
+name: Release TypeScript SDK
+
+on:  # yamllint disable-line rule:truthy
+  workflow_dispatch:
+    inputs:
+      release_type:
+        description: "Stage the package for review or publish it directly"
+        required: true
+        type: choice
+        options:
+          - staged
+          - formal
+      tag:
+        description: "TypeScript SDK release tag (ts-sdk/<version>)"
+        required: true
+        type: string
+      npm_tag:
+        description: "npm dist-tag (for example: beta or latest)"
+        required: true
+        type: string
+
+permissions:
+  contents: read
+
+concurrency:
+  group: ts-sdk-npm-release
+  cancel-in-progress: false
+
+jobs:
+  build:
+    name: Verify and package release
+    runs-on: ubuntu-latest
+    outputs:
+      artifact_name: ${{ steps.package.outputs.artifact_name }}
+      package_file: ${{ steps.release.outputs.package_file }}
+      sha256: ${{ steps.package.outputs.sha256 }}
+      version: ${{ steps.release.outputs.version }}
+    steps:
+      - name: Checkout dispatched release tag
+        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1  # v7.0.1
+        with:
+          fetch-depth: 0
+          persist-credentials: false
+      - name: Set up Node.js
+        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020  # v7.0.0
+        with:
+          node-version: "24.19.0"
+          registry-url: "https://registry.npmjs.org"
+          package-manager-cache: false
+      - name: Enable the pinned pnpm version
+        run: corepack enable
+      - name: Validate release inputs
+        id: release
+        working-directory: ts-sdk
+        env:
+          NPM_TAG: ${{ inputs.npm_tag }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: node scripts/validate-release-inputs.mjs
+      - name: Confirm dispatch and checkout use the release tag
+        env:
+          DISPATCH_REF: ${{ github.ref }}
+          DISPATCH_SHA: ${{ github.sha }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: |
+          set -euo pipefail
+          test "${DISPATCH_REF}" = "refs/tags/${RELEASE_TAG}"
+          test "${DISPATCH_SHA}" = "$(git rev-parse HEAD)"
+          test "$(git rev-parse "refs/tags/${RELEASE_TAG}^{commit}")" = "$(git rev-parse HEAD)"
+          git merge-base --is-ancestor HEAD "$(git rev-parse refs/remotes/origin/main)"
+      - name: Confirm release advances the npm dist-tag
+        working-directory: ts-sdk
+        env:
+          NPM_TAG: ${{ inputs.npm_tag }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: |
+          set -euo pipefail
+          error_file="${RUNNER_TEMP}/npm-view-error.log"
+          set +e
+          current_version="$(npm view apache-airflow-ts-sdk "dist-tags.${NPM_TAG}" 2>"${error_file}")"
+          view_status=$?
+          set -e
+          if [[ ${view_status} -ne 0 ]]; then
+            if grep -q "E404" "${error_file}"; then
+              current_version=""
+            else
+              cat "${error_file}" >&2
+              exit "${view_status}"
+            fi
+          fi
+          CURRENT_DIST_TAG_VERSION="${current_version}" node scripts/validate-release-inputs.mjs
+      - name: Verify package identity
+        working-directory: ts-sdk
+        env:
+          EXPECTED_VERSION: ${{ steps.release.outputs.version }}
+        run: |
+          set -euo pipefail
+          test "$(node --print "require('./package.json').name")" = "apache-airflow-ts-sdk"
+          test "$(node --print "require('./package.json').version")" = "${EXPECTED_VERSION}"
+      - name: Install and test package
+        working-directory: ts-sdk
+        run: |
+          set -euo pipefail
+          pnpm install --frozen-lockfile
+          pnpm run lint
+          pnpm run format:check
+          pnpm run typecheck
+          pnpm test
+      - name: Create package tarball
+        id: package
+        working-directory: ts-sdk
+        env:
+          PACKAGE_FILE: ${{ steps.release.outputs.package_file }}
+          VERSION: ${{ steps.release.outputs.version }}
+        run: |
+          set -euo pipefail
+          artifact_dir="${RUNNER_TEMP}/ts-sdk-package"
+          mkdir -p "${artifact_dir}"
+          test -z "$(find "${artifact_dir}" -mindepth 1 -maxdepth 1 -print -quit)"

Review Comment:
   Addressed in ce5e2cec.



##########
.github/workflows/ts-sdk-release.yml:
##########
@@ -0,0 +1,199 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+---
+name: Release TypeScript SDK
+
+on:  # yamllint disable-line rule:truthy
+  workflow_dispatch:
+    inputs:
+      release_type:
+        description: "Stage the package for review or publish it directly"
+        required: true
+        type: choice
+        options:
+          - staged
+          - formal
+      tag:
+        description: "TypeScript SDK release tag (ts-sdk/<version>)"
+        required: true
+        type: string
+      npm_tag:
+        description: "npm dist-tag (for example: beta or latest)"
+        required: true
+        type: string
+
+permissions:
+  contents: read
+
+concurrency:
+  group: ts-sdk-npm-release
+  cancel-in-progress: false
+
+jobs:
+  build:
+    name: Verify and package release
+    runs-on: ubuntu-latest
+    outputs:
+      artifact_name: ${{ steps.package.outputs.artifact_name }}
+      package_file: ${{ steps.release.outputs.package_file }}
+      sha256: ${{ steps.package.outputs.sha256 }}
+      version: ${{ steps.release.outputs.version }}
+    steps:
+      - name: Checkout dispatched release tag
+        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1  # v7.0.1
+        with:
+          fetch-depth: 0
+          persist-credentials: false
+      - name: Set up Node.js
+        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020  # v7.0.0
+        with:
+          node-version: "24.19.0"
+          registry-url: "https://registry.npmjs.org"
+          package-manager-cache: false
+      - name: Enable the pinned pnpm version
+        run: corepack enable
+      - name: Validate release inputs
+        id: release
+        working-directory: ts-sdk
+        env:
+          NPM_TAG: ${{ inputs.npm_tag }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: node scripts/validate-release-inputs.mjs
+      - name: Confirm dispatch and checkout use the release tag
+        env:
+          DISPATCH_REF: ${{ github.ref }}
+          DISPATCH_SHA: ${{ github.sha }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: |
+          set -euo pipefail
+          test "${DISPATCH_REF}" = "refs/tags/${RELEASE_TAG}"
+          test "${DISPATCH_SHA}" = "$(git rev-parse HEAD)"
+          test "$(git rev-parse "refs/tags/${RELEASE_TAG}^{commit}")" = "$(git rev-parse HEAD)"
+          git merge-base --is-ancestor HEAD "$(git rev-parse refs/remotes/origin/main)"
+      - name: Confirm release advances the npm dist-tag
+        working-directory: ts-sdk
+        env:
+          NPM_TAG: ${{ inputs.npm_tag }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: |
+          set -euo pipefail
+          error_file="${RUNNER_TEMP}/npm-view-error.log"
+          set +e
+          current_version="$(npm view apache-airflow-ts-sdk "dist-tags.${NPM_TAG}" 2>"${error_file}")"
+          view_status=$?
+          set -e
+          if [[ ${view_status} -ne 0 ]]; then
+            if grep -q "E404" "${error_file}"; then
+              current_version=""
+            else
+              cat "${error_file}" >&2
+              exit "${view_status}"
+            fi
+          fi
+          CURRENT_DIST_TAG_VERSION="${current_version}" node scripts/validate-release-inputs.mjs
+      - name: Verify package identity
+        working-directory: ts-sdk
+        env:
+          EXPECTED_VERSION: ${{ steps.release.outputs.version }}
+        run: |
+          set -euo pipefail
+          test "$(node --print "require('./package.json').name")" = "apache-airflow-ts-sdk"
+          test "$(node --print "require('./package.json').version")" = "${EXPECTED_VERSION}"
+      - name: Install and test package
+        working-directory: ts-sdk
+        run: |
+          set -euo pipefail
+          pnpm install --frozen-lockfile
+          pnpm run lint
+          pnpm run format:check
+          pnpm run typecheck
+          pnpm test
+      - name: Create package tarball
+        id: package
+        working-directory: ts-sdk
+        env:
+          PACKAGE_FILE: ${{ steps.release.outputs.package_file }}
+          VERSION: ${{ steps.release.outputs.version }}
+        run: |
+          set -euo pipefail
+          artifact_dir="${RUNNER_TEMP}/ts-sdk-package"
+          mkdir -p "${artifact_dir}"
+          test -z "$(find "${artifact_dir}" -mindepth 1 -maxdepth 1 -print -quit)"
+          npm pack --pack-destination "${artifact_dir}"
+          artifact_path="${artifact_dir}/${PACKAGE_FILE}"
+          test -f "${artifact_path}"
+          test "$(find "${artifact_dir}" -maxdepth 1 -type f -name '*.tgz' | wc -l)" -eq 1
+          echo "artifact_name=ts-sdk-package-${VERSION}" >> "${GITHUB_OUTPUT}"
+          echo "sha256=$(sha256sum "${artifact_path}" | awk '{print $1}')" >> "${GITHUB_OUTPUT}"
+      - name: Upload package tarball
+        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a  # v7.0.1
+        with:
+          name: ${{ steps.package.outputs.artifact_name }}
+          path: ${{ runner.temp }}/ts-sdk-package/${{ steps.release.outputs.package_file }}
+          if-no-files-found: error
+          retention-days: 1

Review Comment:
   Addressed in 00b08b1d.



##########
.github/workflows/ts-sdk-release.yml:
##########
@@ -0,0 +1,199 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+---
+name: Release TypeScript SDK
+
+on:  # yamllint disable-line rule:truthy
+  workflow_dispatch:
+    inputs:
+      release_type:
+        description: "Stage the package for review or publish it directly"
+        required: true
+        type: choice
+        options:
+          - staged
+          - formal
+      tag:
+        description: "TypeScript SDK release tag (ts-sdk/<version>)"
+        required: true
+        type: string
+      npm_tag:
+        description: "npm dist-tag (for example: beta or latest)"
+        required: true
+        type: string
+
+permissions:
+  contents: read
+
+concurrency:
+  group: ts-sdk-npm-release
+  cancel-in-progress: false
+
+jobs:
+  build:
+    name: Verify and package release
+    runs-on: ubuntu-latest
+    outputs:
+      artifact_name: ${{ steps.package.outputs.artifact_name }}
+      package_file: ${{ steps.release.outputs.package_file }}
+      sha256: ${{ steps.package.outputs.sha256 }}
+      version: ${{ steps.release.outputs.version }}
+    steps:
+      - name: Checkout dispatched release tag
+        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1  # v7.0.1
+        with:
+          fetch-depth: 0
+          persist-credentials: false
+      - name: Set up Node.js
+        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020  # v7.0.0
+        with:
+          node-version: "24.19.0"
+          registry-url: "https://registry.npmjs.org"
+          package-manager-cache: false
+      - name: Enable the pinned pnpm version
+        run: corepack enable
+      - name: Validate release inputs
+        id: release
+        working-directory: ts-sdk
+        env:
+          NPM_TAG: ${{ inputs.npm_tag }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: node scripts/validate-release-inputs.mjs
+      - name: Confirm dispatch and checkout use the release tag
+        env:
+          DISPATCH_REF: ${{ github.ref }}
+          DISPATCH_SHA: ${{ github.sha }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: |
+          set -euo pipefail
+          test "${DISPATCH_REF}" = "refs/tags/${RELEASE_TAG}"
+          test "${DISPATCH_SHA}" = "$(git rev-parse HEAD)"
+          test "$(git rev-parse "refs/tags/${RELEASE_TAG}^{commit}")" = "$(git rev-parse HEAD)"
+          git merge-base --is-ancestor HEAD "$(git rev-parse refs/remotes/origin/main)"
+      - name: Confirm release advances the npm dist-tag
+        working-directory: ts-sdk
+        env:
+          NPM_TAG: ${{ inputs.npm_tag }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: |
+          set -euo pipefail
+          error_file="${RUNNER_TEMP}/npm-view-error.log"
+          set +e
+          current_version="$(npm view apache-airflow-ts-sdk "dist-tags.${NPM_TAG}" 2>"${error_file}")"
+          view_status=$?
+          set -e
+          if [[ ${view_status} -ne 0 ]]; then
+            if grep -q "E404" "${error_file}"; then
+              current_version=""
+            else
+              cat "${error_file}" >&2
+              exit "${view_status}"
+            fi
+          fi
+          CURRENT_DIST_TAG_VERSION="${current_version}" node scripts/validate-release-inputs.mjs
+      - name: Verify package identity
+        working-directory: ts-sdk
+        env:
+          EXPECTED_VERSION: ${{ steps.release.outputs.version }}
+        run: |
+          set -euo pipefail
+          test "$(node --print "require('./package.json').name")" = "apache-airflow-ts-sdk"
+          test "$(node --print "require('./package.json').version")" = "${EXPECTED_VERSION}"
+      - name: Install and test package
+        working-directory: ts-sdk
+        run: |
+          set -euo pipefail
+          pnpm install --frozen-lockfile
+          pnpm run lint
+          pnpm run format:check
+          pnpm run typecheck
+          pnpm test
+      - name: Create package tarball
+        id: package
+        working-directory: ts-sdk
+        env:
+          PACKAGE_FILE: ${{ steps.release.outputs.package_file }}
+          VERSION: ${{ steps.release.outputs.version }}
+        run: |
+          set -euo pipefail
+          artifact_dir="${RUNNER_TEMP}/ts-sdk-package"
+          mkdir -p "${artifact_dir}"
+          test -z "$(find "${artifact_dir}" -mindepth 1 -maxdepth 1 -print -quit)"
+          npm pack --pack-destination "${artifact_dir}"
+          artifact_path="${artifact_dir}/${PACKAGE_FILE}"
+          test -f "${artifact_path}"
+          test "$(find "${artifact_dir}" -maxdepth 1 -type f -name '*.tgz' | wc -l)" -eq 1
+          echo "artifact_name=ts-sdk-package-${VERSION}" >> "${GITHUB_OUTPUT}"
+          echo "sha256=$(sha256sum "${artifact_path}" | awk '{print $1}')" >> "${GITHUB_OUTPUT}"
+      - name: Upload package tarball
+        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a  # v7.0.1
+        with:
+          name: ${{ steps.package.outputs.artifact_name }}
+          path: ${{ runner.temp }}/ts-sdk-package/${{ steps.release.outputs.package_file }}
+          if-no-files-found: error
+          retention-days: 1
+
+  publish:
+    name: ${{ inputs.release_type == 'staged' && 'Stage release on npm' || 'Publish formal release to npm' }}
+    needs: build
+    runs-on: ubuntu-latest
+    environment:
+      name: ${{ inputs.release_type == 'staged' && 'ts-sdk-npm-staged' || 'ts-sdk-npm-formal' }}
+    permissions:
+      contents: read
+      id-token: write
+    steps:
+      - name: Set up Node.js
+        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020  # v7.0.0
+        with:
+          node-version: "24.19.0"
+          registry-url: "https://registry.npmjs.org"
+          package-manager-cache: false
+      - name: Check npm supports staged and trusted publishing
+        run: |
+          node --input-type=module --eval '
+            import { execFileSync } from "node:child_process";
+            const npmVersion = execFileSync("npm", ["--version"], { encoding: "utf8" });
+            const [major, minor] = npmVersion.split(".").map(Number);
+            if (major < 11 || (major === 11 && minor < 15)) process.exit(1);

Review Comment:
   Addressed in 9699ab65.



##########
ts-sdk/scripts/validate-release-inputs.mjs:
##########
@@ -0,0 +1,152 @@
+#!/usr/bin/env node
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import console from "node:console";
+import { appendFileSync, readFileSync } from "node:fs";
+import process from "node:process";
+import { URL, pathToFileURL } from "node:url";
+
+const PACKAGE_NAME = JSON.parse(
+  readFileSync(new URL("../package.json", import.meta.url), "utf8"),
+).name;
+const SEMVER_PATTERN =
+  /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?$/;
+const NPM_TAG_PATTERN = /^[a-z][a-z0-9._-]*$/;
+
+function parseVersion(version) {
+  const match = SEMVER_PATTERN.exec(version);
+  if (match === null) {
+    throw new Error(`Release version ${JSON.stringify(version)} is not valid SemVer`);
+  }
+  return {
+    version,
+    major: BigInt(match[1]),
+    minor: BigInt(match[2]),
+    patch: BigInt(match[3]),
+    prerelease: match[4]?.split(".") ?? [],
+  };
+}
+
+function compareIdentifiers(left, right) {
+  if (left === right) {
+    return 0;
+  }
+  const leftIsNumeric = /^\d+$/.test(left);
+  const rightIsNumeric = /^\d+$/.test(right);
+  if (leftIsNumeric && rightIsNumeric) {
+    return BigInt(left) < BigInt(right) ? -1 : 1;
+  }
+  if (leftIsNumeric) {
+    return -1;
+  }
+  if (rightIsNumeric) {
+    return 1;
+  }
+  return left < right ? -1 : 1;
+}
+
+function compareVersions(left, right) {
+  for (const field of ["major", "minor", "patch"]) {
+    if (left[field] !== right[field]) {
+      return left[field] < right[field] ? -1 : 1;
+    }
+  }
+  if (left.prerelease.length === 0 || right.prerelease.length === 0) {
+    return right.prerelease.length - left.prerelease.length;
+  }
+  const length = Math.max(left.prerelease.length, right.prerelease.length);
+  for (let index = 0; index < length; index += 1) {
+    const leftIdentifier = left.prerelease[index];
+    const rightIdentifier = right.prerelease[index];
+    if (leftIdentifier === undefined) {
+      return -1;
+    }
+    if (rightIdentifier === undefined) {
+      return 1;
+    }
+    const difference = compareIdentifiers(leftIdentifier, rightIdentifier);
+    if (difference !== 0) {
+      return difference;
+    }
+  }
+  return 0;
+}
+
+function getPrereleaseChannel(prerelease) {
+  return prerelease[0]?.match(/^[A-Za-z]+/)?.[0].toLowerCase();
+}
+
+export function validateReleaseInputs({ releaseTag, npmTag, currentDistTagVersion = "" }) {
+  if (!releaseTag.startsWith("ts-sdk/")) {
+    throw new Error("Release tag must have the form ts-sdk/<semver>");
+  }
+  const version = releaseTag.slice("ts-sdk/".length);
+  const parsedVersion = parseVersion(version);
+
+  if (!NPM_TAG_PATTERN.test(npmTag)) {
+    throw new Error(`npm tag ${JSON.stringify(npmTag)} is invalid`);
+  }
+  if (parsedVersion.prerelease.length === 0 && npmTag !== "latest") {
+    throw new Error("Stable releases must use the latest npm dist-tag");
+  }
+  if (parsedVersion.prerelease.length > 0) {
+    const channel = getPrereleaseChannel(parsedVersion.prerelease);
+    if (npmTag !== "next" && npmTag !== channel) {
+      const allowedTags = channel === undefined ? "next" : `${channel} or next`;

Review Comment:
   Addressed in e73bed82.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Publish TypeScript SDK with trusted credentials [airflow]

Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on code in PR #71843:
URL: https://github.com/apache/airflow/pull/71843#discussion_r3859908761


##########
ts-sdk/README.md:
##########


Review Comment:
   The README instructs creating two trusted publisher relationships for `apache-airflow-ts-sdk`, one per environment, and claims this makes it so "the staged environment cannot publish directly and the formal environment cannot create staged versions." npm supports only one trust configuration per package: https://docs.npmjs.com/cli/v11/commands/npm-trust#provider-options, so the second npm trust github command will error out. Whichever config is created wins, and because the trusted publisher pins a single `--environment` claim, the other job's publish step will be rejected by the registry at release time - the failure surfaces only after a maintainer has approved the environment gate. The stated security property (mutually exclusive stage/publish permissions) is not achievable with the current registry.



##########
.github/workflows/ts-sdk-release.yml:
##########
@@ -0,0 +1,199 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+---
+name: Release TypeScript SDK
+
+on:  # yamllint disable-line rule:truthy
+  workflow_dispatch:
+    inputs:
+      release_type:
+        description: "Stage the package for review or publish it directly"
+        required: true
+        type: choice
+        options:
+          - staged
+          - formal
+      tag:
+        description: "TypeScript SDK release tag (ts-sdk/<version>)"
+        required: true
+        type: string
+      npm_tag:
+        description: "npm dist-tag (for example: beta or latest)"
+        required: true
+        type: string
+
+permissions:
+  contents: read
+
+concurrency:
+  group: ts-sdk-npm-release
+  cancel-in-progress: false
+
+jobs:
+  build:
+    name: Verify and package release
+    runs-on: ubuntu-latest
+    outputs:
+      artifact_name: ${{ steps.package.outputs.artifact_name }}
+      package_file: ${{ steps.release.outputs.package_file }}
+      sha256: ${{ steps.package.outputs.sha256 }}
+      version: ${{ steps.release.outputs.version }}
+    steps:
+      - name: Checkout dispatched release tag
+        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1  # v7.0.1
+        with:
+          fetch-depth: 0
+          persist-credentials: false
+      - name: Set up Node.js
+        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020  # v7.0.0
+        with:
+          node-version: "24.19.0"
+          registry-url: "https://registry.npmjs.org"
+          package-manager-cache: false
+      - name: Enable the pinned pnpm version
+        run: corepack enable
+      - name: Validate release inputs
+        id: release
+        working-directory: ts-sdk
+        env:
+          NPM_TAG: ${{ inputs.npm_tag }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: node scripts/validate-release-inputs.mjs
+      - name: Confirm dispatch and checkout use the release tag
+        env:
+          DISPATCH_REF: ${{ github.ref }}
+          DISPATCH_SHA: ${{ github.sha }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: |
+          set -euo pipefail
+          test "${DISPATCH_REF}" = "refs/tags/${RELEASE_TAG}"
+          test "${DISPATCH_SHA}" = "$(git rev-parse HEAD)"
+          test "$(git rev-parse "refs/tags/${RELEASE_TAG}^{commit}")" = "$(git rev-parse HEAD)"
+          git merge-base --is-ancestor HEAD "$(git rev-parse refs/remotes/origin/main)"
+      - name: Confirm release advances the npm dist-tag
+        working-directory: ts-sdk
+        env:
+          NPM_TAG: ${{ inputs.npm_tag }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: |
+          set -euo pipefail
+          error_file="${RUNNER_TEMP}/npm-view-error.log"
+          set +e
+          current_version="$(npm view apache-airflow-ts-sdk "dist-tags.${NPM_TAG}" 2>"${error_file}")"

Review Comment:
   Can we use `PACKAGE_NAME` to get this instead of hardcoding or something else?



##########
.github/workflows/ts-sdk-release.yml:
##########
@@ -0,0 +1,199 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+---
+name: Release TypeScript SDK
+
+on:  # yamllint disable-line rule:truthy
+  workflow_dispatch:
+    inputs:
+      release_type:
+        description: "Stage the package for review or publish it directly"
+        required: true
+        type: choice
+        options:
+          - staged
+          - formal
+      tag:
+        description: "TypeScript SDK release tag (ts-sdk/<version>)"
+        required: true
+        type: string
+      npm_tag:
+        description: "npm dist-tag (for example: beta or latest)"
+        required: true
+        type: string
+
+permissions:
+  contents: read
+
+concurrency:
+  group: ts-sdk-npm-release
+  cancel-in-progress: false
+
+jobs:
+  build:
+    name: Verify and package release
+    runs-on: ubuntu-latest
+    outputs:
+      artifact_name: ${{ steps.package.outputs.artifact_name }}
+      package_file: ${{ steps.release.outputs.package_file }}
+      sha256: ${{ steps.package.outputs.sha256 }}
+      version: ${{ steps.release.outputs.version }}
+    steps:
+      - name: Checkout dispatched release tag
+        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1  # v7.0.1
+        with:
+          fetch-depth: 0
+          persist-credentials: false
+      - name: Set up Node.js
+        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020  # v7.0.0
+        with:
+          node-version: "24.19.0"
+          registry-url: "https://registry.npmjs.org"
+          package-manager-cache: false
+      - name: Enable the pinned pnpm version
+        run: corepack enable
+      - name: Validate release inputs
+        id: release
+        working-directory: ts-sdk
+        env:
+          NPM_TAG: ${{ inputs.npm_tag }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: node scripts/validate-release-inputs.mjs
+      - name: Confirm dispatch and checkout use the release tag
+        env:
+          DISPATCH_REF: ${{ github.ref }}
+          DISPATCH_SHA: ${{ github.sha }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: |
+          set -euo pipefail
+          test "${DISPATCH_REF}" = "refs/tags/${RELEASE_TAG}"
+          test "${DISPATCH_SHA}" = "$(git rev-parse HEAD)"
+          test "$(git rev-parse "refs/tags/${RELEASE_TAG}^{commit}")" = "$(git rev-parse HEAD)"
+          git merge-base --is-ancestor HEAD "$(git rev-parse refs/remotes/origin/main)"
+      - name: Confirm release advances the npm dist-tag
+        working-directory: ts-sdk
+        env:
+          NPM_TAG: ${{ inputs.npm_tag }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: |
+          set -euo pipefail
+          error_file="${RUNNER_TEMP}/npm-view-error.log"
+          set +e
+          current_version="$(npm view apache-airflow-ts-sdk "dist-tags.${NPM_TAG}" 2>"${error_file}")"
+          view_status=$?
+          set -e
+          if [[ ${view_status} -ne 0 ]]; then
+            if grep -q "E404" "${error_file}"; then
+              current_version=""
+            else
+              cat "${error_file}" >&2
+              exit "${view_status}"
+            fi
+          fi
+          CURRENT_DIST_TAG_VERSION="${current_version}" node scripts/validate-release-inputs.mjs
+      - name: Verify package identity
+        working-directory: ts-sdk
+        env:
+          EXPECTED_VERSION: ${{ steps.release.outputs.version }}
+        run: |
+          set -euo pipefail
+          test "$(node --print "require('./package.json').name")" = "apache-airflow-ts-sdk"
+          test "$(node --print "require('./package.json').version")" = "${EXPECTED_VERSION}"
+      - name: Install and test package
+        working-directory: ts-sdk
+        run: |
+          set -euo pipefail
+          pnpm install --frozen-lockfile
+          pnpm run lint
+          pnpm run format:check
+          pnpm run typecheck
+          pnpm test
+      - name: Create package tarball
+        id: package
+        working-directory: ts-sdk
+        env:
+          PACKAGE_FILE: ${{ steps.release.outputs.package_file }}
+          VERSION: ${{ steps.release.outputs.version }}
+        run: |
+          set -euo pipefail
+          artifact_dir="${RUNNER_TEMP}/ts-sdk-package"
+          mkdir -p "${artifact_dir}"
+          test -z "$(find "${artifact_dir}" -mindepth 1 -maxdepth 1 -print -quit)"
+          npm pack --pack-destination "${artifact_dir}"
+          artifact_path="${artifact_dir}/${PACKAGE_FILE}"
+          test -f "${artifact_path}"
+          test "$(find "${artifact_dir}" -maxdepth 1 -type f -name '*.tgz' | wc -l)" -eq 1
+          echo "artifact_name=ts-sdk-package-${VERSION}" >> "${GITHUB_OUTPUT}"
+          echo "sha256=$(sha256sum "${artifact_path}" | awk '{print $1}')" >> "${GITHUB_OUTPUT}"
+      - name: Upload package tarball
+        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a  # v7.0.1
+        with:
+          name: ${{ steps.package.outputs.artifact_name }}
+          path: ${{ runner.temp }}/ts-sdk-package/${{ steps.release.outputs.package_file }}
+          if-no-files-found: error
+          retention-days: 1
+
+  publish:
+    name: ${{ inputs.release_type == 'staged' && 'Stage release on npm' || 'Publish formal release to npm' }}
+    needs: build
+    runs-on: ubuntu-latest
+    environment:
+      name: ${{ inputs.release_type == 'staged' && 'ts-sdk-npm-staged' || 'ts-sdk-npm-formal' }}
+    permissions:
+      contents: read
+      id-token: write
+    steps:
+      - name: Set up Node.js
+        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020  # v7.0.0
+        with:
+          node-version: "24.19.0"
+          registry-url: "https://registry.npmjs.org"
+          package-manager-cache: false
+      - name: Check npm supports staged and trusted publishing
+        run: |
+          node --input-type=module --eval '
+            import { execFileSync } from "node:child_process";
+            const npmVersion = execFileSync("npm", ["--version"], { encoding: "utf8" });
+            const [major, minor] = npmVersion.split(".").map(Number);
+            if (major < 11 || (major === 11 && minor < 15)) process.exit(1);

Review Comment:
   `process.exit(1)` produces no message. A release that fails here gives the release manager a bare "Process completed with exit code 1" on the one step whose failure is least self explanatory. Print the detected and required versions before exiting.



##########
.github/workflows/ts-sdk-release.yml:
##########
@@ -0,0 +1,199 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+---
+name: Release TypeScript SDK
+
+on:  # yamllint disable-line rule:truthy
+  workflow_dispatch:
+    inputs:
+      release_type:
+        description: "Stage the package for review or publish it directly"
+        required: true
+        type: choice
+        options:
+          - staged
+          - formal
+      tag:
+        description: "TypeScript SDK release tag (ts-sdk/<version>)"
+        required: true
+        type: string
+      npm_tag:
+        description: "npm dist-tag (for example: beta or latest)"
+        required: true
+        type: string
+
+permissions:
+  contents: read
+
+concurrency:
+  group: ts-sdk-npm-release
+  cancel-in-progress: false
+
+jobs:
+  build:
+    name: Verify and package release
+    runs-on: ubuntu-latest
+    outputs:
+      artifact_name: ${{ steps.package.outputs.artifact_name }}
+      package_file: ${{ steps.release.outputs.package_file }}
+      sha256: ${{ steps.package.outputs.sha256 }}
+      version: ${{ steps.release.outputs.version }}
+    steps:
+      - name: Checkout dispatched release tag
+        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1  # v7.0.1
+        with:
+          fetch-depth: 0
+          persist-credentials: false
+      - name: Set up Node.js
+        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020  # v7.0.0
+        with:
+          node-version: "24.19.0"
+          registry-url: "https://registry.npmjs.org"
+          package-manager-cache: false
+      - name: Enable the pinned pnpm version
+        run: corepack enable
+      - name: Validate release inputs
+        id: release
+        working-directory: ts-sdk
+        env:
+          NPM_TAG: ${{ inputs.npm_tag }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: node scripts/validate-release-inputs.mjs
+      - name: Confirm dispatch and checkout use the release tag
+        env:
+          DISPATCH_REF: ${{ github.ref }}
+          DISPATCH_SHA: ${{ github.sha }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: |
+          set -euo pipefail
+          test "${DISPATCH_REF}" = "refs/tags/${RELEASE_TAG}"
+          test "${DISPATCH_SHA}" = "$(git rev-parse HEAD)"
+          test "$(git rev-parse "refs/tags/${RELEASE_TAG}^{commit}")" = "$(git rev-parse HEAD)"
+          git merge-base --is-ancestor HEAD "$(git rev-parse refs/remotes/origin/main)"
+      - name: Confirm release advances the npm dist-tag
+        working-directory: ts-sdk
+        env:
+          NPM_TAG: ${{ inputs.npm_tag }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: |
+          set -euo pipefail
+          error_file="${RUNNER_TEMP}/npm-view-error.log"
+          set +e
+          current_version="$(npm view apache-airflow-ts-sdk "dist-tags.${NPM_TAG}" 2>"${error_file}")"
+          view_status=$?
+          set -e
+          if [[ ${view_status} -ne 0 ]]; then
+            if grep -q "E404" "${error_file}"; then
+              current_version=""
+            else
+              cat "${error_file}" >&2
+              exit "${view_status}"
+            fi
+          fi
+          CURRENT_DIST_TAG_VERSION="${current_version}" node scripts/validate-release-inputs.mjs
+      - name: Verify package identity
+        working-directory: ts-sdk
+        env:
+          EXPECTED_VERSION: ${{ steps.release.outputs.version }}
+        run: |
+          set -euo pipefail
+          test "$(node --print "require('./package.json').name")" = "apache-airflow-ts-sdk"
+          test "$(node --print "require('./package.json').version")" = "${EXPECTED_VERSION}"
+      - name: Install and test package
+        working-directory: ts-sdk
+        run: |
+          set -euo pipefail
+          pnpm install --frozen-lockfile
+          pnpm run lint
+          pnpm run format:check
+          pnpm run typecheck
+          pnpm test
+      - name: Create package tarball
+        id: package
+        working-directory: ts-sdk
+        env:
+          PACKAGE_FILE: ${{ steps.release.outputs.package_file }}
+          VERSION: ${{ steps.release.outputs.version }}
+        run: |
+          set -euo pipefail
+          artifact_dir="${RUNNER_TEMP}/ts-sdk-package"
+          mkdir -p "${artifact_dir}"
+          test -z "$(find "${artifact_dir}" -mindepth 1 -maxdepth 1 -print -quit)"

Review Comment:
   `test -z ...` runs immediately after `mkdir -p` on a path under `RUNNER_TEMP` on a fresh runner. It can never fail; drop it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Publish TypeScript SDK with trusted credentials [airflow]

Posted by "phanikumv (via GitHub)" <gi...@apache.org>.
phanikumv commented on code in PR #71843:
URL: https://github.com/apache/airflow/pull/71843#discussion_r3859965918


##########
.github/workflows/ts-sdk-release.yml:
##########
@@ -0,0 +1,199 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+---
+name: Release TypeScript SDK
+
+on:  # yamllint disable-line rule:truthy
+  workflow_dispatch:
+    inputs:
+      release_type:
+        description: "Stage the package for review or publish it directly"
+        required: true
+        type: choice
+        options:
+          - staged
+          - formal
+      tag:
+        description: "TypeScript SDK release tag (ts-sdk/<version>)"
+        required: true
+        type: string
+      npm_tag:
+        description: "npm dist-tag (for example: beta or latest)"
+        required: true
+        type: string
+
+permissions:
+  contents: read
+
+concurrency:
+  group: ts-sdk-npm-release
+  cancel-in-progress: false
+
+jobs:
+  build:
+    name: Verify and package release
+    runs-on: ubuntu-latest
+    outputs:
+      artifact_name: ${{ steps.package.outputs.artifact_name }}
+      package_file: ${{ steps.release.outputs.package_file }}
+      sha256: ${{ steps.package.outputs.sha256 }}
+      version: ${{ steps.release.outputs.version }}
+    steps:
+      - name: Checkout dispatched release tag
+        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1  # v7.0.1
+        with:
+          fetch-depth: 0
+          persist-credentials: false
+      - name: Set up Node.js
+        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020  # v7.0.0
+        with:
+          node-version: "24.19.0"
+          registry-url: "https://registry.npmjs.org"
+          package-manager-cache: false
+      - name: Enable the pinned pnpm version
+        run: corepack enable
+      - name: Validate release inputs
+        id: release
+        working-directory: ts-sdk
+        env:
+          NPM_TAG: ${{ inputs.npm_tag }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: node scripts/validate-release-inputs.mjs
+      - name: Confirm dispatch and checkout use the release tag
+        env:
+          DISPATCH_REF: ${{ github.ref }}
+          DISPATCH_SHA: ${{ github.sha }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: |
+          set -euo pipefail
+          test "${DISPATCH_REF}" = "refs/tags/${RELEASE_TAG}"
+          test "${DISPATCH_SHA}" = "$(git rev-parse HEAD)"
+          test "$(git rev-parse "refs/tags/${RELEASE_TAG}^{commit}")" = "$(git rev-parse HEAD)"
+          git merge-base --is-ancestor HEAD "$(git rev-parse refs/remotes/origin/main)"
+      - name: Confirm release advances the npm dist-tag
+        working-directory: ts-sdk
+        env:
+          NPM_TAG: ${{ inputs.npm_tag }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: |
+          set -euo pipefail
+          error_file="${RUNNER_TEMP}/npm-view-error.log"
+          set +e
+          current_version="$(npm view apache-airflow-ts-sdk "dist-tags.${NPM_TAG}" 2>"${error_file}")"
+          view_status=$?
+          set -e
+          if [[ ${view_status} -ne 0 ]]; then
+            if grep -q "E404" "${error_file}"; then
+              current_version=""
+            else
+              cat "${error_file}" >&2
+              exit "${view_status}"
+            fi
+          fi
+          CURRENT_DIST_TAG_VERSION="${current_version}" node scripts/validate-release-inputs.mjs
+      - name: Verify package identity
+        working-directory: ts-sdk
+        env:
+          EXPECTED_VERSION: ${{ steps.release.outputs.version }}
+        run: |
+          set -euo pipefail
+          test "$(node --print "require('./package.json').name")" = "apache-airflow-ts-sdk"
+          test "$(node --print "require('./package.json').version")" = "${EXPECTED_VERSION}"
+      - name: Install and test package
+        working-directory: ts-sdk
+        run: |
+          set -euo pipefail
+          pnpm install --frozen-lockfile
+          pnpm run lint
+          pnpm run format:check
+          pnpm run typecheck
+          pnpm test
+      - name: Create package tarball
+        id: package
+        working-directory: ts-sdk
+        env:
+          PACKAGE_FILE: ${{ steps.release.outputs.package_file }}
+          VERSION: ${{ steps.release.outputs.version }}
+        run: |
+          set -euo pipefail
+          artifact_dir="${RUNNER_TEMP}/ts-sdk-package"
+          mkdir -p "${artifact_dir}"
+          test -z "$(find "${artifact_dir}" -mindepth 1 -maxdepth 1 -print -quit)"
+          npm pack --pack-destination "${artifact_dir}"
+          artifact_path="${artifact_dir}/${PACKAGE_FILE}"
+          test -f "${artifact_path}"
+          test "$(find "${artifact_dir}" -maxdepth 1 -type f -name '*.tgz' | wc -l)" -eq 1
+          echo "artifact_name=ts-sdk-package-${VERSION}" >> "${GITHUB_OUTPUT}"
+          echo "sha256=$(sha256sum "${artifact_path}" | awk '{print $1}')" >> "${GITHUB_OUTPUT}"
+      - name: Upload package tarball
+        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a  # v7.0.1
+        with:
+          name: ${{ steps.package.outputs.artifact_name }}
+          path: ${{ runner.temp }}/ts-sdk-package/${{ steps.release.outputs.package_file }}
+          if-no-files-found: error
+          retention-days: 1

Review Comment:
   ```suggestion
             retention-days: 7
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Publish TypeScript SDK with trusted credentials [airflow]

Posted by "phanikumv (via GitHub)" <gi...@apache.org>.
phanikumv commented on code in PR #71843:
URL: https://github.com/apache/airflow/pull/71843#discussion_r3859967567


##########
.github/workflows/ts-sdk-release.yml:
##########
@@ -0,0 +1,199 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+---
+name: Release TypeScript SDK
+
+on:  # yamllint disable-line rule:truthy
+  workflow_dispatch:
+    inputs:
+      release_type:
+        description: "Stage the package for review or publish it directly"
+        required: true
+        type: choice
+        options:
+          - staged
+          - formal
+      tag:
+        description: "TypeScript SDK release tag (ts-sdk/<version>)"
+        required: true
+        type: string
+      npm_tag:
+        description: "npm dist-tag (for example: beta or latest)"
+        required: true
+        type: string
+
+permissions:
+  contents: read
+
+concurrency:
+  group: ts-sdk-npm-release
+  cancel-in-progress: false
+
+jobs:
+  build:
+    name: Verify and package release
+    runs-on: ubuntu-latest
+    outputs:
+      artifact_name: ${{ steps.package.outputs.artifact_name }}
+      package_file: ${{ steps.release.outputs.package_file }}
+      sha256: ${{ steps.package.outputs.sha256 }}
+      version: ${{ steps.release.outputs.version }}
+    steps:
+      - name: Checkout dispatched release tag
+        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1  # v7.0.1
+        with:
+          fetch-depth: 0
+          persist-credentials: false
+      - name: Set up Node.js
+        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020  # v7.0.0
+        with:
+          node-version: "24.19.0"
+          registry-url: "https://registry.npmjs.org"
+          package-manager-cache: false
+      - name: Enable the pinned pnpm version
+        run: corepack enable
+      - name: Validate release inputs
+        id: release
+        working-directory: ts-sdk
+        env:
+          NPM_TAG: ${{ inputs.npm_tag }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: node scripts/validate-release-inputs.mjs
+      - name: Confirm dispatch and checkout use the release tag
+        env:
+          DISPATCH_REF: ${{ github.ref }}
+          DISPATCH_SHA: ${{ github.sha }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: |
+          set -euo pipefail
+          test "${DISPATCH_REF}" = "refs/tags/${RELEASE_TAG}"
+          test "${DISPATCH_SHA}" = "$(git rev-parse HEAD)"
+          test "$(git rev-parse "refs/tags/${RELEASE_TAG}^{commit}")" = "$(git rev-parse HEAD)"
+          git merge-base --is-ancestor HEAD "$(git rev-parse refs/remotes/origin/main)"
+      - name: Confirm release advances the npm dist-tag
+        working-directory: ts-sdk
+        env:
+          NPM_TAG: ${{ inputs.npm_tag }}
+          RELEASE_TAG: ${{ inputs.tag }}
+        run: |
+          set -euo pipefail
+          error_file="${RUNNER_TEMP}/npm-view-error.log"
+          set +e
+          current_version="$(npm view apache-airflow-ts-sdk "dist-tags.${NPM_TAG}" 2>"${error_file}")"
+          view_status=$?
+          set -e
+          if [[ ${view_status} -ne 0 ]]; then
+            if grep -q "E404" "${error_file}"; then
+              current_version=""
+            else
+              cat "${error_file}" >&2
+              exit "${view_status}"
+            fi
+          fi
+          CURRENT_DIST_TAG_VERSION="${current_version}" node scripts/validate-release-inputs.mjs
+      - name: Verify package identity
+        working-directory: ts-sdk
+        env:
+          EXPECTED_VERSION: ${{ steps.release.outputs.version }}
+        run: |
+          set -euo pipefail
+          test "$(node --print "require('./package.json').name")" = "apache-airflow-ts-sdk"
+          test "$(node --print "require('./package.json').version")" = "${EXPECTED_VERSION}"
+      - name: Install and test package
+        working-directory: ts-sdk
+        run: |
+          set -euo pipefail
+          pnpm install --frozen-lockfile
+          pnpm run lint
+          pnpm run format:check
+          pnpm run typecheck
+          pnpm test
+      - name: Create package tarball
+        id: package
+        working-directory: ts-sdk
+        env:
+          PACKAGE_FILE: ${{ steps.release.outputs.package_file }}
+          VERSION: ${{ steps.release.outputs.version }}
+        run: |
+          set -euo pipefail
+          artifact_dir="${RUNNER_TEMP}/ts-sdk-package"
+          mkdir -p "${artifact_dir}"
+          test -z "$(find "${artifact_dir}" -mindepth 1 -maxdepth 1 -print -quit)"
+          npm pack --pack-destination "${artifact_dir}"
+          artifact_path="${artifact_dir}/${PACKAGE_FILE}"
+          test -f "${artifact_path}"
+          test "$(find "${artifact_dir}" -maxdepth 1 -type f -name '*.tgz' | wc -l)" -eq 1
+          echo "artifact_name=ts-sdk-package-${VERSION}" >> "${GITHUB_OUTPUT}"
+          echo "sha256=$(sha256sum "${artifact_path}" | awk '{print $1}')" >> "${GITHUB_OUTPUT}"
+      - name: Upload package tarball
+        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a  # v7.0.1
+        with:
+          name: ${{ steps.package.outputs.artifact_name }}
+          path: ${{ runner.temp }}/ts-sdk-package/${{ steps.release.outputs.package_file }}
+          if-no-files-found: error
+          retention-days: 1

Review Comment:
   This is the only workflow in the repo gated on human environment approval, and the only one at 1 day — everything else uses 2 or 7. Retention runs from upload, not from run completion, so any approval that lands more than ~24h after dispatch loses the tarball and forces a full re-dispatch.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Publish TypeScript SDK with trusted credentials [airflow]

Posted by "phanikumv (via GitHub)" <gi...@apache.org>.
phanikumv commented on code in PR #71843:
URL: https://github.com/apache/airflow/pull/71843#discussion_r3859974716


##########
ts-sdk/scripts/validate-release-inputs.mjs:
##########
@@ -0,0 +1,152 @@
+#!/usr/bin/env node
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import console from "node:console";
+import { appendFileSync, readFileSync } from "node:fs";
+import process from "node:process";
+import { URL, pathToFileURL } from "node:url";
+
+const PACKAGE_NAME = JSON.parse(
+  readFileSync(new URL("../package.json", import.meta.url), "utf8"),
+).name;
+const SEMVER_PATTERN =
+  /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?$/;
+const NPM_TAG_PATTERN = /^[a-z][a-z0-9._-]*$/;
+
+function parseVersion(version) {
+  const match = SEMVER_PATTERN.exec(version);
+  if (match === null) {
+    throw new Error(`Release version ${JSON.stringify(version)} is not valid SemVer`);
+  }
+  return {
+    version,
+    major: BigInt(match[1]),
+    minor: BigInt(match[2]),
+    patch: BigInt(match[3]),
+    prerelease: match[4]?.split(".") ?? [],
+  };
+}
+
+function compareIdentifiers(left, right) {
+  if (left === right) {
+    return 0;
+  }
+  const leftIsNumeric = /^\d+$/.test(left);
+  const rightIsNumeric = /^\d+$/.test(right);
+  if (leftIsNumeric && rightIsNumeric) {
+    return BigInt(left) < BigInt(right) ? -1 : 1;
+  }
+  if (leftIsNumeric) {
+    return -1;
+  }
+  if (rightIsNumeric) {
+    return 1;
+  }
+  return left < right ? -1 : 1;
+}
+
+function compareVersions(left, right) {
+  for (const field of ["major", "minor", "patch"]) {
+    if (left[field] !== right[field]) {
+      return left[field] < right[field] ? -1 : 1;
+    }
+  }
+  if (left.prerelease.length === 0 || right.prerelease.length === 0) {
+    return right.prerelease.length - left.prerelease.length;
+  }
+  const length = Math.max(left.prerelease.length, right.prerelease.length);
+  for (let index = 0; index < length; index += 1) {
+    const leftIdentifier = left.prerelease[index];
+    const rightIdentifier = right.prerelease[index];
+    if (leftIdentifier === undefined) {
+      return -1;
+    }
+    if (rightIdentifier === undefined) {
+      return 1;
+    }
+    const difference = compareIdentifiers(leftIdentifier, rightIdentifier);
+    if (difference !== 0) {
+      return difference;
+    }
+  }
+  return 0;
+}
+
+function getPrereleaseChannel(prerelease) {
+  return prerelease[0]?.match(/^[A-Za-z]+/)?.[0].toLowerCase();
+}
+
+export function validateReleaseInputs({ releaseTag, npmTag, currentDistTagVersion = "" }) {
+  if (!releaseTag.startsWith("ts-sdk/")) {
+    throw new Error("Release tag must have the form ts-sdk/<semver>");
+  }
+  const version = releaseTag.slice("ts-sdk/".length);
+  const parsedVersion = parseVersion(version);
+
+  if (!NPM_TAG_PATTERN.test(npmTag)) {
+    throw new Error(`npm tag ${JSON.stringify(npmTag)} is invalid`);
+  }
+  if (parsedVersion.prerelease.length === 0 && npmTag !== "latest") {
+    throw new Error("Stable releases must use the latest npm dist-tag");
+  }
+  if (parsedVersion.prerelease.length > 0) {
+    const channel = getPrereleaseChannel(parsedVersion.prerelease);
+    if (npmTag !== "next" && npmTag !== channel) {
+      const allowedTags = channel === undefined ? "next" : `${channel} or next`;

Review Comment:
   Same shape as the one bdd5ca145d fixed for numeric-only identifiers — the numeric case got handled, this one didn't. ts-sdk/1.0.0-next1 with --tag beta gives "must use the next or next npm dist-tag"



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org