|
| 1 | +name: CI/CD |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, release, rc] |
| 6 | + pull_request: |
| 7 | + branches: [main, release, rc] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + packages: write |
| 12 | + checks: write |
| 13 | + pull-requests: write |
| 14 | + id-token: write |
| 15 | + attestations: write |
| 16 | + |
| 17 | +jobs: |
| 18 | + lint: |
| 19 | + name: Lint |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + |
| 27 | + - name: Setup Bun |
| 28 | + uses: oven-sh/setup-bun@v2 |
| 29 | + with: |
| 30 | + bun-version: 1.2.15 |
| 31 | + |
| 32 | + - name: Cache Bun global packages |
| 33 | + uses: actions/cache@v4 |
| 34 | + with: |
| 35 | + path: ~/.bun/install/cache |
| 36 | + key: ${{ runner.os }}-bun-${{ hashFiles('**/package.json') }} |
| 37 | + restore-keys: | |
| 38 | + ${{ runner.os }}-bun- |
| 39 | +
|
| 40 | + - name: Cache Playwright browser binaries |
| 41 | + uses: actions/cache@v4 |
| 42 | + with: |
| 43 | + path: ~/.cache/ms-playwright |
| 44 | + key: ${{ runner.os }}-playwright-${{ hashFiles('**/package.json') }} |
| 45 | + restore-keys: | |
| 46 | + ${{ runner.os }}-playwright- |
| 47 | +
|
| 48 | + - name: Install dependencies |
| 49 | + run: bun install |
| 50 | + |
| 51 | + - name: Run format check |
| 52 | + run: bun run format:check |
| 53 | + |
| 54 | + build: |
| 55 | + name: Build |
| 56 | + needs: lint |
| 57 | + runs-on: ubuntu-latest |
| 58 | + steps: |
| 59 | + - name: Checkout |
| 60 | + uses: actions/checkout@v4 |
| 61 | + with: |
| 62 | + fetch-depth: 0 |
| 63 | + |
| 64 | + - name: Setup Bun |
| 65 | + uses: oven-sh/setup-bun@v2 |
| 66 | + with: |
| 67 | + bun-version: 1.2.15 |
| 68 | + |
| 69 | + - name: Cache Bun global packages |
| 70 | + uses: actions/cache@v4 |
| 71 | + with: |
| 72 | + path: ~/.bun/install/cache |
| 73 | + key: ${{ runner.os }}-bun-${{ hashFiles('**/package.json') }} |
| 74 | + restore-keys: | |
| 75 | + ${{ runner.os }}-bun- |
| 76 | +
|
| 77 | + - name: Cache Playwright browser binaries |
| 78 | + uses: actions/cache@v4 |
| 79 | + with: |
| 80 | + path: ~/.cache/ms-playwright |
| 81 | + key: ${{ runner.os }}-playwright-${{ hashFiles('**/package.json') }} |
| 82 | + restore-keys: | |
| 83 | + ${{ runner.os }}-playwright- |
| 84 | +
|
| 85 | + - name: Install dependencies |
| 86 | + run: bun install |
| 87 | + |
| 88 | + - name: Configure git |
| 89 | + run: | |
| 90 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 91 | + git config --global user.name "github-actions[bot]" |
| 92 | +
|
| 93 | + - name: Build |
| 94 | + run: bun run build |
| 95 | + |
| 96 | + - name: Upload build artifacts |
| 97 | + uses: actions/upload-artifact@v4 |
| 98 | + with: |
| 99 | + name: build-artifacts |
| 100 | + path: dist/ |
| 101 | + |
| 102 | + - name: Attest build artifacts |
| 103 | + if: github.ref == 'refs/heads/release' || github.ref == 'refs/heads/rc' |
| 104 | + uses: actions/attest-build-provenance@v2 |
| 105 | + with: |
| 106 | + subject-path: 'dist/*' |
| 107 | + |
| 108 | + release: |
| 109 | + name: Release |
| 110 | + needs: build |
| 111 | + if: github.event_name == 'push' && (github.ref == 'refs/heads/release' || github.ref == 'refs/heads/rc') |
| 112 | + runs-on: ubuntu-latest |
| 113 | + steps: |
| 114 | + - name: Checkout |
| 115 | + uses: actions/checkout@v4 |
| 116 | + with: |
| 117 | + fetch-depth: 0 |
| 118 | + |
| 119 | + - name: Setup Bun |
| 120 | + uses: oven-sh/setup-bun@v2 |
| 121 | + with: |
| 122 | + bun-version: 1.2.15 |
| 123 | + |
| 124 | + - name: Cache Bun global packages |
| 125 | + uses: actions/cache@v4 |
| 126 | + with: |
| 127 | + path: ~/.bun/install/cache |
| 128 | + key: ${{ runner.os }}-bun-${{ hashFiles('**/package.json') }} |
| 129 | + restore-keys: | |
| 130 | + ${{ runner.os }}-bun- |
| 131 | +
|
| 132 | + - name: Cache Playwright browser binaries |
| 133 | + uses: actions/cache@v4 |
| 134 | + with: |
| 135 | + path: ~/.cache/ms-playwright |
| 136 | + key: ${{ runner.os }}-playwright-${{ hashFiles('**/package.json') }} |
| 137 | + restore-keys: | |
| 138 | + ${{ runner.os }}-playwright- |
| 139 | +
|
| 140 | + - name: Install dependencies |
| 141 | + run: bun install |
| 142 | + |
| 143 | + - name: Download build artifacts |
| 144 | + uses: actions/download-artifact@v4 |
| 145 | + with: |
| 146 | + name: build-artifacts |
| 147 | + path: . |
| 148 | + |
| 149 | + - name: Configure git & npm |
| 150 | + env: |
| 151 | + NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} |
| 152 | + run: | |
| 153 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 154 | + git config --global user.name "github-actions[bot]" |
| 155 | + echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc |
| 156 | +
|
| 157 | + - name: Release |
| 158 | + env: |
| 159 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 160 | + NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} |
| 161 | + run: | |
| 162 | + if [ "${{ github.ref }}" = "refs/heads/release" ]; then |
| 163 | + echo "Releasing stable version..." |
| 164 | + bun run release:ci |
| 165 | + elif [ "${{ github.ref }}" = "refs/heads/rc" ]; then |
| 166 | + echo "Releasing RC version..." |
| 167 | + bun run release:rc:ci |
| 168 | + fi |
0 commit comments