feat(types): generate dynamic exports for collection types in types i… #18
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: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| # Prevent multiple concurrent runs of the same workflow | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test: | |
| runs-on: self-hosted | |
| if: github.repository == 'alloy-lab/collection-registry' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Run typecheck | |
| run: pnpm typecheck | |
| - name: Run linting | |
| run: pnpm lint | |
| - name: Check formatting | |
| run: pnpm format:check | |
| - name: Run tests | |
| run: pnpm test:run | |
| - name: Run tests with coverage | |
| run: pnpm test:coverage | |
| - name: Build package | |
| run: pnpm build | |
| - name: Upload coverage reports | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| os: linux-arm64 | |
| publish: | |
| needs: test | |
| runs-on: self-hosted | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' && github.repository == 'alloy-lab/collection-registry' | |
| environment: npm-publish | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build package | |
| run: pnpm build | |
| - name: Check for version bump needed | |
| id: version-check | |
| run: | | |
| # Check if there are any commits since last tag | |
| if git describe --tags --exact-match HEAD >/dev/null 2>&1; then | |
| echo "no-bump=true" >> $GITHUB_OUTPUT | |
| echo "No version bump needed - already tagged" | |
| else | |
| # Check if the current version already exists on npm | |
| CURRENT_VERSION=$(node -p "require('./package.json').version") | |
| if npm view @alloylab/collection-registry@$CURRENT_VERSION version >/dev/null 2>&1; then | |
| echo "no-bump=true" >> $GITHUB_OUTPUT | |
| echo "Version $CURRENT_VERSION already exists on npm - skipping publish" | |
| else | |
| echo "no-bump=false" >> $GITHUB_OUTPUT | |
| echo "Version bump needed" | |
| fi | |
| fi | |
| - name: Auto-increment version | |
| if: steps.version-check.outputs.no-bump == 'false' | |
| run: | | |
| # Get the last commit message | |
| COMMIT_MSG=$(git log -1 --pretty=%B) | |
| # Determine version bump type based on conventional commits | |
| if echo "$COMMIT_MSG" | grep -q "^feat("; then | |
| echo "Bumping minor version (new feature)" | |
| pnpm version minor --no-git-tag-version | |
| elif echo "$COMMIT_MSG" | grep -q "^fix("; then | |
| echo "Bumping patch version (bug fix)" | |
| pnpm version patch --no-git-tag-version | |
| elif echo "$COMMIT_MSG" | grep -q "^BREAKING CHANGE\|^feat!(\|^fix!("; then | |
| echo "Bumping major version (breaking change)" | |
| pnpm version major --no-git-tag-version | |
| else | |
| echo "Bumping patch version (default)" | |
| pnpm version patch --no-git-tag-version | |
| fi | |
| # Create and push tag | |
| NEW_VERSION=$(node -p "require('./package.json').version") | |
| git config --local user.email "[email protected]" | |
| git config --local user.name "GitHub Action" | |
| git add package.json | |
| git commit -m "chore(release): bump version to $NEW_VERSION" | |
| git tag "v$NEW_VERSION" | |
| git push origin main | |
| git push origin "v$NEW_VERSION" | |
| - name: Check if version exists on npm | |
| if: steps.version-check.outputs.no-bump == 'false' | |
| id: version-exists | |
| run: | | |
| NEW_VERSION=$(node -p "require('./package.json').version") | |
| if npm view @alloylab/collection-registry@$NEW_VERSION version >/dev/null 2>&1; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| echo "Version $NEW_VERSION already exists on npm" | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| echo "Version $NEW_VERSION is new and can be published" | |
| fi | |
| - name: Publish to npm | |
| if: steps.version-check.outputs.no-bump == 'false' && steps.version-exists.outputs.exists == 'false' | |
| run: pnpm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |