|
| 1 | +# Snapshot Releases Workflow |
| 2 | + |
| 3 | +# Purpose |
| 4 | +# This workflow allows you to create snapshot releases for testing changes in a pull request |
| 5 | +# before a full release, without entering pre-release mode. |
| 6 | + |
| 7 | +# Problem |
| 8 | +# Changesets enforce pre-release mode across all packages in our mono repo, blocking stable |
| 9 | +# releases until pre-release mode is exited. |
| 10 | + |
| 11 | +# Snapshot Releases |
| 12 | +# This workflow enables one-off releases from specific branches, known as snapshot releases. |
| 13 | +# These are published under the `snapshot` dist-tag with versions like |
| 14 | +# `0.4.0-b16419cd576a883e1ddde01bd2fe3f5f54bcc52a-20230913164912`, which include the |
| 15 | +# generated version, commit hash, and timestamp. |
| 16 | + |
| 17 | +# Creating a Snapshot Release |
| 18 | +# 1. Push your branch to GitHub and commit a changeset. Generate a changeset with `pnpm changeset`. |
| 19 | +# 2. Go to the LangbaseInc/baseai repository on GitHub. |
| 20 | +# 3. Navigate to Actions > Release Snapshot. |
| 21 | +# 4. Click "Run workflow", select your branch, and click "Run workflow". |
| 22 | +# Inspired by turbo repo. |
| 23 | + |
| 24 | +name: Release Snapshot |
| 25 | + |
| 26 | +on: |
| 27 | + workflow_dispatch: |
| 28 | + |
| 29 | +jobs: |
| 30 | + release-snapshot: |
| 31 | + name: Release Snapshot |
| 32 | + runs-on: ubuntu-latest |
| 33 | + steps: |
| 34 | + - name: Checkout Repo |
| 35 | + uses: actions/checkout@v4 |
| 36 | + with: |
| 37 | + fetch-depth: 0 |
| 38 | + |
| 39 | + - name: Setup pnpm 8 |
| 40 | + uses: pnpm/action-setup@v2 |
| 41 | + with: |
| 42 | + version: 8.6.9 |
| 43 | + |
| 44 | + - name: Setup Node.js 18.x |
| 45 | + uses: actions/setup-node@v2 |
| 46 | + with: |
| 47 | + node-version: 18.x |
| 48 | + |
| 49 | + - name: Add npm auth token to pnpm |
| 50 | + run: pnpm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" |
| 51 | + env: |
| 52 | + NPM_TOKEN: ${{secrets.NPM_TOKEN}} |
| 53 | + |
| 54 | + - name: Install Dependencies |
| 55 | + run: pnpm i |
| 56 | + |
| 57 | + - name: Build |
| 58 | + run: pnpm clean && pnpm build |
| 59 | + |
| 60 | + - name: Add SHORT_SHA env property with commit short sha |
| 61 | + run: echo "SHORT_SHA=`echo ${{ github.sha }} | cut -c1-8`" >> $GITHUB_ENV |
| 62 | + |
| 63 | + - name: Create Snapshot Release |
| 64 | + run: | |
| 65 | + pnpm changeset version --snapshot ${SHORT_SHA} |
| 66 | + pnpm clean-examples |
| 67 | + pnpm changeset publish --no-git-tag --tag snapshot |
| 68 | + env: |
| 69 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments