From 464a0b6b1dff5b66d932a2f2967526fc52deb659 Mon Sep 17 00:00:00 2001 From: Ehab Younes Date: Tue, 14 Oct 2025 17:13:49 +0300 Subject: [PATCH 01/10] Automatically publish extension to marketplaces * Publish pre-release extension on every push to main * Upload VSIX to the VS Code Marketplace and Open VSX on tag push --- .github/workflows/pre-release.yaml | 148 +++++++++++++++++++++++++++++ .github/workflows/release.yaml | 106 +++++++++++++++++++-- 2 files changed, 246 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/pre-release.yaml diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml new file mode 100644 index 00000000..144b7647 --- /dev/null +++ b/.github/workflows/pre-release.yaml @@ -0,0 +1,148 @@ +name: Pre-Release +on: + push: + branches: + - main + +jobs: + package: + name: Package + runs-on: ubuntu-22.04 + outputs: + packageName: ${{ steps.setup.outputs.packageName }} + version: ${{ steps.version.outputs.version }} + steps: + - uses: actions/checkout@v5 + + - uses: actions/setup-node@v5 + with: + node-version: "22" + + - name: Install dependencies + run: | + yarn + npm install -g @vscode/vsce ovsx + + - name: Generate pre-release version + id: version + run: | + BASE_VERSION=$(node -e "console.log(require('./package.json').version)") + IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION" + + PRE_MINOR=$((MINOR + 1)) + + DATE_PREFIX=$(date +%Y%m%d) + BUILD_SUFFIX=$(printf "%02d" $((GITHUB_RUN_NUMBER % 100))) + DATE_PATCH="${DATE_PREFIX}${BUILD_SUFFIX}" + + # Final version: MAJOR.(MINOR+1).YYYYMMDDNN + NUMERIC_VERSION="${MAJOR}.${PRE_MINOR}.${DATE_PATCH}${{ github.run_number }}" + + echo "version=$NUMERIC_VERSION" >> $GITHUB_OUTPUT + + echo "Pre-release version: $NUMERIC_VERSION" + + # Update package.json with the numeric version + npm version $NUMERIC_VERSION --no-git-tag-version + + - name: Setup package path + id: setup + run: | + PACKAGE_NAME="${{ github.event.repository.name }}-pre-${{ steps.version.outputs.version }}.vsix" + echo "packageName=$PACKAGE_NAME" >> $GITHUB_OUTPUT + + - name: Package extension + run: vsce package --pre-release --out "${{ steps.setup.outputs.packageName }}" + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: extension-build-${{ github.run_number }} + path: ${{ steps.setup.outputs.packageName }} + if-no-files-found: error + retention-days: 7 + + publishMS: + name: Publish to VS Marketplace + runs-on: ubuntu-22.04 + needs: package + steps: + - uses: actions/checkout@v5 + + - uses: actions/setup-node@v5 + with: + node-version: "22" + + - name: Install vsce + run: npm install -g @vscode/vsce + + - uses: actions/download-artifact@v5 + with: + name: extension-build-${{ github.run_number }} + + - name: Publish to VS Marketplace + run: | + echo "Publishing version ${{ needs.package.outputs.version }} to VS Marketplace" + vsce publish --pre-release --packagePath "./${{ needs.package.outputs.packageName }}" -p ${{ secrets.VSCE_PAT }} + + publishOVSX: + name: Publish to Open VSX + runs-on: ubuntu-22.04 + needs: package + steps: + - uses: actions/checkout@v5 + + - uses: actions/setup-node@v5 + with: + node-version: "22" + + - name: Install ovsx + run: npm install -g ovsx + + - uses: actions/download-artifact@v5 + with: + name: extension-build-${{ github.run_number }} + + - name: Publish to Open VSX + run: | + echo "Publishing version ${{ needs.package.outputs.version }} to Open VSX" + ovsx publish "./${{ needs.package.outputs.packageName }}" --pre-release -p ${{ secrets.OVSX_PAT }} + + publishGH: + name: Update Latest Pre-Release + runs-on: ubuntu-22.04 + needs: package + permissions: + contents: write + steps: + - uses: actions/checkout@v5 + + - uses: actions/download-artifact@v5 + with: + name: extension-build-${{ github.run_number }} + + - name: Update Rolling Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Delete old release and tag + gh release delete latest-pre-release --cleanup-tag -y || true + + # Create new release with heredoc for formatting + cat << EOF | gh release create latest-pre-release \ + --target ${{ github.sha }} \ + --title "Latest Pre-Release Build" \ + --notes-file - \ + --prerelease \ + --latest=false \ + ${{ needs.package.outputs.packageName }} + ## Latest Pre-Release: v${{ needs.package.outputs.version }} + + **Build:** #${{ github.run_number }} | **Commit:** ${{ github.sha }} + + ## Changes + ${{ github.event.head_commit.message }} + + --- + *This release is automatically updated with each push to main. The tag `latest-pre-release` always points to the most recent build.* + EOF diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 28f8fdf0..d59f195f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,18 +1,21 @@ +name: Release on: push: tags: - "v*" -name: release - permissions: # Required to publish a release contents: write - pull-requests: "read" + pull-requests: read jobs: package: + name: Package runs-on: ubuntu-22.04 + outputs: + packageName: ${{ steps.setup.outputs.packageName }} + version: ${{ steps.version.outputs.version }} steps: - uses: actions/checkout@v5 @@ -20,14 +23,101 @@ jobs: with: node-version: "22" - - run: yarn + - name: Install dependencies + run: | + yarn + npm install -g @vscode/vsce ovsx + + - name: Extract version from tag + id: version + run: | + # Extract version from tag (remove 'v' prefix) + VERSION=${GITHUB_REF#refs/tags/v} + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Release version: $VERSION" + + - name: Setup package path + id: setup + run: | + PACKAGE_NAME="${{ github.event.repository.name }}-${{ steps.version.outputs.version }}.vsix" + echo "packageName=$PACKAGE_NAME" >> $GITHUB_OUTPUT + + - name: Package extension + run: vsce package --out "${{ steps.setup.outputs.packageName }}" + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: extension-release-${{ steps.version.outputs.version }} + path: ${{ steps.setup.outputs.packageName }} + if-no-files-found: error + retention-days: 30 + + publishMS: + name: Publish to VS Marketplace + runs-on: ubuntu-22.04 + needs: package + steps: + - uses: actions/checkout@v5 + + - uses: actions/setup-node@v5 + with: + node-version: "22" + + - name: Install vsce + run: npm install -g @vscode/vsce + + - uses: actions/download-artifact@v5 + with: + name: extension-release-${{ needs.package.outputs.version }} + + - name: Publish to VS Marketplace + run: | + echo "Publishing version ${{ needs.package.outputs.version }} to VS Marketplace" + vsce publish --packagePath "./${{ needs.package.outputs.packageName }}" -p ${{ secrets.VSCE_PAT }} - - run: npx @vscode/vsce package + publishOVSX: + name: Publish to Open VSX + runs-on: ubuntu-22.04 + needs: package + steps: + - uses: actions/checkout@v5 + + - uses: actions/setup-node@v5 + with: + node-version: "22" + + - name: Install ovsx + run: npm install -g ovsx + + - uses: actions/download-artifact@v5 + with: + name: extension-release-${{ needs.package.outputs.version }} + + - name: Publish to Open VSX + run: | + echo "Publishing version ${{ needs.package.outputs.version }} to Open VSX" + ovsx publish "./${{ needs.package.outputs.packageName }}" -p ${{ secrets.OVSX_PAT }} + + publishGH: + name: Create GitHub Release + runs-on: ubuntu-22.04 + needs: package + permissions: + contents: write + steps: + - uses: actions/checkout@v5 + + - uses: actions/download-artifact@v5 + with: + name: extension-release-${{ needs.package.outputs.version }} - - uses: "marvinpinto/action-automatic-releases@latest" + - name: Create Release + uses: marvinpinto/action-automatic-releases@latest with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" + repo_token: ${{ secrets.GITHUB_TOKEN }} prerelease: false draft: true + title: "Release v${{ needs.package.outputs.version }}" files: | - *.vsix + ${{ needs.package.outputs.packageName }} From 8632cd77e1b8ae77b16d3c97d910957f1c385436 Mon Sep 17 00:00:00 2001 From: Ehab Younes Date: Tue, 14 Oct 2025 17:38:49 +0300 Subject: [PATCH 02/10] Unified the extension publishing logic --- .github/workflows/pre-release.yaml | 65 +++++--------------- .github/workflows/publish-extension.yaml | 76 ++++++++++++++++++++++++ .github/workflows/release.yaml | 60 ++++--------------- 3 files changed, 104 insertions(+), 97 deletions(-) create mode 100644 .github/workflows/publish-extension.yaml diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml index 144b7647..d2b9b6e3 100644 --- a/.github/workflows/pre-release.yaml +++ b/.github/workflows/pre-release.yaml @@ -21,7 +21,7 @@ jobs: - name: Install dependencies run: | yarn - npm install -g @vscode/vsce ovsx + npm install -g @vscode/vsce - name: Generate pre-release version id: version @@ -36,10 +36,9 @@ jobs: DATE_PATCH="${DATE_PREFIX}${BUILD_SUFFIX}" # Final version: MAJOR.(MINOR+1).YYYYMMDDNN - NUMERIC_VERSION="${MAJOR}.${PRE_MINOR}.${DATE_PATCH}${{ github.run_number }}" + NUMERIC_VERSION="${MAJOR}.${PRE_MINOR}.${DATE_PATCH}" echo "version=$NUMERIC_VERSION" >> $GITHUB_OUTPUT - echo "Pre-release version: $NUMERIC_VERSION" # Update package.json with the numeric version @@ -57,56 +56,22 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: extension-build-${{ github.run_number }} + name: extension-${{ steps.version.outputs.version }} path: ${{ steps.setup.outputs.packageName }} if-no-files-found: error retention-days: 7 - publishMS: - name: Publish to VS Marketplace - runs-on: ubuntu-22.04 + publish: + name: Publish to Marketplaces needs: package - steps: - - uses: actions/checkout@v5 - - - uses: actions/setup-node@v5 - with: - node-version: "22" - - - name: Install vsce - run: npm install -g @vscode/vsce - - - uses: actions/download-artifact@v5 - with: - name: extension-build-${{ github.run_number }} - - - name: Publish to VS Marketplace - run: | - echo "Publishing version ${{ needs.package.outputs.version }} to VS Marketplace" - vsce publish --pre-release --packagePath "./${{ needs.package.outputs.packageName }}" -p ${{ secrets.VSCE_PAT }} - - publishOVSX: - name: Publish to Open VSX - runs-on: ubuntu-22.04 - needs: package - steps: - - uses: actions/checkout@v5 - - - uses: actions/setup-node@v5 - with: - node-version: "22" - - - name: Install ovsx - run: npm install -g ovsx - - - uses: actions/download-artifact@v5 - with: - name: extension-build-${{ github.run_number }} - - - name: Publish to Open VSX - run: | - echo "Publishing version ${{ needs.package.outputs.version }} to Open VSX" - ovsx publish "./${{ needs.package.outputs.packageName }}" --pre-release -p ${{ secrets.OVSX_PAT }} + uses: ./.github/workflows/publish-extension.yaml + with: + version: ${{ needs.package.outputs.version }} + packageName: ${{ needs.package.outputs.packageName }} + isPreRelease: true + secrets: + VSCE_PAT: ${{ secrets.VSCE_PAT }} + OVSX_PAT: ${{ secrets.OVSX_PAT }} publishGH: name: Update Latest Pre-Release @@ -119,7 +84,7 @@ jobs: - uses: actions/download-artifact@v5 with: - name: extension-build-${{ github.run_number }} + name: extension-${{ needs.package.outputs.version }} - name: Update Rolling Release env: @@ -144,5 +109,5 @@ jobs: ${{ github.event.head_commit.message }} --- - *This release is automatically updated with each push to main. The tag `latest-pre-release` always points to the most recent build.* + *This release is automatically updated with each push to main. The tag \`latest-pre-release\` always points to the most recent build.* EOF diff --git a/.github/workflows/publish-extension.yaml b/.github/workflows/publish-extension.yaml new file mode 100644 index 00000000..152bdb96 --- /dev/null +++ b/.github/workflows/publish-extension.yaml @@ -0,0 +1,76 @@ +name: Publish Extension + +on: + workflow_call: + inputs: + version: + required: true + type: string + description: "Version to publish" + packageName: + required: true + type: string + description: "Package filename" + isPreRelease: + required: false + type: boolean + default: false + description: "Whether this is a pre-release" + secrets: + VSCE_PAT: + required: true + OVSX_PAT: + required: true + +jobs: + publishMS: + name: Publish to VS Marketplace + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v5 + + - uses: actions/setup-node@v5 + with: + node-version: "22" + + - name: Install vsce + run: npm install -g @vscode/vsce + + - uses: actions/download-artifact@v5 + with: + name: extension-${{ inputs.version }} + + - name: Publish to VS Marketplace + run: | + echo "Publishing version ${{ inputs.version }} to VS Marketplace" + if [ "${{ inputs.isPreRelease }}" = "true" ]; then + vsce publish --pre-release --packagePath "./${{ inputs.packageName }}" -p ${{ secrets.VSCE_PAT }} + else + vsce publish --packagePath "./${{ inputs.packageName }}" -p ${{ secrets.VSCE_PAT }} + fi + + publishOVSX: + name: Publish to Open VSX + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v5 + + - uses: actions/setup-node@v5 + with: + node-version: "22" + + - name: Install ovsx + run: npm install -g ovsx + + - uses: actions/download-artifact@v5 + with: + name: extension-${{ inputs.version }} + + - name: Publish to Open VSX + run: | + echo "Publishing version ${{ inputs.version }} to Open VSX" + if [ "${{ inputs.isPreRelease }}" = "true" ]; then + ovsx publish "./${{ inputs.packageName }}" --pre-release -p ${{ secrets.OVSX_PAT }} + else + ovsx publish "./${{ inputs.packageName }}" -p ${{ secrets.OVSX_PAT }} + fi diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d59f195f..e07a3eed 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -26,7 +26,7 @@ jobs: - name: Install dependencies run: | yarn - npm install -g @vscode/vsce ovsx + npm install -g @vscode/vsce - name: Extract version from tag id: version @@ -48,56 +48,22 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: extension-release-${{ steps.version.outputs.version }} + name: extension-${{ steps.version.outputs.version }} path: ${{ steps.setup.outputs.packageName }} if-no-files-found: error retention-days: 30 - publishMS: - name: Publish to VS Marketplace - runs-on: ubuntu-22.04 - needs: package - steps: - - uses: actions/checkout@v5 - - - uses: actions/setup-node@v5 - with: - node-version: "22" - - - name: Install vsce - run: npm install -g @vscode/vsce - - - uses: actions/download-artifact@v5 - with: - name: extension-release-${{ needs.package.outputs.version }} - - - name: Publish to VS Marketplace - run: | - echo "Publishing version ${{ needs.package.outputs.version }} to VS Marketplace" - vsce publish --packagePath "./${{ needs.package.outputs.packageName }}" -p ${{ secrets.VSCE_PAT }} - - publishOVSX: - name: Publish to Open VSX - runs-on: ubuntu-22.04 + publish: + name: Publish to Marketplaces needs: package - steps: - - uses: actions/checkout@v5 - - - uses: actions/setup-node@v5 - with: - node-version: "22" - - - name: Install ovsx - run: npm install -g ovsx - - - uses: actions/download-artifact@v5 - with: - name: extension-release-${{ needs.package.outputs.version }} - - - name: Publish to Open VSX - run: | - echo "Publishing version ${{ needs.package.outputs.version }} to Open VSX" - ovsx publish "./${{ needs.package.outputs.packageName }}" -p ${{ secrets.OVSX_PAT }} + uses: ./.github/workflows/publish-extension.yaml + with: + version: ${{ needs.package.outputs.version }} + packageName: ${{ needs.package.outputs.packageName }} + isPreRelease: false + secrets: + VSCE_PAT: ${{ secrets.VSCE_PAT }} + OVSX_PAT: ${{ secrets.OVSX_PAT }} publishGH: name: Create GitHub Release @@ -110,7 +76,7 @@ jobs: - uses: actions/download-artifact@v5 with: - name: extension-release-${{ needs.package.outputs.version }} + name: extension-${{ needs.package.outputs.version }} - name: Create Release uses: marvinpinto/action-automatic-releases@latest From c6baaf190eedc4f7b8af900c1d49f0fe9f81b7ac Mon Sep 17 00:00:00 2001 From: Ehab Younes Date: Wed, 15 Oct 2025 12:20:47 +0300 Subject: [PATCH 03/10] Fix name --- .github/workflows/pre-release.yaml | 3 ++- .github/workflows/release.yaml | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml index d2b9b6e3..e772a91b 100644 --- a/.github/workflows/pre-release.yaml +++ b/.github/workflows/pre-release.yaml @@ -47,7 +47,8 @@ jobs: - name: Setup package path id: setup run: | - PACKAGE_NAME="${{ github.event.repository.name }}-pre-${{ steps.version.outputs.version }}.vsix" + EXTENSION_NAME=$(node -e "console.log(require('./package.json').name)") + PACKAGE_NAME="${EXTENSION_NAME}-${{ steps.version.outputs.version }}-pre.vsix" echo "packageName=$PACKAGE_NAME" >> $GITHUB_OUTPUT - name: Package extension diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e07a3eed..36bfcc96 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -39,7 +39,8 @@ jobs: - name: Setup package path id: setup run: | - PACKAGE_NAME="${{ github.event.repository.name }}-${{ steps.version.outputs.version }}.vsix" + EXTENSION_NAME=$(node -e "console.log(require('./package.json').name)") + PACKAGE_NAME="${EXTENSION_NAME}-${{ steps.version.outputs.version }}.vsix" echo "packageName=$PACKAGE_NAME" >> $GITHUB_OUTPUT - name: Package extension @@ -85,5 +86,4 @@ jobs: prerelease: false draft: true title: "Release v${{ needs.package.outputs.version }}" - files: | - ${{ needs.package.outputs.packageName }} + files: ${{ needs.package.outputs.packageName }} From 2cff82f95d6bfd063e8c7594cf3989e07ed8db61 Mon Sep 17 00:00:00 2001 From: Ehab Younes Date: Wed, 15 Oct 2025 13:46:37 +0300 Subject: [PATCH 04/10] Package VSIX on every CI run and merge to main * Publish pre-release on tag push "v*-pre" --- .github/workflows/ci.yaml | 55 +++++++++++++++++ .github/workflows/pre-release.yaml | 75 +++++------------------- .github/workflows/publish-extension.yaml | 21 +++++++ .github/workflows/release.yaml | 26 +------- 4 files changed, 92 insertions(+), 85 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 87a03723..029225aa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -41,3 +41,58 @@ jobs: - run: yarn - run: yarn test:ci + + package: + name: Package + runs-on: ubuntu-22.04 + needs: [lint, test] + outputs: + packageName: ${{ steps.setup.outputs.packageName }} + version: ${{ steps.version.outputs.version }} + steps: + - uses: actions/checkout@v5 + + - uses: actions/setup-node@v5 + with: + node-version: "22" + + - name: Install dependencies + run: | + yarn + npm install -g @vscode/vsce + + - name: Get version from package.json + id: version + run: | + VERSION=$(node -e "console.log(require('./package.json').version)") + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Version: $VERSION" + + - name: Setup package path + id: setup + run: | + EXTENSION_NAME=$(node -e "console.log(require('./package.json').name)") + # Add commit SHA for CI builds + SHORT_SHA=$(git rev-parse --short HEAD) + PACKAGE_NAME="${EXTENSION_NAME}-${{ steps.version.outputs.version }}-${SHORT_SHA}.vsix" + echo "packageName=$PACKAGE_NAME" >> $GITHUB_OUTPUT + + - name: Package extension + run: vsce package --out "${{ steps.setup.outputs.packageName }}" + + - name: Upload artifact (PR) + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: extension-pr-${{ github.event.pull_request.number }} + path: ${{ steps.setup.outputs.packageName }} + if-no-files-found: error + retention-days: 7 + + - name: Upload artifact (main) + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: actions/upload-artifact@v4 + with: + name: extension-main-${{ github.sha }} + path: ${{ steps.setup.outputs.packageName }} + if-no-files-found: error diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml index e772a91b..b4909301 100644 --- a/.github/workflows/pre-release.yaml +++ b/.github/workflows/pre-release.yaml @@ -1,8 +1,13 @@ name: Pre-Release on: push: - branches: - - main + tags: + - "v*-pre" + +permissions: + # Required to publish a release + contents: write + pull-requests: read jobs: package: @@ -23,26 +28,14 @@ jobs: yarn npm install -g @vscode/vsce - - name: Generate pre-release version + - name: Extract version from tag id: version run: | - BASE_VERSION=$(node -e "console.log(require('./package.json').version)") - IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION" - - PRE_MINOR=$((MINOR + 1)) - - DATE_PREFIX=$(date +%Y%m%d) - BUILD_SUFFIX=$(printf "%02d" $((GITHUB_RUN_NUMBER % 100))) - DATE_PATCH="${DATE_PREFIX}${BUILD_SUFFIX}" - - # Final version: MAJOR.(MINOR+1).YYYYMMDDNN - NUMERIC_VERSION="${MAJOR}.${PRE_MINOR}.${DATE_PATCH}" - - echo "version=$NUMERIC_VERSION" >> $GITHUB_OUTPUT - echo "Pre-release version: $NUMERIC_VERSION" - - # Update package.json with the numeric version - npm version $NUMERIC_VERSION --no-git-tag-version + # Extract version from tag (remove 'v' prefix and '-pre' suffix) + TAG_NAME=${GITHUB_REF#refs/tags/v} + VERSION=${TAG_NAME%-pre} + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Pre-release version: $VERSION" - name: Setup package path id: setup @@ -60,10 +53,9 @@ jobs: name: extension-${{ steps.version.outputs.version }} path: ${{ steps.setup.outputs.packageName }} if-no-files-found: error - retention-days: 7 publish: - name: Publish to Marketplaces + name: Publish Extension and Create Pre-Release needs: package uses: ./.github/workflows/publish-extension.yaml with: @@ -73,42 +65,3 @@ jobs: secrets: VSCE_PAT: ${{ secrets.VSCE_PAT }} OVSX_PAT: ${{ secrets.OVSX_PAT }} - - publishGH: - name: Update Latest Pre-Release - runs-on: ubuntu-22.04 - needs: package - permissions: - contents: write - steps: - - uses: actions/checkout@v5 - - - uses: actions/download-artifact@v5 - with: - name: extension-${{ needs.package.outputs.version }} - - - name: Update Rolling Release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - # Delete old release and tag - gh release delete latest-pre-release --cleanup-tag -y || true - - # Create new release with heredoc for formatting - cat << EOF | gh release create latest-pre-release \ - --target ${{ github.sha }} \ - --title "Latest Pre-Release Build" \ - --notes-file - \ - --prerelease \ - --latest=false \ - ${{ needs.package.outputs.packageName }} - ## Latest Pre-Release: v${{ needs.package.outputs.version }} - - **Build:** #${{ github.run_number }} | **Commit:** ${{ github.sha }} - - ## Changes - ${{ github.event.head_commit.message }} - - --- - *This release is automatically updated with each push to main. The tag \`latest-pre-release\` always points to the most recent build.* - EOF diff --git a/.github/workflows/publish-extension.yaml b/.github/workflows/publish-extension.yaml index 152bdb96..37295c9d 100644 --- a/.github/workflows/publish-extension.yaml +++ b/.github/workflows/publish-extension.yaml @@ -74,3 +74,24 @@ jobs: else ovsx publish "./${{ inputs.packageName }}" -p ${{ secrets.OVSX_PAT }} fi + + publishGH: + name: Create GitHub ${{ inputs.isPreRelease && 'Pre-' || '' }}Release + runs-on: ubuntu-22.04 + permissions: + contents: write + steps: + - uses: actions/checkout@v5 + + - uses: actions/download-artifact@v5 + with: + name: extension-${{ inputs.version }} + + - name: Create ${{ inputs.isPreRelease && 'Pre-' || '' }}Release + uses: marvinpinto/action-automatic-releases@latest + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + prerelease: ${{ inputs.isPreRelease }} + draft: true + title: "${{ inputs.isPreRelease && 'Pre-' || '' }}Release v${{ inputs.version }}" + files: ${{ inputs.packageName }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 36bfcc96..8790e9e6 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,6 +3,7 @@ on: push: tags: - "v*" + - "!v*-pre" permissions: # Required to publish a release @@ -52,10 +53,9 @@ jobs: name: extension-${{ steps.version.outputs.version }} path: ${{ steps.setup.outputs.packageName }} if-no-files-found: error - retention-days: 30 publish: - name: Publish to Marketplaces + name: Publish Extension and Create Release needs: package uses: ./.github/workflows/publish-extension.yaml with: @@ -65,25 +65,3 @@ jobs: secrets: VSCE_PAT: ${{ secrets.VSCE_PAT }} OVSX_PAT: ${{ secrets.OVSX_PAT }} - - publishGH: - name: Create GitHub Release - runs-on: ubuntu-22.04 - needs: package - permissions: - contents: write - steps: - - uses: actions/checkout@v5 - - - uses: actions/download-artifact@v5 - with: - name: extension-${{ needs.package.outputs.version }} - - - name: Create Release - uses: marvinpinto/action-automatic-releases@latest - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - prerelease: false - draft: true - title: "Release v${{ needs.package.outputs.version }}" - files: ${{ needs.package.outputs.packageName }} From 90fc804b8bd41a6b3c24051af3caef12c1c1624e Mon Sep 17 00:00:00 2001 From: Ehab Younes Date: Thu, 16 Oct 2025 15:14:21 +0300 Subject: [PATCH 05/10] Review comments --- .github/workflows/ci.yaml | 3 --- .github/workflows/pre-release.yaml | 23 ++++++++++++++++++----- .github/workflows/release.yaml | 23 ++++++++++++++++++----- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 029225aa..9fca8155 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -46,9 +46,6 @@ jobs: name: Package runs-on: ubuntu-22.04 needs: [lint, test] - outputs: - packageName: ${{ steps.setup.outputs.packageName }} - version: ${{ steps.version.outputs.version }} steps: - uses: actions/checkout@v5 diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml index b4909301..169880ef 100644 --- a/.github/workflows/pre-release.yaml +++ b/.github/workflows/pre-release.yaml @@ -23,11 +23,6 @@ jobs: with: node-version: "22" - - name: Install dependencies - run: | - yarn - npm install -g @vscode/vsce - - name: Extract version from tag id: version run: | @@ -37,6 +32,24 @@ jobs: echo "version=$VERSION" >> $GITHUB_OUTPUT echo "Pre-release version: $VERSION" + - name: Validate version matches package.json + run: | + TAG_VERSION="${{ steps.version.outputs.version }}" + PACKAGE_VERSION=$(node -e "console.log(require('./package.json').version)") + + if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then + echo "Error: Tag version ($TAG_VERSION) does not match package.json version ($PACKAGE_VERSION)" + echo "Please ensure the tag version matches the version in package.json" + exit 1 + fi + + echo "Version validation successful: $TAG_VERSION" + + - name: Install dependencies + run: | + yarn + npm install -g @vscode/vsce + - name: Setup package path id: setup run: | diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8790e9e6..60e5905f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -24,11 +24,6 @@ jobs: with: node-version: "22" - - name: Install dependencies - run: | - yarn - npm install -g @vscode/vsce - - name: Extract version from tag id: version run: | @@ -37,6 +32,24 @@ jobs: echo "version=$VERSION" >> $GITHUB_OUTPUT echo "Release version: $VERSION" + - name: Validate version matches package.json + run: | + TAG_VERSION="${{ steps.version.outputs.version }}" + PACKAGE_VERSION=$(node -e "console.log(require('./package.json').version)") + + if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then + echo "Error: Tag version ($TAG_VERSION) does not match package.json version ($PACKAGE_VERSION)" + echo "Please ensure the tag version matches the version in package.json" + exit 1 + fi + + echo "Version validation successful: $TAG_VERSION" + + - name: Install dependencies + run: | + yarn + npm install -g @vscode/vsce + - name: Setup package path id: setup run: | From 0e34f4ddc23ea963928fd8aea035463ac824da98 Mon Sep 17 00:00:00 2001 From: Ehab Younes Date: Mon, 20 Oct 2025 12:08:34 +0300 Subject: [PATCH 06/10] Construct package name from version and pre-release flag in publish-extension.yaml --- .github/workflows/ci.yaml | 4 +- .github/workflows/pre-release.yaml | 2 - .github/workflows/publish-extension.yaml | 47 ++++++++++++++++-------- .github/workflows/release.yaml | 2 - 4 files changed, 35 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9fca8155..96941245 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -name: ci +name: CI on: push: @@ -11,6 +11,7 @@ on: jobs: lint: + name: Lint runs-on: ubuntu-22.04 steps: @@ -29,6 +30,7 @@ jobs: - run: yarn build test: + name: Test runs-on: ubuntu-22.04 steps: diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml index 169880ef..5c24bb3c 100644 --- a/.github/workflows/pre-release.yaml +++ b/.github/workflows/pre-release.yaml @@ -14,7 +14,6 @@ jobs: name: Package runs-on: ubuntu-22.04 outputs: - packageName: ${{ steps.setup.outputs.packageName }} version: ${{ steps.version.outputs.version }} steps: - uses: actions/checkout@v5 @@ -73,7 +72,6 @@ jobs: uses: ./.github/workflows/publish-extension.yaml with: version: ${{ needs.package.outputs.version }} - packageName: ${{ needs.package.outputs.packageName }} isPreRelease: true secrets: VSCE_PAT: ${{ secrets.VSCE_PAT }} diff --git a/.github/workflows/publish-extension.yaml b/.github/workflows/publish-extension.yaml index 37295c9d..645c7453 100644 --- a/.github/workflows/publish-extension.yaml +++ b/.github/workflows/publish-extension.yaml @@ -7,10 +7,6 @@ on: required: true type: string description: "Version to publish" - packageName: - required: true - type: string - description: "Package filename" isPreRelease: required: false type: boolean @@ -23,12 +19,35 @@ on: required: true jobs: - publishMS: - name: Publish to VS Marketplace + setup: + name: Setup Package Name runs-on: ubuntu-22.04 + outputs: + packageName: ${{ steps.package.outputs.packageName }} steps: - uses: actions/checkout@v5 + - uses: actions/setup-node@v5 + with: + node-version: "22" + + - name: Construct package name + id: package + run: | + EXTENSION_NAME=$(node -e "console.log(require('./package.json').name)") + if [ "${{ inputs.isPreRelease }}" = "true" ]; then + PACKAGE_NAME="${EXTENSION_NAME}-${{ inputs.version }}-pre.vsix" + else + PACKAGE_NAME="${EXTENSION_NAME}-${{ inputs.version }}.vsix" + fi + echo "packageName=$PACKAGE_NAME" >> $GITHUB_OUTPUT + echo "Package name: $PACKAGE_NAME" + + publishMS: + name: Publish to VS Marketplace + needs: setup + runs-on: ubuntu-22.04 + steps: - uses: actions/setup-node@v5 with: node-version: "22" @@ -44,17 +63,16 @@ jobs: run: | echo "Publishing version ${{ inputs.version }} to VS Marketplace" if [ "${{ inputs.isPreRelease }}" = "true" ]; then - vsce publish --pre-release --packagePath "./${{ inputs.packageName }}" -p ${{ secrets.VSCE_PAT }} + vsce publish --pre-release --packagePath "./${{ needs.setup.outputs.packageName }}" -p ${{ secrets.VSCE_PAT }} else - vsce publish --packagePath "./${{ inputs.packageName }}" -p ${{ secrets.VSCE_PAT }} + vsce publish --packagePath "./${{ needs.setup.outputs.packageName }}" -p ${{ secrets.VSCE_PAT }} fi publishOVSX: name: Publish to Open VSX + needs: setup runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v5 - - uses: actions/setup-node@v5 with: node-version: "22" @@ -70,19 +88,18 @@ jobs: run: | echo "Publishing version ${{ inputs.version }} to Open VSX" if [ "${{ inputs.isPreRelease }}" = "true" ]; then - ovsx publish "./${{ inputs.packageName }}" --pre-release -p ${{ secrets.OVSX_PAT }} + ovsx publish "./${{ needs.setup.outputs.packageName }}" --pre-release -p ${{ secrets.OVSX_PAT }} else - ovsx publish "./${{ inputs.packageName }}" -p ${{ secrets.OVSX_PAT }} + ovsx publish "./${{ needs.setup.outputs.packageName }}" -p ${{ secrets.OVSX_PAT }} fi publishGH: name: Create GitHub ${{ inputs.isPreRelease && 'Pre-' || '' }}Release + needs: setup runs-on: ubuntu-22.04 permissions: contents: write steps: - - uses: actions/checkout@v5 - - uses: actions/download-artifact@v5 with: name: extension-${{ inputs.version }} @@ -94,4 +111,4 @@ jobs: prerelease: ${{ inputs.isPreRelease }} draft: true title: "${{ inputs.isPreRelease && 'Pre-' || '' }}Release v${{ inputs.version }}" - files: ${{ inputs.packageName }} + files: ${{ needs.setup.outputs.packageName }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 60e5905f..51d9ff97 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -15,7 +15,6 @@ jobs: name: Package runs-on: ubuntu-22.04 outputs: - packageName: ${{ steps.setup.outputs.packageName }} version: ${{ steps.version.outputs.version }} steps: - uses: actions/checkout@v5 @@ -73,7 +72,6 @@ jobs: uses: ./.github/workflows/publish-extension.yaml with: version: ${{ needs.package.outputs.version }} - packageName: ${{ needs.package.outputs.packageName }} isPreRelease: false secrets: VSCE_PAT: ${{ secrets.VSCE_PAT }} From fe1bb0f5a209e5c798fbc299009298a7f40ede79 Mon Sep 17 00:00:00 2001 From: Ehab Younes Date: Mon, 20 Oct 2025 12:16:41 +0300 Subject: [PATCH 07/10] Remove permissions on publishGH job --- .github/workflows/publish-extension.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/publish-extension.yaml b/.github/workflows/publish-extension.yaml index 645c7453..ee175a08 100644 --- a/.github/workflows/publish-extension.yaml +++ b/.github/workflows/publish-extension.yaml @@ -97,8 +97,6 @@ jobs: name: Create GitHub ${{ inputs.isPreRelease && 'Pre-' || '' }}Release needs: setup runs-on: ubuntu-22.04 - permissions: - contents: write steps: - uses: actions/download-artifact@v5 with: From da5d5c228db8c72982906c3e92d06f58da43a2ba Mon Sep 17 00:00:00 2001 From: Ehab Younes Date: Wed, 22 Oct 2025 11:22:47 +0300 Subject: [PATCH 08/10] Update actions/setup-node to v6 --- .github/workflows/ci.yaml | 2 +- .github/workflows/pre-release.yaml | 2 +- .github/workflows/publish-extension.yaml | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 96941245..912e9a1c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -51,7 +51,7 @@ jobs: steps: - uses: actions/checkout@v5 - - uses: actions/setup-node@v5 + - uses: actions/setup-node@v6 with: node-version: "22" diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml index 5c24bb3c..61761700 100644 --- a/.github/workflows/pre-release.yaml +++ b/.github/workflows/pre-release.yaml @@ -18,7 +18,7 @@ jobs: steps: - uses: actions/checkout@v5 - - uses: actions/setup-node@v5 + - uses: actions/setup-node@v6 with: node-version: "22" diff --git a/.github/workflows/publish-extension.yaml b/.github/workflows/publish-extension.yaml index ee175a08..35f6fff4 100644 --- a/.github/workflows/publish-extension.yaml +++ b/.github/workflows/publish-extension.yaml @@ -27,7 +27,7 @@ jobs: steps: - uses: actions/checkout@v5 - - uses: actions/setup-node@v5 + - uses: actions/setup-node@v6 with: node-version: "22" @@ -48,7 +48,7 @@ jobs: needs: setup runs-on: ubuntu-22.04 steps: - - uses: actions/setup-node@v5 + - uses: actions/setup-node@v6 with: node-version: "22" @@ -73,7 +73,7 @@ jobs: needs: setup runs-on: ubuntu-22.04 steps: - - uses: actions/setup-node@v5 + - uses: actions/setup-node@v6 with: node-version: "22" From 0b583b1961518d28e02d6a7ec7c8559fb79c4468 Mon Sep 17 00:00:00 2001 From: Ehab Younes Date: Thu, 23 Oct 2025 02:23:56 +0300 Subject: [PATCH 09/10] Add secret check before publishing --- .github/workflows/publish-extension.yaml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-extension.yaml b/.github/workflows/publish-extension.yaml index 35f6fff4..cf93d6ba 100644 --- a/.github/workflows/publish-extension.yaml +++ b/.github/workflows/publish-extension.yaml @@ -14,16 +14,18 @@ on: description: "Whether this is a pre-release" secrets: VSCE_PAT: - required: true + required: false OVSX_PAT: - required: true + required: false jobs: setup: - name: Setup Package Name + name: Setup runs-on: ubuntu-22.04 outputs: packageName: ${{ steps.package.outputs.packageName }} + hasVscePat: ${{ steps.check-secrets.outputs.hasVscePat }} + hasOvsxPat: ${{ steps.check-secrets.outputs.hasOvsxPat }} steps: - uses: actions/checkout@v5 @@ -43,10 +45,20 @@ jobs: echo "packageName=$PACKAGE_NAME" >> $GITHUB_OUTPUT echo "Package name: $PACKAGE_NAME" + - name: Check secrets + id: check-secrets + env: + VSCE_PAT: ${{ secrets.VSCE_PAT }} + OVSX_PAT: ${{ secrets.OVSX_PAT }} + run: | + echo "hasVscePat=$([ -n "$VSCE_PAT" ] && echo true || echo false)" >> $GITHUB_OUTPUT + echo "hasOvsxPat=$([ -n "$OVSX_PAT" ] && echo true || echo false)" >> $GITHUB_OUTPUT + publishMS: name: Publish to VS Marketplace needs: setup runs-on: ubuntu-22.04 + if: ${{ needs.setup.outputs.hasVscePat == 'true' }} steps: - uses: actions/setup-node@v6 with: @@ -72,6 +84,7 @@ jobs: name: Publish to Open VSX needs: setup runs-on: ubuntu-22.04 + if: ${{ needs.setup.outputs.hasOvsxPat == 'true' }} steps: - uses: actions/setup-node@v6 with: From 25cd97251f04ad39c75b083b2db356dae04817c7 Mon Sep 17 00:00:00 2001 From: Ehab Younes Date: Thu, 23 Oct 2025 02:30:16 +0300 Subject: [PATCH 10/10] Speed up dependency installation in CI --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 912e9a1c..a878f9f2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,6 +20,7 @@ jobs: - uses: actions/setup-node@v6 with: node-version: "22" + cache: "yarn" - run: yarn @@ -39,6 +40,7 @@ jobs: - uses: actions/setup-node@v6 with: node-version: "22" + cache: "yarn" - run: yarn @@ -54,6 +56,7 @@ jobs: - uses: actions/setup-node@v6 with: node-version: "22" + cache: "yarn" - name: Install dependencies run: |