Updated GitHub Actions workflow for release creation #1
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
| name: Build VSIX and Create Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build-and-release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # required to create releases & upload assets | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| # If vsce is a devDependency in package.json this is enough | |
| - name: Package VS Code extension | |
| run: npx vsce package | |
| # If your package command is different, adjust: | |
| # run: npm run package | |
| - name: Get VSIX file name | |
| id: vsix | |
| run: | | |
| FILE=$(ls *.vsix | head -n 1) | |
| echo "file=$FILE" >> $GITHUB_OUTPUT | |
| - name: Compute release tag and name | |
| id: version | |
| run: | | |
| # Extract version from package.json | |
| VERSION=$(node -p "require('./package.json').version") | |
| TAG="v$VERSION" | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| echo "name=Release $TAG" >> $GITHUB_OUTPUT | |
| - name: Create or update GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.tag }} | |
| name: ${{ steps.version.outputs.name }} | |
| draft: false | |
| prerelease: false | |
| files: ${{ steps.vsix.outputs.file }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |