- Notifications
You must be signed in to change notification settings - Fork35
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
10 commits Select commitHold shift + click to select a range
464a0b6 Automatically publish extension to marketplaces
EhabY8632cd7 Unified the extension publishing logic
EhabYc6baaf1 Fix name
EhabY2cff82f Package VSIX on every CI run and merge to main
EhabY90fc804 Review comments
EhabY0e34f4d Construct package name from version and pre-release flag in publish-e…
EhabYfe1bb0f Remove permissions on publishGH job
EhabYda5d5c2 Update actions/setup-node to v6
EhabY0b583b1 Add secret check before publishing
EhabY25cd972 Speed up dependency installation in CI
EhabYFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
59 changes: 58 additions & 1 deletion.github/workflows/ci.yaml
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,4 +1,4 @@ | ||
| name:CI | ||
| on: | ||
| push: | ||
| @@ -11,6 +11,7 @@ on: | ||
| jobs: | ||
| lint: | ||
| name: Lint | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| @@ -19,6 +20,7 @@ jobs: | ||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: "22" | ||
| cache: "yarn" | ||
| - run: yarn | ||
| @@ -29,6 +31,7 @@ jobs: | ||
| - run: yarn build | ||
| test: | ||
| name: Test | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| @@ -37,7 +40,61 @@ jobs: | ||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: "22" | ||
| cache: "yarn" | ||
| - run: yarn | ||
| - run: yarn test:ci | ||
| package: | ||
| name: Package | ||
| runs-on: ubuntu-22.04 | ||
| needs: [lint, test] | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: "22" | ||
| cache: "yarn" | ||
| - 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 }} | ||
EhabY marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| path: ${{ steps.setup.outputs.packageName }} | ||
| if-no-files-found: error | ||
78 changes: 78 additions & 0 deletions.github/workflows/pre-release.yaml
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 resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| - 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 resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| with: | ||
| version: ${{ needs.package.outputs.version }} | ||
| isPreRelease: true | ||
| secrets: | ||
| VSCE_PAT: ${{ secrets.VSCE_PAT }} | ||
| OVSX_PAT: ${{ secrets.OVSX_PAT }} | ||
125 changes: 125 additions & 0 deletions.github/workflows/publish-extension.yaml
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 resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| 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 }} | ||
67 changes: 56 additions & 11 deletions.github/workflows/release.yaml
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*" | ||
| - "!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) | ||
| 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" | ||
| - 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 }}.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-${{ 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.