diff --git a/.github/workflows/extension-publish-prerelease.yml b/.github/workflows/extension-publish-prerelease.yml index 2b2d2434..e0400a3c 100644 --- a/.github/workflows/extension-publish-prerelease.yml +++ b/.github/workflows/extension-publish-prerelease.yml @@ -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 @@ -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" diff --git a/.github/workflows/extension-publish.yml b/.github/workflows/extension-publish.yml index 7840a2df..4ef8079c 100644 --- a/.github/workflows/extension-publish.yml +++ b/.github/workflows/extension-publish.yml @@ -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: '' @@ -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: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5d5fc0fa..02820ad2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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) diff --git a/release-please-config.json b/release-please-config.json index cf1d013c..bf88d08c 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -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", @@ -19,7 +17,6 @@ ], "bump-minor-pre-major": true, "bump-patch-for-minor-pre-major": false, - "draft": true, "extra-files": [ { "type": "json",