Setup trusted publishing #162
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: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| id-token: write | |
| jobs: | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Generate GitHub App Token | |
| id: generate-token | |
| uses: actions/create-github-app-token@v2 | |
| with: | |
| app-id: ${{ secrets.AI_ELEMENTS_APP_ID }} | |
| private-key: ${{ secrets.AI_ELEMENTS_APP_PRIVATE_KEY }} | |
| - name: Checkout Repo | |
| uses: actions/checkout@v6 | |
| with: | |
| token: ${{ steps.generate-token.outputs.token }} | |
| - name: Setup Git User | |
| run: | | |
| git config --global user.email "ai-elements-bot[bot]@users.noreply.github.com" | |
| git config --global user.name "ai-elements-bot[bot]" | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: '24' | |
| registry-url: 'https://registry.npmjs.org' | |
| # Ensure npm 11.5.1 or later is installed | |
| - name: Update npm | |
| run: npm install -g npm@latest | |
| - name: Install Dependencies | |
| run: pnpm i | |
| - name: Install Playwright Browsers | |
| run: pnpm --filter @repo/elements exec playwright install --with-deps chromium | |
| - name: Build Packages | |
| run: pnpm build --filter ai-elements | |
| - name: Run Tests | |
| run: pnpm test | |
| - name: Create Release Pull Request or Publish to npm | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| version: pnpm changeset version | |
| publish: pnpm changeset publish | |
| env: | |
| GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} | |
| NPM_TOKEN: "" # Workaround for https://github.com/changesets/action/pull/545 | |
| - name: Deploy to Vercel | |
| if: steps.changesets.outputs.published == 'true' | |
| run: npx vercel --prod --token=${{ secrets.VERCEL_TOKEN }} | |
| env: | |
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} |