|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - master |
| 8 | + - naga |
| 9 | + - 'feature/**' |
| 10 | + pull_request: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + - master |
| 14 | + - naga |
| 15 | + workflow_dispatch: |
| 16 | + inputs: |
| 17 | + release_type: |
| 18 | + description: 'Release type' |
| 19 | + required: true |
| 20 | + default: 'alpha' |
| 21 | + type: choice |
| 22 | + options: |
| 23 | + - alpha |
| 24 | + - beta |
| 25 | + - latest |
| 26 | + |
| 27 | +env: |
| 28 | + LIT_STATUS_WRITE_KEY: ${{ secrets.LIT_STATUS_WRITE_KEY }} |
| 29 | + LIT_STATUS_BACKEND_URL: ${{ vars.LIT_STATUS_BACKEND_URL }} |
| 30 | + LIVE_MASTER_ACCOUNT: ${{ secrets.LIVE_MASTER_ACCOUNT }} |
| 31 | + LOCAL_MASTER_ACCOUNT: ${{ secrets.LOCAL_MASTER_ACCOUNT }} |
| 32 | + LOG_LEVEL: info |
| 33 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 34 | + |
| 35 | +jobs: |
| 36 | + test-and-release: |
| 37 | + runs-on: ubuntu-latest |
| 38 | + environment: Health Check |
| 39 | + timeout-minutes: 30 |
| 40 | + if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')" |
| 41 | + |
| 42 | + steps: |
| 43 | + - name: Checkout code |
| 44 | + uses: actions/checkout@v4 |
| 45 | + with: |
| 46 | + fetch-depth: 0 |
| 47 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 48 | + |
| 49 | + - name: Setup Bun |
| 50 | + uses: oven-sh/setup-bun@v1 |
| 51 | + with: |
| 52 | + bun-version: latest |
| 53 | + |
| 54 | + - name: Install rust |
| 55 | + |
| 56 | + |
| 57 | + - name: Install wasm-pack |
| 58 | + |
| 59 | + with: |
| 60 | + version: 'latest' |
| 61 | + |
| 62 | + - name: Setup Node for NPM |
| 63 | + uses: actions/setup-node@v4 |
| 64 | + with: |
| 65 | + node-version: '18' |
| 66 | + registry-url: 'https://registry.npmjs.org' |
| 67 | + |
| 68 | + - name: Install Bun dependencies |
| 69 | + run: bun install |
| 70 | + |
| 71 | + - name: Build project |
| 72 | + run: bun run build |
| 73 | + |
| 74 | + - name: Run health check for naga-dev |
| 75 | + run: NETWORK=naga-dev bun run test:e2e all --timeout 5000000 |
| 76 | + timeout-minutes: 10 |
| 77 | + |
| 78 | + - name: Run health check for naga-test |
| 79 | + run: NETWORK=naga-test bun run test:e2e all --timeout 5000000 |
| 80 | + timeout-minutes: 10 |
| 81 | + |
| 82 | + - name: Run health check for naga-staging |
| 83 | + run: NETWORK=naga-staging bun run test:e2e all --timeout 5000000 |
| 84 | + timeout-minutes: 10 |
| 85 | + |
| 86 | + # Release logic - only on push to main/naga branches (not PRs or feature branches) |
| 87 | + - name: Check release conditions |
| 88 | + id: release-check |
| 89 | + if: github.event_name == 'push' && (github.ref == 'refs/heads/naga' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') |
| 90 | + run: | |
| 91 | + echo "branch-eligible=true" >> $GITHUB_OUTPUT |
| 92 | + echo "✅ Branch is eligible for release" |
| 93 | +
|
| 94 | + - name: Check for changesets |
| 95 | + id: changesets |
| 96 | + if: steps.release-check.outputs.branch-eligible == 'true' || github.event_name == 'workflow_dispatch' |
| 97 | + uses: changesets/action@v1 |
| 98 | + with: |
| 99 | + version: echo "Checking for changesets..." |
| 100 | + env: |
| 101 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 102 | + |
| 103 | + - name: Release Beta (naga branch) |
| 104 | + if: steps.changesets.outputs.hasChangesets == 'true' && github.ref == 'refs/heads/naga' |
| 105 | + run: | |
| 106 | + echo "🚀 Publishing alpha release for naga branch" |
| 107 | + bun run changeset pre enter beta |
| 108 | + bun run changeset version |
| 109 | +
|
| 110 | + # This will probably fail because we have already entered `beta` mode, but let this fail and |
| 111 | + # see if it works so that we don't accidentally publish to `latest` |
| 112 | + bun run changeset publish --tag beta |
| 113 | + env: |
| 114 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 115 | + |
| 116 | + - name: Release Stable (main/master branch) |
| 117 | + if: steps.changesets.outputs.hasChangesets == 'true' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') |
| 118 | + run: | |
| 119 | + echo "🚀 Publishing stable release for main branch" |
| 120 | + bun run changeset pre exit |
| 121 | + bun run changeset version |
| 122 | + bun run changeset publish |
| 123 | + env: |
| 124 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 125 | + |
| 126 | + - name: No changesets found |
| 127 | + if: (steps.release-check.outputs.branch-eligible == 'true' || github.event_name == 'workflow_dispatch') && steps.changesets.outputs.hasChangesets != 'true' |
| 128 | + run: | |
| 129 | + echo "ℹ️ No changesets found - nothing to release" |
| 130 | + echo "To create a release, add changesets with: bun run changeset" |
| 131 | + echo "This is normal for documentation updates, refactoring, or other non-package changes" |
0 commit comments