Publish #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # yaml-language-server: $schema=https://www.schemastore.org/github-workflow.json | |
| --- | |
| name: Publish | |
| on: | |
| workflow_run: | |
| workflows: ["Integration Tests"] | |
| types: | |
| - completed | |
| branches: | |
| - main | |
| push: | |
| tags: | |
| - 'v*.*.*' | |
| - '*.*.*' | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| publish-ea: | |
| if: | | |
| github.event_name == 'workflow_run' && | |
| github.event.workflow_run.head_branch == 'main' && | |
| github.event.workflow_run.event == 'push' | |
| runs-on: ubuntu-latest | |
| name: Publish EA release to NPM | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_branch }} | |
| fetch-depth: 0 | |
| - name: Install node 24 | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: 24 | |
| cache: npm | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Update npm | |
| run: npm install -g npm@latest | |
| - name: Configure git | |
| run: | | |
| git config user.name "${{ github.actor }}" | |
| git config user.email "${{ github.actor }}@users.noreply.github.com" | |
| - name: Reset to workflow run commit | |
| run: | | |
| git reset --hard ${{ github.event.workflow_run.head_sha }} | |
| - name: Get current version | |
| id: current-version | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| # Remove both -ea. and -ea- formats for compatibility | |
| BASE_VERSION=$(echo "$VERSION" | sed -E 's/-ea[.-][0-9]+$//') | |
| echo "base-version=$BASE_VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Install project modules | |
| run: npm ci | |
| - name: Compile project | |
| run: npm run compile | |
| - name: Publish package | |
| run: | | |
| SHORT_SHA=$(git rev-parse --short "${{ github.event.workflow_run.head_sha }}") | |
| EA_VERSION="${{ steps.current-version.outputs.base-version }}-ea.${SHORT_SHA}" | |
| # Temporarily update version for publish | |
| npm version "$EA_VERSION" --no-git-tag-version | |
| npm publish --verbose --tag ea --access public --provenance | |
| # Restore original version | |
| npm version "${{ steps.current-version.outputs.base-version }}" --no-git-tag-version | |
| publish-release: | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| name: Publish release to NPM | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| fetch-depth: 0 | |
| - name: Install node 24 | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: 24 | |
| cache: npm | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Update npm | |
| run: npm install -g npm@latest | |
| - name: Get tag name | |
| id: tag | |
| run: | | |
| TAG_NAME=${GITHUB_REF#refs/tags/} | |
| echo "name=$TAG_NAME" >> "$GITHUB_OUTPUT" | |
| - name: Update package.json with tag version | |
| id: update-version | |
| run: | | |
| TAG_NAME="${{ steps.tag.outputs.name }}" | |
| # Remove 'v' prefix if present | |
| VERSION=${TAG_NAME#v} | |
| npm version "$VERSION" --no-git-tag-version | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Install project modules | |
| run: npm ci | |
| - name: Compile project | |
| run: npm run compile | |
| - name: Publish package | |
| run: npm publish --verbose --access public --provenance |