Merge pull request #63 from arvoreeducacao/ricardo-/-fix-gitignore-an… #224
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: CI | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Run linting | |
| run: pnpm lint | |
| - name: Run tests with coverage | |
| run: pnpm test:cov | |
| - name: Build all packages | |
| run: pnpm build | |
| publish: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' | |
| permissions: | |
| contents: read | |
| id-token: write | |
| attestations: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "pnpm" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build packages | |
| run: pnpm build | |
| - name: Upgrade npm for trusted publishing | |
| run: npm install -g npm@latest | |
| - name: Publish packages | |
| run: | | |
| for pkg in packages/*/; do | |
| PKG_NAME=$(node -p "require('./$pkg/package.json').name") | |
| PKG_VERSION=$(node -p "require('./$pkg/package.json').version") | |
| if npm view "$PKG_NAME@$PKG_VERSION" version 2>/dev/null; then | |
| echo "$PKG_NAME@$PKG_VERSION already published, skipping." | |
| else | |
| echo "Publishing $PKG_NAME@$PKG_VERSION..." | |
| cd "$pkg" | |
| TARBALL=$(pnpm pack --pack-destination /tmp | tail -1) | |
| npm publish "$TARBALL" --access public --provenance | |
| cd ../.. | |
| fi | |
| done |