chore: update release workflow to build package with Turbo #87
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 Monorepo Packages | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - '@chimp-stack/*@*' # Triggers only on scoped version tags | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| name: Build and Publish ${{ matrix.package }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| package: | |
| - chimp-core | |
| - git-chimp | |
| - doc-chimp | |
| - release-chimp | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Required for tag detection | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org/' | |
| - name: Configure npm auth | |
| run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build package and dependencies with Turbo | |
| run: npx turbo run build --filter=${{ matrix.package }} --concurrency=1 | |
| - name: Publish package if new | |
| working-directory: packages/${{ matrix.package }} | |
| run: | | |
| PACKAGE_NAME=$(node -p "require('./package.json').name") | |
| CURRENT_VERSION=$(node -p "require('./package.json').version") | |
| PUBLISHED_VERSION=$(npm view $PACKAGE_NAME version || echo "0.0.0") | |
| echo "📦 Package: $PACKAGE_NAME" | |
| echo "🔖 Current Version: $CURRENT_VERSION" | |
| echo "📬 Published Version: $PUBLISHED_VERSION" | |
| if [ "$CURRENT_VERSION" = "$PUBLISHED_VERSION" ]; then | |
| echo "⏩ Skipping — already published." | |
| exit 0 | |
| fi | |
| echo "🚀 Publishing $PACKAGE_NAME@$CURRENT_VERSION..." | |
| npm publish --access public | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |