mirror of
https://github.com/benngaihk/Tiptap-UI-Kit.git
synced 2026-12-05 16:01:47 +00:00
Fail releases when npm authentication is unavailable and verify the published version.
102 lines
2.6 KiB
YAML
102 lines
2.6 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
release:
|
|
name: Create Release
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 9.15.9
|
|
|
|
- name: Verify NPM authentication
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
run: |
|
|
if [ -z "$NODE_AUTH_TOKEN" ]; then
|
|
echo "::error::NPM_TOKEN is not configured. Add it in Settings > Secrets and variables > Actions."
|
|
exit 1
|
|
fi
|
|
|
|
npm whoami
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Build
|
|
run: pnpm build
|
|
env:
|
|
NODE_ENV: production
|
|
|
|
- name: Extract version from tag
|
|
id: get_version
|
|
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Generate changelog
|
|
id: changelog
|
|
run: |
|
|
previous_tag="$(git tag --sort=-creatordate --merged HEAD | grep -v "^${GITHUB_REF_NAME}$" | head -n 1 || true)"
|
|
|
|
{
|
|
echo "CHANGELOG<<EOF"
|
|
if [ -n "$previous_tag" ]; then
|
|
git log "${previous_tag}..HEAD" --pretty=format:"- %s (%h)"
|
|
else
|
|
git log -20 --pretty=format:"- %s (%h)"
|
|
fi
|
|
echo
|
|
echo "EOF"
|
|
} >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
name: Release ${{ steps.get_version.outputs.VERSION }}
|
|
body: |
|
|
## What's Changed
|
|
|
|
${{ steps.changelog.outputs.CHANGELOG }}
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
npm install tiptap-ui-kit@${{ steps.get_version.outputs.VERSION }}
|
|
```
|
|
|
|
See [CHANGELOG.md](https://github.com/benngaihk/Tiptap-UI-Kit/blob/main/CHANGELOG.md) for full details.
|
|
draft: false
|
|
prerelease: false
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Publish to NPM
|
|
run: pnpm publish --no-git-checks --access public
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
|
- name: Verify NPM release
|
|
env:
|
|
VERSION: ${{ steps.get_version.outputs.VERSION }}
|
|
run: npm view "tiptap-ui-kit@$VERSION" version
|