|
| 1 | +name: Branch Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '**' |
| 7 | + - '!main' |
| 8 | + |
| 9 | +jobs: |
| 10 | + branch-release: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + fetch-depth: 0 # Fetch all history to get the latest tag |
| 16 | + |
| 17 | + - name: Setup Node.js |
| 18 | + uses: actions/setup-node@v4 |
| 19 | + with: |
| 20 | + node-version: '20' |
| 21 | + |
| 22 | + - name: Install pnpm |
| 23 | + uses: pnpm/action-setup@v2 |
| 24 | + with: |
| 25 | + version: latest |
| 26 | + |
| 27 | + - name: Cache pnpm modules |
| 28 | + uses: actions/cache@v4 |
| 29 | + with: |
| 30 | + path: | |
| 31 | + ~/.pnpm-store |
| 32 | + node_modules |
| 33 | + src/playground/node_modules |
| 34 | + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 35 | + restore-keys: | |
| 36 | + ${{ runner.os }}-pnpm- |
| 37 | +
|
| 38 | + - name: Install Dependencies |
| 39 | + run: pnpm install --frozen-lockfile |
| 40 | + |
| 41 | + - name: Build |
| 42 | + run: pnpm run build |
| 43 | + |
| 44 | + - name: Set Version from Branch |
| 45 | + run: | |
| 46 | + BRANCH_NAME=${GITHUB_REF#refs/heads/} |
| 47 | + BRANCH_NAME=${BRANCH_NAME//\//-} # Replace slashes with dashes |
| 48 | + SHORT_SHA=$(git rev-parse --short HEAD) |
| 49 | +
|
| 50 | + # Get the latest version tag and increment patch |
| 51 | + LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") |
| 52 | + LATEST_VERSION=${LATEST_TAG#v} # Remove 'v' prefix |
| 53 | +
|
| 54 | + # Split version into major.minor.patch |
| 55 | + IFS='.' read -r major minor patch <<< "$LATEST_VERSION" |
| 56 | +
|
| 57 | + # Increment patch version |
| 58 | + patch=$((patch + 1)) |
| 59 | + BASE_VERSION="${major}.${minor}.${patch}" |
| 60 | +
|
| 61 | + VERSION="${BASE_VERSION}-${BRANCH_NAME}-${SHORT_SHA}" |
| 62 | + pnpm version $VERSION --no-git-tag-version |
| 63 | +
|
| 64 | + - name: Configure NPM Authentication |
| 65 | + run: | |
| 66 | + echo "@bitte-ai:registry=https://registry.npmjs.org/" > ~/.npmrc |
| 67 | + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc |
| 68 | +
|
| 69 | + - name: Publish with npm |
| 70 | + run: npm publish --access public --tag beta |
| 71 | + env: |
| 72 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments