21.5.2 #47
Workflow file for this run
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
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| id-token: write | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: 24 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Extract version from tag | |
| id: tag_version | |
| run: | | |
| TAG_NAME=${GITHUB_REF#refs/tags/} | |
| VERSION=${TAG_NAME#v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT | |
| echo "Extracted version: $VERSION from tag: $TAG_NAME" | |
| # Lint CI uses setup-node's npm as-is. Do not bump to npm@latest here: | |
| # npm v12 defaults allow-git=none and breaks github:apple-sign-in. | |
| - name: Install dependencies | |
| run: npm ci --allow-git=all | |
| - name: Extract library projects | |
| id: libraries | |
| run: | | |
| LIBRARIES=$(node -e "const fs=require('fs'); const angular=JSON.parse(fs.readFileSync('angular.json','utf8')); const libs=Object.keys(angular.projects).filter(p=>angular.projects[p].projectType==='library'); console.log(libs.join(' '));") | |
| echo "list=$LIBRARIES" >> $GITHUB_OUTPUT | |
| echo "Library projects: $LIBRARIES" | |
| - name: Switch to default branch and align with tag commit | |
| run: | | |
| DEFAULT_BRANCH="${{ github.event.repository.default_branch }}" | |
| git fetch origin "$DEFAULT_BRANCH" | |
| git checkout "$DEFAULT_BRANCH" | |
| git merge --ff-only "$GITHUB_SHA" | |
| - name: Update project package.json versions | |
| run: | | |
| VERSION="${{ steps.tag_version.outputs.version }}" | |
| echo "Setting project versions to $VERSION" | |
| for project in ${{ steps.libraries.outputs.list }}; do | |
| echo "Updating projects/$project/package.json..." | |
| cd "projects/$project" | |
| npm version "$VERSION" --no-git-tag-version | |
| cd ../.. | |
| done | |
| - name: Build all projects | |
| run: npm run prebuild | |
| - name: Commit changes | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add projects/*/package.json | |
| git commit -m "chore: update project versions to ${{ steps.tag_version.outputs.version }}" || exit 0 | |
| git push origin HEAD | |
| - name: Publish packages | |
| run: | | |
| VERSION="${{ steps.tag_version.outputs.version }}" | |
| IS_STABLE=$(echo "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' && echo true || echo false) | |
| for project in ${{ steps.libraries.outputs.list }}; do | |
| echo "Publishing $project..." | |
| cd "dist/$project" | |
| if [ "$IS_STABLE" = "true" ]; then | |
| npm publish --provenance --access public | |
| else | |
| npm publish --provenance --access public --tag beta | |
| fi | |
| cd ../.. | |
| done | |