microsoft/hve-core
Publicmirrored fromhttps://github.com/microsoft/hve-coreAvailable
.github/workflows/extension-publish.yml
92lines · modecode
| 1 | name: Publish Extension |
| 2 | |
| 3 | on: |
| 4 | # Release trigger disabled - extension publishing is manual-only |
| 5 | # Uncomment to enable auto-publish on GitHub releases: |
| 6 | # release: |
| 7 | # types: [published] |
| 8 | workflow_dispatch: |
| 9 | inputs: |
| 10 | version: |
| 11 | description: "Version to publish (leave empty to auto-detect from latest release)" |
| 12 | required: false |
| 13 | type: string |
| 14 | default: "" |
| 15 | dry-run: |
| 16 | description: "Dry run (package only, do not publish)" |
| 17 | required: false |
| 18 | type: boolean |
| 19 | default: false |
| 20 | |
| 21 | permissions: |
| 22 | contents: read |
| 23 | |
| 24 | concurrency: |
| 25 | group: ${{ github.workflow }}-${{ github.ref }} |
| 26 | cancel-in-progress: false |
| 27 | |
| 28 | jobs: |
| 29 | normalize-version: |
| 30 | name: Normalize Version |
| 31 | runs-on: ubuntu-latest |
| 32 | permissions: |
| 33 | contents: read |
| 34 | outputs: |
| 35 | version: ${{ steps.normalize.outputs.version }} |
| 36 | steps: |
| 37 | - name: Normalize version string |
| 38 | id: normalize |
| 39 | env: |
| 40 | GH_TOKEN: ${{ github.token }} |
| 41 | INPUT_VERSION: ${{ inputs.version }} |
| 42 | run: | |
| 43 | VERSION="$INPUT_VERSION" |
| 44 | # Strip leading 'v' and component prefix if present |
| 45 | VERSION="${VERSION#v}" |
| 46 | VERSION="${VERSION#hve-core-v}" |
| 47 | |
| 48 | # Auto-detect from latest release tag when no version specified |
| 49 | if [ -z "$VERSION" ]; then |
| 50 | TAG=$(gh release list --exclude-drafts --exclude-pre-releases --limit 1 --json tagName -q '.[0].tagName' -R "${{ github.repository }}") |
| 51 | VERSION="${TAG#hve-core-v}" |
| 52 | echo "📦 Auto-detected version from latest release: $VERSION" |
| 53 | fi |
| 54 | |
| 55 | # Validate semver format |
| 56 | if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 57 | echo "::error::Invalid version format: $VERSION. Expected semantic version (e.g., 2.0.0)" |
| 58 | exit 1 |
| 59 | fi |
| 60 | |
| 61 | # Validate even minor version (stable channel convention) |
| 62 | MINOR=$(echo "$VERSION" | cut -d. -f2) |
| 63 | if (( MINOR % 2 != 0 )); then |
| 64 | echo "::error::Stable channel requires EVEN minor version. Got: $VERSION (minor=$MINOR is ODD)" |
| 65 | echo "::error::Use extension-publish-prerelease workflow for ODD minor (pre-release) versions" |
| 66 | exit 1 |
| 67 | fi |
| 68 | |
| 69 | echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 70 | |
| 71 | package: |
| 72 | name: Package Extensions |
| 73 | needs: [normalize-version] |
| 74 | uses: ./.github/workflows/extension-package.yml |
| 75 | with: |
| 76 | version: ${{ needs.normalize-version.outputs.version }} |
| 77 | channel: Stable |
| 78 | permissions: |
| 79 | contents: read |
| 80 | |
| 81 | publish: |
| 82 | name: Publish Extensions |
| 83 | needs: [package] |
| 84 | if: ${{ !inputs.dry-run }} |
| 85 | uses: ./.github/workflows/extension-publish-marketplace.yml |
| 86 | with: |
| 87 | collections-matrix: ${{ needs.package.outputs.collections-matrix }} |
| 88 | pre-release: false |
| 89 | permissions: |
| 90 | contents: read |
| 91 | id-token: write |
| 92 | secrets: inherit |
| 93 | |