- 
                Notifications
    
You must be signed in to change notification settings  - Fork 35
 
Automatically publish extension and add pre-release version #624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            10 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      464a0b6
              
                Automatically publish extension to marketplaces
              
              
                EhabY 8632cd7
              
                Unified the extension publishing logic
              
              
                EhabY c6baaf1
              
                Fix name
              
              
                EhabY 2cff82f
              
                Package VSIX on every CI run and merge to main
              
              
                EhabY 90fc804
              
                Review comments
              
              
                EhabY 0e34f4d
              
                Construct package name from version and pre-release flag in publish-e…
              
              
                EhabY fe1bb0f
              
                Remove permissions on publishGH job
              
              
                EhabY da5d5c2
              
                Update actions/setup-node to v6
              
              
                EhabY 0b583b1
              
                Add secret check before publishing
              
              
                EhabY 25cd972
              
                Speed up dependency installation in CI
              
              
                EhabY File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| name: Pre-Release | ||
| on: | ||
| push: | ||
| tags: | ||
| - "v*-pre" | ||
| 
     | 
||
| permissions: | ||
| # Required to publish a release | ||
| contents: write | ||
| pull-requests: read | ||
| 
     | 
||
| jobs: | ||
| package: | ||
| name: Package | ||
| runs-on: ubuntu-22.04 | ||
| outputs: | ||
| version: ${{ steps.version.outputs.version }} | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| 
     | 
||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: "22" | ||
| 
     | 
||
| - name: Extract version from tag | ||
| id: version | ||
| run: | | ||
| # 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" | ||
                
      
                  EhabY marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| 
     | 
||
| - 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: | | ||
| 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 | ||
| run: vsce package --pre-release --out "${{ steps.setup.outputs.packageName }}" | ||
| 
     | 
||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: extension-${{ steps.version.outputs.version }} | ||
| path: ${{ steps.setup.outputs.packageName }} | ||
| if-no-files-found: error | ||
| 
     | 
||
| publish: | ||
| name: Publish Extension and Create Pre-Release | ||
| needs: package | ||
| uses: ./.github/workflows/publish-extension.yaml | ||
                
      
                  EhabY marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| with: | ||
| version: ${{ needs.package.outputs.version }} | ||
| isPreRelease: true | ||
| secrets: | ||
| VSCE_PAT: ${{ secrets.VSCE_PAT }} | ||
| OVSX_PAT: ${{ secrets.OVSX_PAT }} | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| name: Publish Extension | ||
| 
     | 
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| version: | ||
| required: true | ||
| type: string | ||
| description: "Version to publish" | ||
| isPreRelease: | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| description: "Whether this is a pre-release" | ||
| secrets: | ||
| VSCE_PAT: | ||
| required: false | ||
| OVSX_PAT: | ||
| required: false | ||
| 
     | 
||
| jobs: | ||
| setup: | ||
| 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 | ||
| 
     | 
||
| - uses: actions/setup-node@v6 | ||
| 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" | ||
| 
     | 
||
| - 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: | ||
| 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 "./${{ needs.setup.outputs.packageName }}" -p ${{ secrets.VSCE_PAT }} | ||
| else | ||
| 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 | ||
| if: ${{ needs.setup.outputs.hasOvsxPat == 'true' }} | ||
| steps: | ||
| - uses: actions/setup-node@v6 | ||
| 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 "./${{ needs.setup.outputs.packageName }}" --pre-release -p ${{ secrets.OVSX_PAT }} | ||
| else | ||
| ovsx publish "./${{ needs.setup.outputs.packageName }}" -p ${{ secrets.OVSX_PAT }} | ||
| fi | ||
| 
     | 
||
| publishGH: | ||
| name: Create GitHub ${{ inputs.isPreRelease && 'Pre-' || '' }}Release | ||
                
      
                  EhabY marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| needs: setup | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - 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: ${{ needs.setup.outputs.packageName }} | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,33 +1,78 @@ | ||
| name: Release | ||
| on: | ||
| push: | ||
| tags: | ||
| - "v*" | ||
| 
     | 
||
| name: release | ||
| - "!v*-pre" | ||
| 
     | 
||
| permissions: | ||
| # Required to publish a release | ||
| contents: write | ||
| pull-requests: "read" | ||
| pull-requests: read | ||
| 
     | 
||
| jobs: | ||
| package: | ||
| name: Package | ||
| runs-on: ubuntu-22.04 | ||
| outputs: | ||
| version: ${{ steps.version.outputs.version }} | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| 
     | 
||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: "22" | ||
| 
     | 
||
| - run: yarn | ||
| - 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: 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" | ||
| 
     | 
||
| - run: npx @vscode/vsce package | ||
| - name: Install dependencies | ||
| run: | | ||
| yarn | ||
| npm install -g @vscode/vsce | ||
| 
     | 
||
| - uses: "marvinpinto/action-automatic-releases@latest" | ||
| - name: Setup package path | ||
| id: setup | ||
| run: | | ||
| 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 | ||
| run: vsce package --out "${{ steps.setup.outputs.packageName }}" | ||
| 
     | 
||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| repo_token: "${{ secrets.GITHUB_TOKEN }}" | ||
| prerelease: false | ||
| draft: true | ||
| files: | | ||
| *.vsix | ||
| name: extension-${{ steps.version.outputs.version }} | ||
| path: ${{ steps.setup.outputs.packageName }} | ||
| if-no-files-found: error | ||
| 
     | 
||
| publish: | ||
| name: Publish Extension and Create Release | ||
| needs: package | ||
| uses: ./.github/workflows/publish-extension.yaml | ||
| with: | ||
| version: ${{ needs.package.outputs.version }} | ||
| isPreRelease: false | ||
| secrets: | ||
| VSCE_PAT: ${{ secrets.VSCE_PAT }} | ||
| OVSX_PAT: ${{ secrets.OVSX_PAT }} | 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.