Skip to content

Added proper release information handling for uploading the vsix #9

Added proper release information handling for uploading the vsix

Added proper release information handling for uploading the vsix #9

name: Build and Release VSIX
on:
push:
branches:
- main
- master
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
outputs:
version: ${{ steps.validate.outputs.newVersion }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install vsce
run: npm install -g @vscode/vsce
- name: Install dependencies
run: |
cd .\anko\
npm install
- name: Determine Version Bump
id: version
run: |
$comment = "${{ github.event.head_commit.message }}"
if ($comment -match "#major") {
echo "bumpType=major" >> $ENV:GITHUB_OUTPUT
} elseif ($comment -match "#minor") {
echo "bumpType=minor" >> $ENV:GITHUB_OUTPUT
} else {
echo "bumpType=patch" >> $ENV:GITHUB_OUTPUT
}
- name: Execute Update Script
id: update
run: |
$DebugInfo = @()
$DebugInfo += "Executing update.ps1 with VersionType=${{ steps.version.outputs.bumpType }}"
$result = pwsh ./scripts/update.ps1 ${{ steps.version.outputs.bumpType }}
echo "version=$result" >> $ENV:GITHUB_OUTPUT
echo "$DebugInfo" >> $ENV:GITHUB_STEP_SUMMARY
shell: pwsh
- name: Validate Version Output
id: validate
run: |
$version = "${{ steps.update.outputs.version }}"
echo "Validating version: $version" >> $ENV:GITHUB_STEP_SUMMARY
if ($version -notmatch "^\d+\.\d+\.\d+$") {
Write-Error "Invalid version format: $version"
exit 1
}
echo "newVersion=$version" >> $ENV:GITHUB_OUTPUT
- name: Build VSIX file
run: |
cd .\anko\
vsce package --allow-missing-repository --out ..\dist\blazium-anko-extension-${{ steps.validate.outputs.newVersion }}.vsix
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: blazium-anko-extension-vsix
path: dist/blazium-anko-extension-${{ steps.validate.outputs.newVersion }}.vsix
release:
needs: build
runs-on: windows-latest
permissions:
contents: write # Grants write permissions for content operations
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: blazium-anko-extension-vsix
- name: Create GitHub Release
id: createRelease
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.build.outputs.version }}
release_name: Blazium Anko Extension v${{ needs.build.outputs.version }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.createRelease.outputs.upload_url }}
asset_path: ${{ github.workspace }}/dist/blazium-anko-extension-${{ needs.build.outputs.version }}.vsix
asset_name: blazium-anko-extension-${{ needs.build.outputs.version }}.vsix
asset_content_type: application/octet-stream