feat: add BDD tests and CI/CD pipeline #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: Changesets | |
| on: | |
| push: | |
| branches: | |
| - main | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| env: | |
| TURBO_CACHE_DIR: .turbo | |
| jobs: | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| id-token: write | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Setup Node.js (for npm publish) | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Cache Turbo | |
| uses: actions/cache@v4 | |
| with: | |
| path: .turbo | |
| key: turbo-release-${{ runner.os }}-${{ hashFiles('**/bun.lock') }}-${{ github.sha }} | |
| restore-keys: | | |
| turbo-release-${{ runner.os }}-${{ hashFiles('**/bun.lock') }}- | |
| turbo-release-${{ runner.os }}- | |
| - name: Install Dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Build Packages | |
| run: bun run build | |
| - name: Replace workspace protocol | |
| run: | | |
| VERSION=$(jq -r '.version' packages/core/package.json) | |
| echo "Replacing workspace:* with ^${VERSION}" | |
| find packages -name "package.json" -type f -exec sed -i 's/"workspace:\*"/"^'"${VERSION}"'"/g' {} \; | |
| if grep -r '"workspace:' packages/ --include="package.json" 2>/dev/null; then | |
| echo "ERROR: workspace: protocol still found!" | |
| exit 1 | |
| fi | |
| echo "✅ All workspace:* replaced with ^${VERSION}" | |
| - name: Create Release Pull Request or Publish | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| version: bun run version | |
| publish: bun run release | |
| title: "chore: version packages" | |
| commit: "chore: version packages" | |
| createGithubReleases: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NODE_AUTH_TOKEN: ${{ secrets.ORG_NPM_TOKEN }} | |
| - name: Create GitHub Release | |
| if: steps.changesets.outputs.published == 'true' | |
| run: | | |
| VERSION=$(jq -r '.version' packages/core/package.json) | |
| TAG="v${VERSION}" | |
| if git rev-parse "$TAG" >/dev/null 2>&1; then | |
| echo "Tag $TAG already exists, skipping" | |
| exit 0 | |
| fi | |
| git tag "$TAG" | |
| git push origin "$TAG" | |
| PACKAGES='${{ steps.changesets.outputs.publishedPackages }}' | |
| BODY="## Published Packages\n\n" | |
| BODY+=$(echo "$PACKAGES" | jq -r '.[] | "- \(.name)@\(.version)"') | |
| gh release create "$TAG" \ | |
| --title "Release $TAG" \ | |
| --notes "$BODY" | |
| echo "Created release $TAG" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Summary | |
| if: steps.changesets.outputs.published == 'true' | |
| run: | | |
| VERSION=$(jq -r '.version' packages/core/package.json) | |
| echo "## ✅ Packages Published" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Version:** v${VERSION}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Published packages:" >> $GITHUB_STEP_SUMMARY | |
| echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r '.[] | "- `\(.name)@\(.version)`"' >> $GITHUB_STEP_SUMMARY |