Merge pull request #341 from RSamaium/changeset-release/v5 #707
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 | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| on: | |
| push: | |
| branches: | |
| - "**" | |
| paths-ignore: | |
| - "docs/**" | |
| pull_request: | |
| branches: | |
| - "*" | |
| paths-ignore: | |
| - "docs/**" | |
| jobs: | |
| tests: | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| matrix: | |
| node-version: [22] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install --no-frozen-lockfile | |
| - name: Build | |
| run: pnpm build | |
| - name: Public API boundary | |
| run: pnpm api:boundary | |
| - name: Public API type contracts | |
| run: pnpm test:types | |
| - name: Unit tests | |
| run: pnpm test -- --run | |
| - name: Cloudflare MMORPG runtime tests | |
| run: pnpm --dir samples/cloudflare-mmorpg test | |
| - name: Cloudflare Studio runtime tests | |
| run: pnpm --dir playground/games/studio test | |
| - name: Playground and sample builds | |
| run: pnpm --filter '@rpgjs/playground-*' --filter sample run build | |
| build_and_publish: | |
| needs: tests | |
| if: github.ref == 'refs/heads/v5' | |
| runs-on: ubuntu-latest | |
| outputs: | |
| published: ${{ steps.changesets.outputs.published }} | |
| steps: | |
| - name: ⬇️ Checkout | |
| id: checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: 🟢 Setup node | |
| id: setup-node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| registry-url: https://registry.npmjs.org | |
| - name: 🥡 Setup pnpm | |
| id: setup-pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| run_install: false | |
| - name: 🎈 Get pnpm store directory | |
| id: get-pnpm-cache-dir | |
| run: | | |
| echo "pnpm_cache_dir=$(pnpm store path)" >> "$GITHUB_OUTPUT" | |
| - name: 🔆 Cache pnpm modules | |
| uses: actions/cache@v4 | |
| id: pnpm-cache | |
| with: | |
| path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: 🧩 Install Dependencies | |
| id: install-dependencies | |
| run: pnpm install --no-frozen-lockfile | |
| - name: 🏗️ Build | |
| id: build-the-mono-repo | |
| run: | | |
| pnpm build | |
| - name: Configure npm auth | |
| run: | | |
| pnpm config set "//registry.npmjs.org/:_authToken" "$NPM_AUTH_TOKEN" | |
| npm config set "//registry.npmjs.org/:_authToken" "$NPM_AUTH_TOKEN" | |
| env: | |
| NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: 📣 Version packages or publish to npm | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| version: pnpm run version-packages | |
| publish: pnpm run publish-packages | |
| commit: "chore: version packages" | |
| title: "chore: version packages" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| starter_repo_update_dependencies: | |
| needs: build_and_publish | |
| if: github.ref == 'refs/heads/v5' && needs.build_and_publish.outputs.published == 'true' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| starter_branch: | |
| - v5-studio | |
| - v5 | |
| steps: | |
| - name: Check starter repository token | |
| run: | | |
| if [ -z "$GH_ACCESS_TOKEN" ]; then | |
| echo "::error::Missing GH_ACCESS_TOKEN secret. It must be a GitHub token with write access to rpgjs/starter." | |
| exit 1 | |
| fi | |
| env: | |
| GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} | |
| - name: Checkout the starter repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: rpgjs/starter | |
| ref: ${{ matrix.starter_branch }} | |
| path: starter | |
| token: ${{ secrets.GH_ACCESS_TOKEN }} | |
| - name: Install npm-check-updates globally | |
| run: npm i npm-check-updates -g | |
| - name: Run ncu to update dependencies | |
| run: | | |
| cd starter | |
| ncu -u | |
| - name: Update package lock | |
| run: | | |
| cd starter | |
| npm i --package-lock-only | |
| - name: Deploy to external repository | |
| run: | | |
| cd starter | |
| if git diff --quiet; then | |
| echo "No dependency changes to commit." | |
| exit 0 | |
| fi | |
| git config user.name "${{ github.actor }}" | |
| git config user.email "${{ github.actor }}@users.noreply.github.com" | |
| git add package.json package-lock.json | |
| git commit -m "update package dependencies to latest RPGJS version on ${{ matrix.starter_branch }}" | |
| git push origin HEAD:${{ matrix.starter_branch }} |