|
| 1 | +name: VSC VSIX Publish |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + extension-name: |
| 7 | + description: 'The extension name (e.g., VSC-MCPServer)' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + display-name: |
| 11 | + description: 'Human readable display name (e.g., "VSC as MCP")' |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + marketplace-id: |
| 15 | + description: 'VS Code Marketplace ID (e.g., CodingWithCalvin.VSC-MCPServer)' |
| 16 | + required: true |
| 17 | + type: string |
| 18 | + description: |
| 19 | + description: 'Short description for social media embeds' |
| 20 | + required: true |
| 21 | + type: string |
| 22 | + hashtags: |
| 23 | + description: 'Additional hashtags for social posts (optional)' |
| 24 | + required: false |
| 25 | + type: string |
| 26 | + default: '' |
| 27 | + node-version: |
| 28 | + description: 'Node.js version to use' |
| 29 | + required: false |
| 30 | + type: string |
| 31 | + default: '20' |
| 32 | + run-tests: |
| 33 | + description: 'Whether to run tests before publishing' |
| 34 | + required: false |
| 35 | + type: boolean |
| 36 | + default: true |
| 37 | + secrets: |
| 38 | + VS_PAT: |
| 39 | + description: 'VS Code Marketplace PAT' |
| 40 | + required: true |
| 41 | + BLUESKY_USERNAME: |
| 42 | + description: 'BlueSky username' |
| 43 | + required: true |
| 44 | + BLUESKY_APP_PASSWORD: |
| 45 | + description: 'BlueSky app password' |
| 46 | + required: true |
| 47 | + X_CONSUMER_KEY: |
| 48 | + description: 'X API consumer key' |
| 49 | + required: true |
| 50 | + X_CONSUMER_KEY_SECRET: |
| 51 | + description: 'X API consumer key secret' |
| 52 | + required: true |
| 53 | + X_ACCESS_TOKEN: |
| 54 | + description: 'X API access token' |
| 55 | + required: true |
| 56 | + X_ACCESS_TOKEN_SECRET: |
| 57 | + description: 'X API access token secret' |
| 58 | + required: true |
| 59 | + |
| 60 | +env: |
| 61 | + VSIX_FILE: CodingWithCalvin.${{ inputs.extension-name }}.vsix |
| 62 | + |
| 63 | +jobs: |
| 64 | + publish: |
| 65 | + runs-on: ubuntu-latest |
| 66 | + permissions: |
| 67 | + contents: write |
| 68 | + outputs: |
| 69 | + version: ${{ steps.version.outputs.version }} |
| 70 | + steps: |
| 71 | + - name: Checkout code |
| 72 | + uses: actions/checkout@v4 |
| 73 | + with: |
| 74 | + fetch-depth: 0 |
| 75 | + |
| 76 | + - name: Setup Node.js |
| 77 | + uses: actions/setup-node@v4 |
| 78 | + with: |
| 79 | + node-version: ${{ inputs.node-version }} |
| 80 | + cache: 'npm' |
| 81 | + |
| 82 | + - name: Install dependencies |
| 83 | + run: npm ci |
| 84 | + |
| 85 | + - name: Run tests |
| 86 | + if: inputs.run-tests |
| 87 | + run: npm run test |
| 88 | + |
| 89 | + - name: Build extension |
| 90 | + run: npm run build |
| 91 | + |
| 92 | + - name: Set version |
| 93 | + id: version |
| 94 | + run: | |
| 95 | + VERSION=$(date +'%Y.%m%d').${{ github.run_number }} |
| 96 | + npm version $VERSION --no-git-tag-version --allow-same-version |
| 97 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 98 | +
|
| 99 | + - name: Package VSIX |
| 100 | + run: npx @vscode/vsce package -o ${{ env.VSIX_FILE }} |
| 101 | + |
| 102 | + - name: Publish to VS Code Marketplace |
| 103 | + run: npx @vscode/vsce publish -p ${{ secrets.VS_PAT }} |
| 104 | + |
| 105 | + - name: Upload VSIX artifact |
| 106 | + uses: actions/upload-artifact@v4 |
| 107 | + with: |
| 108 | + name: vsix |
| 109 | + path: ${{ env.VSIX_FILE }} |
| 110 | + |
| 111 | + changelog: |
| 112 | + needs: publish |
| 113 | + uses: CodingWithCalvin/.github/.github/workflows/generate-changelog.yml@main |
| 114 | + secrets: inherit |
| 115 | + |
| 116 | + release: |
| 117 | + needs: [publish, changelog] |
| 118 | + runs-on: ubuntu-latest |
| 119 | + permissions: |
| 120 | + contents: write |
| 121 | + steps: |
| 122 | + - name: Download VSIX artifact |
| 123 | + uses: actions/download-artifact@v4 |
| 124 | + with: |
| 125 | + name: vsix |
| 126 | + |
| 127 | + - name: Create GitHub Release |
| 128 | + uses: softprops/action-gh-release@v1 |
| 129 | + with: |
| 130 | + tag_name: v${{ needs.publish.outputs.version }} |
| 131 | + name: v${{ needs.publish.outputs.version }} |
| 132 | + body: ${{ needs.changelog.outputs.changelog }} |
| 133 | + files: CodingWithCalvin.${{ inputs.extension-name }}.vsix |
| 134 | + |
| 135 | + bluesky: |
| 136 | + needs: [publish, release] |
| 137 | + uses: CodingWithCalvin/.github/.github/workflows/bluesky-post.yml@main |
| 138 | + with: |
| 139 | + post_text: | |
| 140 | + 🚀 ${{ inputs.display-name }} v${{ needs.publish.outputs.version }} has been released! |
| 141 | +
|
| 142 | + [GitHub Release](https://github.com/${{ github.repository }}/releases/tag/v${{ needs.publish.outputs.version }}) |
| 143 | + [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=${{ inputs.marketplace-id }}) |
| 144 | +
|
| 145 | + #vscode ${{ inputs.hashtags }} |
| 146 | + embed_title: "${{ inputs.display-name }} v${{ needs.publish.outputs.version }}" |
| 147 | + embed_description: ${{ inputs.description }} |
| 148 | + secrets: |
| 149 | + BLUESKY_USERNAME: ${{ secrets.BLUESKY_USERNAME }} |
| 150 | + BLUESKY_APP_PASSWORD: ${{ secrets.BLUESKY_APP_PASSWORD }} |
| 151 | + |
| 152 | + x: |
| 153 | + needs: [publish, release] |
| 154 | + uses: CodingWithCalvin/.github/.github/workflows/x-post.yml@main |
| 155 | + with: |
| 156 | + post_text: | |
| 157 | + 🚀 ${{ inputs.display-name }} v${{ needs.publish.outputs.version }} has been released! |
| 158 | +
|
| 159 | + GitHub Release: https://github.com/${{ github.repository }}/releases/tag/v${{ needs.publish.outputs.version }} |
| 160 | + VS Code Marketplace: https://marketplace.visualstudio.com/items?itemName=${{ inputs.marketplace-id }} |
| 161 | +
|
| 162 | + #vscode ${{ inputs.hashtags }} |
| 163 | + secrets: |
| 164 | + X_CONSUMER_KEY: ${{ secrets.X_CONSUMER_KEY }} |
| 165 | + X_CONSUMER_KEY_SECRET: ${{ secrets.X_CONSUMER_KEY_SECRET }} |
| 166 | + X_ACCESS_TOKEN: ${{ secrets.X_ACCESS_TOKEN }} |
| 167 | + X_ACCESS_TOKEN_SECRET: ${{ secrets.X_ACCESS_TOKEN_SECRET }} |
0 commit comments