77 paths :
88 - ' packages/**'
99 - ' .github/workflows/release.yml'
10+ workflow_dispatch :
11+ inputs :
12+ force_release :
13+ description : ' Force release of packages (comma-separated, e.g. "mcp,test-utils")'
14+ required : false
15+ type : string
16+ force_version :
17+ description : ' Force specific version (leave empty to auto-increment)'
18+ required : false
19+ type : string
1020
1121jobs :
1222 release :
8090 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
8191 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
8292 CHANGED_PACKAGES : ${{ steps.changed_packages.outputs.packages }}
93+ FORCE_RELEASE : ${{ github.event.inputs.force_release }}
94+ FORCE_VERSION : ${{ github.event.inputs.force_version }}
8395 run : |
8496 # Convert JSON array back to space-separated list for shell processing
8597 PACKAGES_LIST=$(echo '${{ steps.changed_packages.outputs.packages }}' | jq -r 'join(" ")')
@@ -101,25 +113,54 @@ jobs:
101113 cp ../../.github/release-template.json .releaserc.json
102114 fi
103115
116+ # Check if this package is in the FORCE_RELEASE list
117+ PACKAGE_SHORT_NAME=$(echo $PKG | sed 's|packages/||')
118+ FORCE_THIS_PACKAGE=false
119+ if [[ -n "$FORCE_RELEASE" && "$FORCE_RELEASE" == *"$PACKAGE_SHORT_NAME"* ]]; then
120+ FORCE_THIS_PACKAGE=true
121+ echo "Force release enabled for $PACKAGE_NAME"
122+ fi
123+
104124 # Unified versioning logic for all packages
105125 # Check if package exists on npm yet
106126 PACKAGE_EXISTS=$(npm view $PACKAGE_NAME version 2>/dev/null || echo "")
107127
108- if [[ -z "$PACKAGE_EXISTS" ]]; then
109- # First-time publishing
110- if [[ "$CURRENT_VERSION" == 0.* ]]; then
111- # Keep the 0.x.x version for pre-1.0 packages
112- echo "First-time publishing $PACKAGE_NAME at version $CURRENT_VERSION"
128+ if [[ -z "$PACKAGE_EXISTS" || "$FORCE_THIS_PACKAGE" == "true" ]]; then
129+ # First-time publishing or forced release
130+ if [[ -n "$FORCE_VERSION" ]]; then
131+ # Use forced version if provided
132+ NEW_VERSION="$FORCE_VERSION"
133+ npm version $NEW_VERSION --no-git-tag-version --allow-same-version
134+ echo "Forcing version $NEW_VERSION for $PACKAGE_NAME"
135+ elif [[ "$CURRENT_VERSION" == 0.* ]]; then
136+ # For packages starting with 0.x.x, extract and increment the patch version
137+ MAJOR=$(echo $CURRENT_VERSION | cut -d. -f1)
138+ MINOR=$(echo $CURRENT_VERSION | cut -d. -f2)
139+ PATCH=$(echo $CURRENT_VERSION | cut -d. -f3)
140+ NEXT_PATCH=$((PATCH + 1))
141+ NEW_VERSION="$MAJOR.$MINOR.$NEXT_PATCH"
142+ npm version $NEW_VERSION --no-git-tag-version
143+ echo "Incrementing version to $NEW_VERSION for $PACKAGE_NAME"
113144 else
114- # For packages with version >= 1.0.0, ensure we start at proper semver
115- if [[ "$CURRENT_VERSION" != 1.0.0 ]]; then
116- npm version 1.0.0 --no-git-tag-version --allow-same-version
117- echo "First-time publishing $PACKAGE_NAME - normalizing to version 1.0.0"
118- else
119- echo "First-time publishing $PACKAGE_NAME at version 1.0.0"
120- fi
145+ # For packages with version >= 1.0.0, increment patch
146+ MAJOR=$(echo $CURRENT_VERSION | cut -d. -f1)
147+ MINOR=$(echo $CURRENT_VERSION | cut -d. -f2)
148+ PATCH=$(echo $CURRENT_VERSION | cut -d. -f3)
149+ NEXT_PATCH=$((PATCH + 1))
150+ NEW_VERSION="$MAJOR.$MINOR.$NEXT_PATCH"
151+ npm version $NEW_VERSION --no-git-tag-version
152+ echo "Incrementing version to $NEW_VERSION for $PACKAGE_NAME"
153+ fi
154+
155+ if [[ "$FORCE_THIS_PACKAGE" == "true" ]]; then
156+ # Force publish without checking for changes
157+ echo "Running semantic-release with force flag for $PACKAGE_NAME"
158+ RELEASE_OUTPUT=$(npx semantic-release --branches main --no-ci 2>&1 || true)
159+ else
160+ # First-time publishing
161+ echo "First-time publishing $PACKAGE_NAME at version $CURRENT_VERSION"
162+ RELEASE_OUTPUT=$(npx semantic-release --branches main --no-ci --first-release 2>&1 || true)
121163 fi
122- RELEASE_OUTPUT=$(npx semantic-release --branches main --no-ci --first-release 2>&1 || true)
123164 else
124165 # Package exists - determine version increment
125166 # Get existing versions
@@ -128,47 +169,58 @@ jobs:
128169 # Determine if we need to bump version based on commit history
129170 BUMP_TYPE=$(npx semantic-release --dry-run --branches main 2>&1 | grep -o "The next release version is" | wc -l)
130171
131- if [[ $BUMP_TYPE -gt 0 ]]; then
132- # Get the recommended bump type based on commits
133- NEXT_VERSION_TYPE=$(npx semantic-release --dry-run --branches main 2>&1 | grep -o "release type: \\w\\+" | cut -d " " -f 3)
134-
135- # Current version components
136- CURRENT_MAJOR=$(echo $CURRENT_VERSION | cut -d. -f1)
137- CURRENT_MINOR=$(echo $CURRENT_VERSION | cut -d. -f2)
138- CURRENT_PATCH=$(echo $CURRENT_VERSION | cut -d. -f3)
139-
140- # Calculate next version properly depending on current major version
141- if [[ "$CURRENT_MAJOR" == "0" ]]; then
142- # For 0.x versions
143- if [[ "$NEXT_VERSION_TYPE" == "major" || "$NEXT_VERSION_TYPE" == "minor" ]]; then
144- # For a major or minor bump in 0.x, increment the minor (0.x.y -> 0.[x+1].0)
145- NEXT_MINOR=$((CURRENT_MINOR + 1))
146- NEXT_VERSION="0.$NEXT_MINOR.0"
147- else
148- # For a patch bump, increment patch (0.x.y -> 0.x.[y+1])
149- NEXT_PATCH=$((CURRENT_PATCH + 1))
150- NEXT_VERSION="0.$CURRENT_MINOR.$NEXT_PATCH"
151- fi
172+ if [[ $BUMP_TYPE -gt 0 || "$FORCE_THIS_PACKAGE" == "true" ]]; then
173+ # Changes detected or force flag enabled
174+ if [[ -n "$FORCE_VERSION" ]]; then
175+ # Use forced version if provided
176+ NEW_VERSION="$FORCE_VERSION"
152177 else
153- # For 1.x and above, follow standard semver
154- if [[ "$NEXT_VERSION_TYPE" == "major" ]]; then
155- NEXT_MAJOR=$((CURRENT_MAJOR + 1))
156- NEXT_VERSION="$NEXT_MAJOR.0.0"
157- elif [[ "$NEXT_VERSION_TYPE" == "minor" ]]; then
158- NEXT_MINOR=$((CURRENT_MINOR + 1))
159- NEXT_VERSION="$CURRENT_MAJOR.$NEXT_MINOR.0"
178+ # Try to get recommended bump type based on commits
179+ NEXT_VERSION_TYPE=$(npx semantic-release --dry-run --branches main 2>&1 | grep -o "release type: \\w\\+" | cut -d " " -f 3 || echo "patch")
180+
181+ # Default to patch if we couldn't determine the type
182+ if [[ -z "$NEXT_VERSION_TYPE" ]]; then
183+ NEXT_VERSION_TYPE="patch"
184+ fi
185+
186+ # Current version components
187+ CURRENT_MAJOR=$(echo $CURRENT_VERSION | cut -d. -f1)
188+ CURRENT_MINOR=$(echo $CURRENT_VERSION | cut -d. -f2)
189+ CURRENT_PATCH=$(echo $CURRENT_VERSION | cut -d. -f3)
190+
191+ # Calculate next version properly depending on current major version
192+ if [[ "$CURRENT_MAJOR" == "0" ]]; then
193+ # For 0.x versions
194+ if [[ "$NEXT_VERSION_TYPE" == "major" || "$NEXT_VERSION_TYPE" == "minor" || "$FORCE_THIS_PACKAGE" == "true" ]]; then
195+ # For a major or minor bump in 0.x, increment the minor (0.x.y -> 0.[x+1].0)
196+ NEXT_MINOR=$((CURRENT_MINOR + 1))
197+ NEW_VERSION="0.$NEXT_MINOR.0"
198+ else
199+ # For a patch bump, increment patch (0.x.y -> 0.x.[y+1])
200+ NEXT_PATCH=$((CURRENT_PATCH + 1))
201+ NEW_VERSION="0.$CURRENT_MINOR.$NEXT_PATCH"
202+ fi
160203 else
161- NEXT_PATCH=$((CURRENT_PATCH + 1))
162- NEXT_VERSION="$CURRENT_MAJOR.$CURRENT_MINOR.$NEXT_PATCH"
204+ # For 1.x and above, follow standard semver
205+ if [[ "$NEXT_VERSION_TYPE" == "major" ]]; then
206+ NEXT_MAJOR=$((CURRENT_MAJOR + 1))
207+ NEW_VERSION="$NEXT_MAJOR.0.0"
208+ elif [[ "$NEXT_VERSION_TYPE" == "minor" ]]; then
209+ NEXT_MINOR=$((CURRENT_MINOR + 1))
210+ NEW_VERSION="$CURRENT_MAJOR.$NEXT_MINOR.0"
211+ else
212+ NEXT_PATCH=$((CURRENT_PATCH + 1))
213+ NEW_VERSION="$CURRENT_MAJOR.$CURRENT_MINOR.$NEXT_PATCH"
214+ fi
163215 fi
164216 fi
165217
166218 # Set this version in package.json
167- npm version $NEXT_VERSION --no-git-tag-version --allow-same-version
168- echo "Bumping $PACKAGE_NAME version to $NEXT_VERSION based on semantic-release recommendation "
219+ npm version $NEW_VERSION --no-git-tag-version --allow-same-version
220+ echo "Bumping $PACKAGE_NAME version to $NEW_VERSION "
169221 RELEASE_OUTPUT=$(npx semantic-release --branches main --no-ci 2>&1 || true)
170222 else
171- # No changes requiring version bump
223+ # No changes requiring version bump and not forcing
172224 echo "No changes detected requiring version bump for $PACKAGE_NAME"
173225 RELEASE_OUTPUT="No changes requiring release detected"
174226 fi
0 commit comments