publish #1
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: publish | |
| on: | |
| workflow_run: | |
| workflows: | |
| - ci | |
| branches: | |
| - main | |
| types: | |
| - completed | |
| workflow_dispatch: | |
| concurrency: | |
| group: publish-${{ github.ref }} | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| publish: | |
| if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GH_PERSONAL_TOKEN || github.token }} | |
| fetch-depth: 0 | |
| ref: ${{ github.event.workflow_run.head_sha || github.sha }} | |
| - uses: actions/cache@v4 | |
| id: yarn-cache | |
| with: | |
| path: ~/.cache | |
| key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-yarn- | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22.22.3 | |
| registry-url: 'https://npm.pkg.github.com' | |
| scope: '@twig-it' | |
| - name: Install dependencies | |
| run: yarn --immutable | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name "${{ secrets.GIT_USER || 'github-actions[bot]' }}" | |
| git config --global user.email "${{ secrets.GIT_EMAIL || '41898282+github-actions[bot]@users.noreply.github.com' }}" | |
| - name: Configure npm | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| npm config set @twig-it:registry=https://npm.pkg.github.com | |
| npm config set //npm.pkg.github.com/:_authToken=$NODE_AUTH_TOKEN | |
| - name: Build and test release artifacts | |
| run: yarn ci | |
| - name: Version and generate changelog | |
| env: | |
| YARN_ENABLE_IMMUTABLE_INSTALLS: 'false' | |
| run: | | |
| if git tag -l 'angular-rspack@*' | grep -q .; then | |
| yarn nx release version --groups angular-rspack --git-commit --git-tag | |
| else | |
| yarn nx release version 22.0.0 --groups angular-rspack --first-release --git-commit --git-tag | |
| fi | |
| if git tag -l 'angular-rstest@*' | grep -q .; then | |
| yarn nx release version --groups angular-rstest --git-commit --git-tag | |
| else | |
| yarn nx release version 22.0.0 --groups angular-rstest --first-release --git-commit --git-tag | |
| fi | |
| if git tag -l 'angular-rsbuild@*' | grep -q .; then | |
| yarn nx release version --groups angular-rsbuild --git-commit --git-tag | |
| else | |
| yarn nx release version 22.0.0 --groups angular-rsbuild --first-release --git-commit --git-tag | |
| fi | |
| if git tag -l 'angular-rslint@*' | grep -q .; then | |
| yarn nx release version --groups angular-rslint --git-commit --git-tag | |
| else | |
| yarn nx release version 22.0.0 --groups angular-rslint --first-release --git-commit --git-tag | |
| fi | |
| - name: Commit and push release tag | |
| run: | | |
| git push origin HEAD:main --follow-tags | |
| - name: Publish changed packages to GitHub Packages | |
| run: | | |
| yarn nx release publish --groups angular-rspack | |
| yarn nx release publish --groups angular-rstest | |
| yarn nx release publish --groups angular-rsbuild | |
| yarn nx release publish --groups angular-rslint | |
| - name: Create GitHub Release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| for TAG in $(git tag --points-at HEAD 'angular-rspack@*' 'angular-rstest@*' 'angular-rsbuild@*' 'angular-rslint@*'); do | |
| gh release view "$TAG" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1 || \ | |
| gh release create "$TAG" --repo "${GITHUB_REPOSITORY}" --generate-notes --title "$TAG" | |
| done | |
| - name: Verify GitHub Package | |
| run: | | |
| for PACKAGE_PATH in packages/angular-rspack packages/angular-rstest packages/angular-rsbuild packages/angular-rslint; do | |
| NAME=$(node -p "require('./${PACKAGE_PATH}/package.json').name") | |
| VERSION=$(node -p "require('./${PACKAGE_PATH}/package.json').version") | |
| npm view "${NAME}@${VERSION}" version --registry=https://npm.pkg.github.com | |
| done |