Create GitHub Release for Extension Package #7
This file contains 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
name: Create GitHub Release for Extension Package | |
on: | |
workflow_dispatch: | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
- name: Install dependencies | |
run: npm install | |
- name: Build VSIX Package | |
run: npx vsce package | |
- name: Create release | |
id: create_release | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const packageVersion = require('./package.json').version; | |
const response = await github.rest.repos.createRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
tag_name: `v${packageVersion}`, | |
name: `Release ${packageVersion}`, | |
body: `Generating release for version ${packageVersion}` | |
}); | |
return response.data.id; | |
- name: Attach VSIX package to release | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require('fs'); | |
const packageJson = require('./package.json'); | |
const packageName = packageJson.name; | |
const packageVersion = packageJson.version; | |
const vsixFilename = `${packageName}-${packageVersion}.vsix`; | |
await github.rest.repos.uploadReleaseAsset({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: ${{ steps.create_release.outputs.result }}, | |
name: vsixFilename, | |
data: fs.readFileSync(vsixFilename) | |
}); |