microsoft/hve-core
Publicmirrored fromhttps://github.com/microsoft/hve-coreAvailable
.github/workflows/extension-package.yml
103lines · 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 | outputs: |
| 22 | version: |
| 23 | description: 'Version that was packaged' |
| 24 | value: ${{ jobs.package.outputs.version }} |
| 25 | vsix-file: |
| 26 | description: 'Path to the packaged VSIX file' |
| 27 | value: ${{ jobs.package.outputs.vsix-file }} |
| 28 | |
| 29 | permissions: |
| 30 | contents: read |
| 31 | |
| 32 | jobs: |
| 33 | package: |
| 34 | runs-on: ubuntu-latest |
| 35 | outputs: |
| 36 | version: ${{ steps.package.outputs.version }} |
| 37 | vsix-file: ${{ steps.package.outputs.vsix-file }} |
| 38 | steps: |
| 39 | - name: Harden Runner |
| 40 | uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 |
| 41 | with: |
| 42 | egress-policy: audit |
| 43 | |
| 44 | - name: Checkout code |
| 45 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 46 | with: |
| 47 | persist-credentials: false |
| 48 | |
| 49 | - name: Setup Node.js |
| 50 | uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
| 51 | with: |
| 52 | node-version: '20' |
| 53 | |
| 54 | - name: Install dependencies |
| 55 | run: npm install -g @vscode/vsce |
| 56 | |
| 57 | - name: Setup PowerShell |
| 58 | shell: pwsh |
| 59 | run: | |
| 60 | Write-Host "PowerShell version: $($PSVersionTable.PSVersion)" |
| 61 | |
| 62 | - name: Download changelog artifact |
| 63 | if: inputs.use-changelog |
| 64 | uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 |
| 65 | with: |
| 66 | name: changelog |
| 67 | path: ./ |
| 68 | continue-on-error: true |
| 69 | |
| 70 | - name: Package extension |
| 71 | id: package |
| 72 | shell: pwsh |
| 73 | run: | |
| 74 | $version = "${{ inputs.version }}".Trim() |
| 75 | $devPatch = "${{ inputs.dev-patch-number }}".Trim() |
| 76 | |
| 77 | Write-Host "📦 Packaging extension..." |
| 78 | |
| 79 | $arguments = @() |
| 80 | |
| 81 | if ($version) { |
| 82 | $arguments += '-Version' |
| 83 | $arguments += $version |
| 84 | } |
| 85 | |
| 86 | if ($devPatch) { |
| 87 | $arguments += '-DevPatchNumber' |
| 88 | $arguments += $devPatch |
| 89 | } |
| 90 | |
| 91 | if (Test-Path "./CHANGELOG.md") { |
| 92 | $arguments += '-ChangelogPath' |
| 93 | $arguments += "./CHANGELOG.md" |
| 94 | } |
| 95 | |
| 96 | ./scripts/extension/Package-Extension.ps1 @arguments |
| 97 | |
| 98 | - name: Upload VSIX artifact |
| 99 | uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 100 | with: |
| 101 | name: extension-vsix |
| 102 | path: extension/*.vsix |
| 103 | retention-days: 30 |
| 104 | |