|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + tags: |
| 7 | + - "v*" |
| 8 | + pull_request: |
| 9 | + branches: [main] |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + build-and-test: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
| 22 | + |
| 23 | + - name: Install pnpm |
| 24 | + uses: pnpm/action-setup@v4 |
| 25 | + |
| 26 | + - name: Setup Node.js |
| 27 | + uses: actions/setup-node@v4 |
| 28 | + with: |
| 29 | + node-version: lts/* |
| 30 | + cache: pnpm |
| 31 | + |
| 32 | + - name: Install dependencies |
| 33 | + run: pnpm install |
| 34 | + |
| 35 | + - name: Build |
| 36 | + run: pnpm run build |
| 37 | + |
| 38 | + - name: Lint |
| 39 | + run: pnpm run lint |
| 40 | + |
| 41 | + - name: Typecheck |
| 42 | + run: pnpm run typecheck |
| 43 | + |
| 44 | + - name: Test |
| 45 | + run: pnpm run test |
| 46 | + |
| 47 | + publish: |
| 48 | + needs: build-and-test |
| 49 | + if: startsWith(github.ref, 'refs/tags/v') |
| 50 | + runs-on: ubuntu-latest |
| 51 | + steps: |
| 52 | + - name: Checkout |
| 53 | + uses: actions/checkout@v4 |
| 54 | + with: |
| 55 | + fetch-depth: 0 |
| 56 | + |
| 57 | + - name: Install pnpm |
| 58 | + uses: pnpm/action-setup@v4 |
| 59 | + |
| 60 | + - name: Setup Node.js |
| 61 | + uses: actions/setup-node@v4 |
| 62 | + with: |
| 63 | + node-version: lts/* |
| 64 | + cache: pnpm |
| 65 | + registry-url: "https://registry.npmjs.org" |
| 66 | + |
| 67 | + - name: Install dependencies |
| 68 | + run: pnpm install |
| 69 | + |
| 70 | + - name: Build |
| 71 | + run: pnpm run build |
| 72 | + |
| 73 | + - name: Extract version from tag |
| 74 | + id: version |
| 75 | + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT |
| 76 | + |
| 77 | + - name: Sync package versions |
| 78 | + run: | |
| 79 | + VERSION=${{ steps.version.outputs.VERSION }} |
| 80 | + echo "Setting all packages to version $VERSION" |
| 81 | +
|
| 82 | + # Update version in all package.json files |
| 83 | + for pkg in packages/*/package.json; do |
| 84 | + jq --arg v "$VERSION" '.version = $v' "$pkg" > tmp.json && mv tmp.json "$pkg" |
| 85 | + echo "$pkg: $VERSION" |
| 86 | + done |
| 87 | +
|
| 88 | + # Note: pnpm automatically replaces workspace:^ with ^VERSION during publish |
| 89 | +
|
| 90 | + - name: Publish all packages |
| 91 | + run: pnpm -r publish --access public --no-git-checks |
| 92 | + env: |
| 93 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 94 | + |
| 95 | + - name: Create GitHub Release |
| 96 | + run: npx changelogithub |
| 97 | + env: |
| 98 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments