|
| 1 | +name: Publish Extension |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + version: |
| 9 | + description: 'Version to publish (leave empty to use package.json version)' |
| 10 | + required: false |
| 11 | + type: string |
| 12 | + default: '' |
| 13 | + dry-run: |
| 14 | + description: 'Dry run (package only, do not publish)' |
| 15 | + required: false |
| 16 | + type: boolean |
| 17 | + default: false |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: read |
| 21 | + id-token: write |
| 22 | + |
| 23 | +jobs: |
| 24 | + prepare-changelog: |
| 25 | + name: Prepare Changelog |
| 26 | + runs-on: ubuntu-latest |
| 27 | + outputs: |
| 28 | + changelog-path: ${{ steps.create-changelog.outputs.path }} |
| 29 | + steps: |
| 30 | + - name: Harden Runner |
| 31 | + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 |
| 32 | + with: |
| 33 | + egress-policy: audit |
| 34 | + |
| 35 | + - name: Checkout code |
| 36 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 37 | + with: |
| 38 | + persist-credentials: false |
| 39 | + |
| 40 | + - name: Create changelog file |
| 41 | + id: create-changelog |
| 42 | + run: | |
| 43 | + if [ "${{ github.event_name }}" == "release" ]; then |
| 44 | + cat > CHANGELOG.md << 'EOF' |
| 45 | + ${{ github.event.release.body }} |
| 46 | + EOF |
| 47 | + echo "path=CHANGELOG.md" >> $GITHUB_OUTPUT |
| 48 | + elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then |
| 49 | + echo "path=" >> $GITHUB_OUTPUT |
| 50 | + else |
| 51 | + echo "path=" >> $GITHUB_OUTPUT |
| 52 | + fi |
| 53 | +
|
| 54 | + - name: Upload changelog |
| 55 | + if: steps.create-changelog.outputs.path != '' |
| 56 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 57 | + with: |
| 58 | + name: changelog |
| 59 | + path: CHANGELOG.md |
| 60 | + retention-days: 1 |
| 61 | + |
| 62 | + normalize-version: |
| 63 | + name: Normalize Version |
| 64 | + runs-on: ubuntu-latest |
| 65 | + outputs: |
| 66 | + version: ${{ steps.normalize.outputs.version }} |
| 67 | + steps: |
| 68 | + - name: Harden Runner |
| 69 | + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 |
| 70 | + with: |
| 71 | + egress-policy: audit |
| 72 | + |
| 73 | + - name: Normalize version string |
| 74 | + id: normalize |
| 75 | + run: | |
| 76 | + if [ "${{ github.event_name }}" == "release" ]; then |
| 77 | + VERSION="${{ github.event.release.tag_name }}" |
| 78 | + else |
| 79 | + VERSION="${{ inputs.version }}" |
| 80 | + fi |
| 81 | + # Strip leading 'v' if present |
| 82 | + VERSION="${VERSION#v}" |
| 83 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 84 | +
|
| 85 | + package: |
| 86 | + name: Package Extension |
| 87 | + needs: [prepare-changelog, normalize-version] |
| 88 | + uses: ./.github/workflows/extension-package.yml |
| 89 | + with: |
| 90 | + version: ${{ needs.normalize-version.outputs.version }} |
| 91 | + use-changelog: ${{ needs.prepare-changelog.outputs.changelog-path != '' }} |
| 92 | + permissions: |
| 93 | + contents: read |
| 94 | + |
| 95 | + publish: |
| 96 | + name: Publish to Marketplace |
| 97 | + needs: [prepare-changelog, package] |
| 98 | + if: ${{ !inputs.dry-run }} |
| 99 | + runs-on: ubuntu-latest |
| 100 | + environment: marketplace |
| 101 | + steps: |
| 102 | + - name: Harden Runner |
| 103 | + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 |
| 104 | + with: |
| 105 | + egress-policy: audit |
| 106 | + |
| 107 | + - name: Checkout code |
| 108 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 109 | + with: |
| 110 | + persist-credentials: false |
| 111 | + |
| 112 | + - name: Azure Login (OIDC) |
| 113 | + uses: azure/login@a65d910e8af852a8061c627c456678983e180302 # v2.2.0 |
| 114 | + with: |
| 115 | + client-id: ${{ secrets.AZURE_CLIENT_ID }} |
| 116 | + tenant-id: ${{ secrets.AZURE_TENANT_ID }} |
| 117 | + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} |
| 118 | + |
| 119 | + - name: Setup Node.js |
| 120 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
| 121 | + with: |
| 122 | + node-version: '20' |
| 123 | + |
| 124 | + - name: Install VSCE |
| 125 | + run: npm install -g @vscode/vsce |
| 126 | + |
| 127 | + - name: Download VSIX artifact |
| 128 | + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 |
| 129 | + with: |
| 130 | + name: extension-vsix |
| 131 | + path: ./extension |
| 132 | + |
| 133 | + - name: Publish to VS Code Marketplace |
| 134 | + run: | |
| 135 | + VSIX_FILE=$(ls -t extension/hve-core-*.vsix | head -1) |
| 136 | + echo "📦 Publishing: $VSIX_FILE" |
| 137 | + vsce publish --packagePath "$VSIX_FILE" --azure-credential |
| 138 | +
|
| 139 | + - name: Summary |
| 140 | + run: | |
| 141 | + echo "## 🎉 Extension Published Successfully" >> $GITHUB_STEP_SUMMARY |
| 142 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 143 | + echo "**Version:** ${{ needs.package.outputs.version }}" >> $GITHUB_STEP_SUMMARY |
| 144 | + echo "**VSIX File:** ${{ needs.package.outputs.vsix-file }}" >> $GITHUB_STEP_SUMMARY |
| 145 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 146 | + echo "View on [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=ise-hve-essentials.hve-core)" >> $GITHUB_STEP_SUMMARY |
0 commit comments