Files
AIPex/.github/workflows/release.yml
dependabot[bot] b239e7233d build(deps): bump pnpm/action-setup from 4 to 5 (#188)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-23 15:12:29 +08:00

72 lines
2.1 KiB
YAML

name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
id-token: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: pnpm/action-setup@v5
with:
version: 10
- uses: actions/setup-node@v6
with:
node-version: lts/*
cache: pnpm
registry-url: 'https://registry.npmjs.org'
- run: npx changelogithub
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build
- name: Determine npm tag
id: determine_npm_tag
shell: bash
run: |
TAG="${GITHUB_REF#refs/tags/}"
if [[ "$TAG" =~ -(next|canary|beta|rc) ]]; then
# Extract pre-release tag (e.g., beta, rc)
NPM_TAG=${BASH_REMATCH[1]}
else
# Check if the commit is on the main branch or a version branch
git fetch origin main
CURRENT_BRANCH=$(git branch -r --contains "$GITHUB_SHA" | grep -E 'origin/(main|v[0-9]+\.[0-9]+\.x-latest)' | head -1 | sed 's/.*origin\///')
if [[ "$CURRENT_BRANCH" == "main" ]]; then
NPM_TAG="latest"
elif [[ "$CURRENT_BRANCH" =~ ^v[0-9]+\.[0-9]+\.x-latest$ ]]; then
# For version branches like v1.3.x-latest, v1.4.x-latest, use "latest" tag
NPM_TAG="latest"
else
echo "The tagged commit is not on the main branch or a version branch (v*.*.x-latest)."
echo "::error ::Releases with the 'latest' npm tag must be on the main branch or a version branch."
exit 1
fi
fi
echo "npm_tag=$NPM_TAG" >> $GITHUB_OUTPUT
echo "Using npm tag: $NPM_TAG"
- name: Publish to npm
run: pnpm -r publish --access public --no-git-checks --tag ${{ steps.determine_npm_tag.outputs.npm_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true