feat: add types exports to SDK packages and update test imports #57
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: | |
| branches: | |
| - main | |
| paths: | |
| # Only trigger on changes that affect packages or changesets | |
| - 'packages/**' | |
| - '.changeset/**' | |
| - 'package.json' | |
| - 'bun.lock' | |
| - 'turbo.json' | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| jobs: | |
| # First job: Check if there are changesets to release | |
| check-changesets: | |
| name: Check for changesets | |
| runs-on: ubuntu-latest | |
| outputs: | |
| has-changesets: ${{ steps.check.outputs.has-changesets }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v1 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Check for changesets | |
| id: check | |
| run: | | |
| # Check if there are any changesets | |
| if [ -n "$(find .changeset -name '*.md' -not -name 'README.md' -type f)" ]; then | |
| echo "has-changesets=true" >> $GITHUB_OUTPUT | |
| echo "Found changesets to release" | |
| else | |
| echo "has-changesets=false" >> $GITHUB_OUTPUT | |
| echo "No changesets found, skipping release" | |
| fi | |
| release: | |
| name: Release | |
| needs: check-changesets | |
| if: needs.check-changesets.outputs.has-changesets == 'true' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: write | |
| packages: write | |
| pull-requests: write | |
| issues: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v1 | |
| with: | |
| bun-version: latest | |
| - name: Setup Node.js for NPM | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.bun/install/cache | |
| node_modules | |
| key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} | |
| restore-keys: | | |
| ${{ runner.os }}-bun- | |
| - name: Cache Turbo | |
| uses: actions/cache@v4 | |
| with: | |
| path: .turbo | |
| key: ${{ runner.os }}-turbo-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-turbo- | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Generate SDKs | |
| run: bunx turbo run generate | |
| - name: Run tests | |
| run: bunx turbo run test | |
| env: | |
| GOV_INFO_API_KEY: ${{ secrets.GOV_INFO_API_KEY }} | |
| DOL_API_KEY: ${{ secrets.DOL_API_KEY }} | |
| - name: Build packages | |
| run: bunx turbo run build | |
| - name: Create Release Pull Request or Publish to npm | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| publish: bun run release | |
| version: bun run version-packages | |
| commit: 'chore: version packages' | |
| title: 'chore: version packages' | |
| createGithubReleases: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Publish to GitHub Packages | |
| if: steps.changesets.outputs.published == 'true' | |
| run: | | |
| # Setup Node.js for GitHub Packages | |
| echo "@beshkenadze:registry=https://npm.pkg.github.com" >> ~/.npmrc | |
| echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc | |
| # Parse published packages and publish to GitHub Packages | |
| echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r '.[] | .name' | while read package; do | |
| cd packages/${package#@us-legal-tools/} | |
| npm publish --registry=https://npm.pkg.github.com --access public | |
| cd ../.. | |
| done | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Success notification | |
| if: steps.changesets.outputs.published == 'true' | |
| run: | | |
| echo "🎉 Successfully published packages!" | |
| echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r '.[] | "📦 \(.name) v\(.version): https://www.npmjs.com/package/\(.name)"' | |
| echo "📦 GitHub Packages: https://github.com/${{ github.repository }}/packages" |