Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/beta-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

permissions:
contents: read
id-token: write
actions: write

jobs:
publish-beta:
Expand All @@ -20,7 +20,6 @@ jobs:
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 24.22.3
registry-url: "https://registry.npmjs.org/"

- name: "Install dependencies"
run: npm ci
Expand Down Expand Up @@ -63,12 +62,13 @@ jobs:
fi
echo "Beta version $BETA_VERSION is available for release"

- name: "Update package.json with beta version"
run: |
npm version ${{ steps.get_version.outputs.version }} --no-git-tag-version

- name: "Publish beta to NPM"
run: npm publish --tag beta --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.get_version.outputs.version }}
run: |
RUN_ID=$(gh api -X POST "repos/$GITHUB_REPOSITORY/actions/workflows/publish.yml/dispatches" \
-f ref="$GITHUB_REF_NAME" -F return_run_details=true \
-f "inputs[ref]=$GITHUB_SHA" -f "inputs[version]=$VERSION" -f "inputs[tag]=beta" \
--jq .workflow_run_id)
gh run watch "$RUN_ID" --repo "$GITHUB_REPOSITORY" --exit-status
12 changes: 8 additions & 4 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:

permissions:
contents: write
id-token: write
actions: write

jobs:
Expand All @@ -21,7 +20,6 @@ jobs:
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 24.22.3
registry-url: "https://registry.npmjs.org/"

- name: "Install dependencies"
run: npm ci
Expand Down Expand Up @@ -101,9 +99,15 @@ jobs:
run: git push origin ${{ steps.get_version.outputs.version }}

- name: "Publish to NPM"
run: npm publish --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.get_version.outputs.version }}
run: |
RUN_ID=$(gh api -X POST "repos/$GITHUB_REPOSITORY/actions/workflows/publish.yml/dispatches" \
-f ref="$GITHUB_REF_NAME" -F return_run_details=true \
-f "inputs[ref]=$VERSION" -f "inputs[version]=${VERSION#v}" -f "inputs[tag]=latest" \
--jq .workflow_run_id)
gh run watch "$RUN_ID" --repo "$GITHUB_REPOSITORY" --exit-status

- name: "Create GitHub Release"
env:
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: "Publish to NPM"

on:
workflow_dispatch:
inputs:
ref:
description: "Git tag or commit"
required: true
type: string
version:
description: "Version to publish"
required: true
type: string
tag:
description: "npm dist-tag (latest | beta | tp-canary)"
required: true
type: string

permissions:
contents: read

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
env:
PACKAGE_NAME: "@browserstack/mcp-server"
VERSION: ${{ inputs.version }}
TAG: ${{ inputs.tag }}
steps:
- name: "Checkout source code"
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
ref: ${{ inputs.ref }}

- name: "Set up Node.js"
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 24.22.3

- name: "Install npm with trusted publishing support"
run: npm install -g npm@11.21.0

- name: "Install dependencies"
run: npm ci

- name: "Create build"
run: npm run build

- name: "Verify name and set version"
run: |
[ "$(node -p 'require("./package.json").name')" = "$PACKAGE_NAME" ] || { echo "::error::wrong package"; exit 1; }
BASE="$(node -p 'require("./package.json").version')"
case "$VERSION" in
"$BASE") ;;
"$BASE"-*) npm version "$VERSION" --no-git-tag-version ;;
*) echo "::error::version $VERSION does not match package.json $BASE"; exit 1 ;;
esac

- name: "Publish"
run: npm publish --tag "$TAG" --access public
Loading