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
33 changes: 27 additions & 6 deletions .github/workflows/extension-publish-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ on:
workflow_dispatch:
inputs:
version:
description: 'ODD minor version (e.g., 1.1.0, 1.3.0). Must use ODD minor number.'
required: true
description: 'ODD minor version (e.g., 1.1.0). Leave empty to auto-detect from latest release.'
required: false
type: string
default: ''
dry-run:
description: 'Dry run (package only, do not publish)'
required: false
Expand All @@ -25,27 +26,47 @@ jobs:
steps:
- name: Validate ODD minor version
id: validate
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION="${{ inputs.version }}"
# Strip leading 'v' if present
VERSION="${VERSION#v}"


# Auto-detect from latest release tag when no version specified
if [ -z "$VERSION" ]; then
TAG=$(gh release view --json tagName -q '.tagName' -R "${{ github.repository }}")
VERSION="${TAG#hve-core-v}"

MAJOR=$(echo "$VERSION" | cut -d. -f1)
MINOR=$(echo "$VERSION" | cut -d. -f2)
PATCH=$(echo "$VERSION" | cut -d. -f3)

# Derive ODD minor: if even, bump minor by 1 and reset patch
if (( MINOR % 2 == 0 )); then
MINOR=$((MINOR + 1))
PATCH=0
fi
VERSION="${MAJOR}.${MINOR}.${PATCH}"
echo "📦 Auto-derived pre-release version from latest release: $VERSION"
fi

# Validate format
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid version format: $VERSION. Expected semantic version (e.g., 1.1.0)"
exit 1
fi

# Extract minor version
MINOR=$(echo "$VERSION" | cut -d. -f2)

# Check if ODD (pre-release channel uses ODD minor versions)
if (( MINOR % 2 == 0 )); then
echo "::error::Pre-release requires ODD minor version. Got: $VERSION (minor=$MINOR is EVEN)"
echo "::error::Use version like 1.1.0, 1.3.0, 2.1.0 for pre-release channel"
exit 1
fi

echo "✅ Valid pre-release version: $VERSION (minor=$MINOR is ODD)"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/extension-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
workflow_dispatch:
inputs:
version:
description: 'Version to publish (leave empty to use package.json version)'
description: 'Version to publish (leave empty to auto-detect from latest release)'
required: false
type: string
default: ''
Expand Down Expand Up @@ -63,14 +63,25 @@ jobs:
steps:
- name: Normalize version string
id: normalize
env:
GH_TOKEN: ${{ github.token }}
run: |
if [ "${{ github.event_name }}" == "release" ]; then
VERSION="${{ github.event.release.tag_name }}"
else
VERSION="${{ inputs.version }}"
fi
# Strip leading 'v' if present
# Strip leading 'v' and component prefix if present
VERSION="${VERSION#v}"
VERSION="${VERSION#hve-core-v}"

# Auto-detect from latest release tag when no version specified
if [ -z "$VERSION" ]; then
TAG=$(gh release view --json tagName -q '.tagName' -R "${{ github.repository }}")
VERSION="${TAG#hve-core-v}"
echo "📦 Auto-detected version from latest release: $VERSION"
fi

echo "version=$VERSION" >> "$GITHUB_OUTPUT"

package:
Expand Down
30 changes: 7 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,33 +96,17 @@ jobs:
config-file: release-please-config.json
manifest-file: .release-please-manifest.json

# Bridge: GitHub does not create git tags for draft releases, but
# release-please needs the tag to anchor version calculations for
# subsequent release PRs. Without it, release-please scans the full
# commit history, may find an old breaking change, and proposes a
# wrong major bump. The force-tag-creation config option (release-please
# v17.2.0+) would handle this natively, but v4.4.0 of the action
# bundles v17.1.3. Remove this step once the action upgrades past
# v17.2.0. See: https://github.com/googleapis/release-please/pull/2423
- name: Create git tag for draft release
# Bridge: release-please creates a published release so it can
# anchor version calculations in the same run. Convert to draft
# immediately so assets can be uploaded to a mutable release.
# The publish-release job converts back to published after upload.
- name: Convert release to draft for asset upload
if: ${{ steps.release.outputs.release_created == 'true' }}
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
TAG="${{ steps.release.outputs.tag_name }}"
echo "Creating tag $TAG at ${{ github.sha }}"
if ! OUTPUT=$(gh api "repos/${{ github.repository }}/git/refs" \
--method POST \
-f ref="refs/tags/$TAG" \
-f sha="${{ github.sha }}" 2>&1); then
if echo "$OUTPUT" | grep -qi "Reference already exists"; then
echo "::warning::Tag $TAG already exists, skipping"
else
echo "::error::Failed to create tag $TAG"
echo "$OUTPUT" >&2
exit 1
fi
fi
gh release edit "${{ steps.release.outputs.tag_name }}" \
--draft=true -R "${{ github.repository }}"

extension-package-release:
name: Package VS Code Extensions (Release)
Expand Down
3 changes: 0 additions & 3 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"draft": true,
"release-search-depth": 800,
"commit-search-depth": 1000,
"force-tag-creation": true,
"packages": {
".": {
"release-type": "node",
Expand All @@ -19,7 +17,6 @@
],
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": false,
"draft": true,
"extra-files": [
{
"type": "json",
Expand Down
Loading