Skip to content

Beta Release

Beta Release #2

Workflow file for this run

name: "Beta Release"
on:
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 and package name from package.json and create beta version"
id: get_version
run: |
PACKAGE_NAME=$(node -p 'require("./package.json").name')
BASE_VERSION=$(node -p 'require("./package.json").version')
# Fetch all published versions for this package
ALL_VERSIONS=$(npm view $PACKAGE_NAME versions --json 2>/dev/null || echo "[]")
# Get latest beta for this base version
LATEST_BETA=$(echo $ALL_VERSIONS | jq -r '.[] | select(startswith("'"$BASE_VERSION"'-beta."))' | sort -V | tail -n 1)
if [ -z "$LATEST_BETA" ]; then
COUNTER=1
else
COUNTER=$(echo $LATEST_BETA | sed -E 's/.*-beta\.([0-9]+)$/\1/')
COUNTER=$((COUNTER + 1))
fi
BETA_VERSION="$BASE_VERSION-beta.$COUNTER"
echo "package=$PACKAGE_NAME" >> $GITHUB_OUTPUT
echo "version=$BETA_VERSION" >> $GITHUB_OUTPUT
echo "Beta version: $BETA_VERSION for package: $PACKAGE_NAME"
- name: "Check if beta version already exists on NPM"
run: |
PACKAGE_NAME=${{ steps.get_version.outputs.package }}
BETA_VERSION=${{ steps.get_version.outputs.version }}
if npm view $PACKAGE_NAME@$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 }}