diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml new file mode 100644 index 0000000..226729e --- /dev/null +++ b/.github/workflows/beta-release.yml @@ -0,0 +1,58 @@ +name: "Beta Release" + +on: + push: + branches: + - beta + workflow_dispatch: + +permissions: + contents: read + +jobs: + publish-beta: + runs-on: ubuntu-latest + steps: + - name: "Checkout source code" + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: "Set up Node.js" + uses: actions/setup-node@v4 + with: + node-version: 22.x + registry-url: "https://registry.npmjs.org/" + + - name: "Install dependencies" + run: npm ci + + - name: "Create build" + run: npm run build + + - name: "Get version from package.json and create beta version" + id: get_version + run: | + BASE_VERSION=$(node -p 'require("./package.json").version') + BETA_VERSION="$BASE_VERSION-beta" + echo "version=$BETA_VERSION" >> $GITHUB_OUTPUT + echo "Beta version: $BETA_VERSION" + + - name: "Check if beta version already exists on NPM" + run: | + BETA_VERSION=${{ steps.get_version.outputs.version }} + # Check if version exists on npm + if npm view @browserstack/mcp-server@$BETA_VERSION version 2>/dev/null; then + echo "Error: Beta version $BETA_VERSION already exists on NPM!" + exit 1 + 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 + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file