microsoft/hve-core
Publicmirrored fromhttps://github.com/microsoft/hve-coreAvailable
.github/workflows/extension-package.yml
113lines · modecode
| 1 | name: Package Extension |
| 2 | |
| 3 | on: |
| 4 | workflow_call: |
| 5 | inputs: |
| 6 | version: |
| 7 | description: 'Full version to use (e.g., 1.0.0 or empty to use package.json)' |
| 8 | required: false |
| 9 | type: string |
| 10 | default: '' |
| 11 | dev-patch-number: |
| 12 | description: 'Dev patch number to append (creates version like 1.0.0-dev.123)' |
| 13 | required: false |
| 14 | type: string |
| 15 | default: '' |
| 16 | use-changelog: |
| 17 | description: 'Whether to download and use changelog artifact' |
| 18 | required: false |
| 19 | type: boolean |
| 20 | default: false |
| 21 | channel: |
| 22 | description: 'Release channel (Stable or PreRelease) controlling agent maturity filtering' |
| 23 | required: false |
| 24 | type: string |
| 25 | default: 'Stable' |
| 26 | outputs: |
| 27 | version: |
| 28 | description: 'Version that was packaged' |
| 29 | value: ${{ jobs.package.outputs.version }} |
| 30 | vsix-file: |
| 31 | description: 'Path to the packaged VSIX file' |
| 32 | value: ${{ jobs.package.outputs.vsix-file }} |
| 33 | |
| 34 | permissions: |
| 35 | contents: read |
| 36 | |
| 37 | jobs: |
| 38 | package: |
| 39 | runs-on: ubuntu-latest |
| 40 | permissions: |
| 41 | contents: read |
| 42 | outputs: |
| 43 | version: ${{ steps.package.outputs.version }} |
| 44 | vsix-file: ${{ steps.package.outputs.vsix-file }} |
| 45 | steps: |
| 46 | - name: Checkout code |
| 47 | uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4.2.2 |
| 48 | with: |
| 49 | persist-credentials: false |
| 50 | |
| 51 | - name: Setup Node.js |
| 52 | uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v4.1.0 |
| 53 | with: |
| 54 | node-version: '20' |
| 55 | |
| 56 | - name: Install dependencies |
| 57 | run: npm install -g @vscode/vsce@3.7.1 |
| 58 | |
| 59 | - name: Setup PowerShell |
| 60 | shell: pwsh |
| 61 | run: | |
| 62 | Write-Host "PowerShell version: $($PSVersionTable.PSVersion)" |
| 63 | Install-Module -Name PowerShell-Yaml -Force -Scope CurrentUser |
| 64 | |
| 65 | - name: Download changelog artifact |
| 66 | if: inputs.use-changelog |
| 67 | uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 |
| 68 | with: |
| 69 | name: changelog |
| 70 | path: ./ |
| 71 | continue-on-error: true |
| 72 | |
| 73 | - name: Prepare extension resources |
| 74 | id: prepare |
| 75 | shell: pwsh |
| 76 | run: | |
| 77 | $channel = "${{ inputs.channel }}".Trim() |
| 78 | if (-not $channel) { $channel = 'Stable' } |
| 79 | |
| 80 | Write-Host "🔧 Preparing extension for $channel channel..." |
| 81 | ./scripts/extension/Prepare-Extension.ps1 -Channel $channel |
| 82 | |
| 83 | - name: Package extension |
| 84 | id: package |
| 85 | shell: pwsh |
| 86 | run: | |
| 87 | $version = "${{ inputs.version }}".Trim() |
| 88 | $devPatch = "${{ inputs.dev-patch-number }}".Trim() |
| 89 | |
| 90 | Write-Host "📦 Packaging extension..." |
| 91 | |
| 92 | $arguments = @{} |
| 93 | |
| 94 | if ($version) { |
| 95 | $arguments['Version'] = $version |
| 96 | } |
| 97 | |
| 98 | if ($devPatch) { |
| 99 | $arguments['DevPatchNumber'] = $devPatch |
| 100 | } |
| 101 | |
| 102 | if (Test-Path "./CHANGELOG.md") { |
| 103 | $arguments['ChangelogPath'] = "./CHANGELOG.md" |
| 104 | } |
| 105 | |
| 106 | ./scripts/extension/Package-Extension.ps1 @arguments |
| 107 | |
| 108 | - name: Upload VSIX artifact |
| 109 | uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v4.4.3 |
| 110 | with: |
| 111 | name: extension-vsix |
| 112 | path: extension/*.vsix |
| 113 | retention-days: 30 |
| 114 | |