|
| 1 | +--- |
| 2 | +name: main |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + pull_request: |
| 8 | + branches: [main] |
| 9 | + types: [opened, synchronize, reopened, ready_for_review] |
| 10 | + workflow_dispatch: |
| 11 | + inputs: |
| 12 | + dry-run: |
| 13 | + description: Dry run |
| 14 | + default: true |
| 15 | + required: false |
| 16 | + type: boolean |
| 17 | + |
| 18 | +concurrency: |
| 19 | + group: ${{ github.workflow }}-${{ github.event.number || github.ref }} |
| 20 | + cancel-in-progress: true |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: read |
| 24 | + |
| 25 | +jobs: |
| 26 | + build: |
| 27 | + name: Build |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 31 | + |
| 32 | + - name: Setup Bun |
| 33 | + uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2.1.2 |
| 34 | + |
| 35 | + - name: Install dependencies |
| 36 | + run: bun install --frozen-lockfile |
| 37 | + |
| 38 | + - name: Build |
| 39 | + run: bun run build |
| 40 | + |
| 41 | + typecheck: |
| 42 | + name: Typecheck |
| 43 | + runs-on: ubuntu-latest |
| 44 | + steps: |
| 45 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 46 | + |
| 47 | + - name: Setup Bun |
| 48 | + uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2.1.2 |
| 49 | + |
| 50 | + - name: Install dependencies |
| 51 | + run: bun install --frozen-lockfile |
| 52 | + |
| 53 | + - name: Typecheck |
| 54 | + run: bun run typecheck |
| 55 | + |
| 56 | + lint: |
| 57 | + name: Lint |
| 58 | + runs-on: ubuntu-latest |
| 59 | + steps: |
| 60 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 61 | + |
| 62 | + - name: Setup Bun |
| 63 | + uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2.1.2 |
| 64 | + |
| 65 | + - name: Install dependencies |
| 66 | + run: bun install --frozen-lockfile |
| 67 | + |
| 68 | + - name: Lint codebase |
| 69 | + run: bun run lint |
| 70 | + |
| 71 | + test: |
| 72 | + name: Test |
| 73 | + runs-on: ubuntu-latest |
| 74 | + steps: |
| 75 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 76 | + |
| 77 | + - name: Setup Bun |
| 78 | + uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2.1.2 |
| 79 | + |
| 80 | + - name: Install dependencies |
| 81 | + run: bun install --frozen-lockfile |
| 82 | + |
| 83 | + - name: Run tests |
| 84 | + run: bun test tests/unit |
| 85 | + |
| 86 | + release: |
| 87 | + env: |
| 88 | + DRY_RUN: ${{ github.event_name == 'pull_request' || github.event.inputs.dry-run && 'true' || 'false' }} |
| 89 | + name: Release |
| 90 | + needs: [build, typecheck, lint, test] |
| 91 | + runs-on: ubuntu-latest |
| 92 | + permissions: |
| 93 | + contents: write |
| 94 | + id-token: write |
| 95 | + issues: write |
| 96 | + pull-requests: write |
| 97 | + steps: |
| 98 | + - id: get-workflow-app-token |
| 99 | + name: Get Workflow Application Token |
| 100 | + uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 |
| 101 | + with: |
| 102 | + app-id: ${{ secrets.APPLICATION_ID }} |
| 103 | + private-key: ${{ secrets.APPLICATION_PRIVATE_KEY }} |
| 104 | + |
| 105 | + - id: setup-git-user |
| 106 | + name: Get GitHub App User ID and Setup Git user |
| 107 | + env: |
| 108 | + GH_TOKEN: ${{ steps.get-workflow-app-token.outputs.token }} |
| 109 | + run: | |
| 110 | + name="${{ steps.get-workflow-app-token.outputs.app-slug }}[bot]" |
| 111 | + user_id=$(gh api "/users/${name}" --jq .id) |
| 112 | + email="${user_id}+${name}@users.noreply.github.com" |
| 113 | + echo "user-email=${email}" >> "$GITHUB_OUTPUT" |
| 114 | + echo "user-name=${name}" >> "$GITHUB_OUTPUT" |
| 115 | + git config --global user.email "${email}" |
| 116 | + git config --global user.name "${name}" |
| 117 | +
|
| 118 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 119 | + with: |
| 120 | + fetch-depth: 0 |
| 121 | + persist-credentials: false |
| 122 | + token: ${{ steps.get-workflow-app-token.outputs.token }} |
| 123 | + |
| 124 | + - name: Setup Bun |
| 125 | + uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2.1.2 |
| 126 | + |
| 127 | + - name: Setup Node.js for NPM publishing |
| 128 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
| 129 | + with: |
| 130 | + node-version: 22 |
| 131 | + registry-url: 'https://registry.npmjs.org' |
| 132 | + |
| 133 | + - name: Install dependencies |
| 134 | + run: bun install --frozen-lockfile |
| 135 | + |
| 136 | + - name: Build |
| 137 | + run: bun run build |
| 138 | + |
| 139 | + - name: Get Release Options |
| 140 | + env: |
| 141 | + INPUT_DRY_RUN: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.dry-run && 'true' || 'false' }} |
| 142 | + IS_DEFAULT_BRANCH: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} |
| 143 | + run: | |
| 144 | + if [[ $DRY_RUN != 'true' || $IS_DEFAULT_BRANCH == 'true' ]]; then |
| 145 | + echo "DRY_RUN=false" >> $GITHUB_ENV |
| 146 | + fi |
| 147 | +
|
| 148 | + - name: Semantic Release |
| 149 | + id: semantic-release |
| 150 | + env: |
| 151 | + CI_FLAG: ${{ env.DRY_RUN == 'true' && 'false' || 'true' }} |
| 152 | + GIT_AUTHOR_EMAIL: ${{ steps.setup-git-user.outputs.user-email }} |
| 153 | + GIT_AUTHOR_NAME: ${{ steps.setup-git-user.outputs.user-name }} |
| 154 | + GIT_COMMITTER_EMAIL: ${{ steps.setup-git-user.outputs.user-email }} |
| 155 | + GIT_COMMITTER_NAME: ${{ steps.setup-git-user.outputs.user-name }} |
| 156 | + GITHUB_TOKEN: ${{ steps.get-workflow-app-token.outputs.token }} |
| 157 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 158 | + NPM_CONFIG_PROVENANCE: true |
| 159 | + run: | |
| 160 | + npx semantic-release --dry-run ${{ env.DRY_RUN }} --ci ${{ env.CI_FLAG }} |
| 161 | + shell: 'bash -Eeuxo pipefail {0}' |
0 commit comments