Skip to content

release note

release note #1

Workflow file for this run

name: Release sbot
on:
push:
tags: ['sbot-v*']
workflow_dispatch:
permissions:
contents: write
jobs:
release-sbot:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 10.33.0
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
registry-url: 'https://registry.npmjs.org'
- run: pnpm install --frozen-lockfile
- name: Build sbot
run: pnpm run build:sbot
- name: Resolve and verify version
id: version
shell: bash
run: |
PKG_VERSION=$(node -p "require('./packages/sbot/package.json').version")
if [ "${{ github.event_name }}" = "push" ]; then
TAG_VERSION="${GITHUB_REF_NAME#sbot-v}"
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
echo "::error::Tag version ($TAG_VERSION) does not match packages/sbot/package.json version ($PKG_VERSION)"
exit 1
fi
fi
echo "version=$PKG_VERSION" >> "$GITHUB_OUTPUT"
echo "tag=sbot-v$PKG_VERSION" >> "$GITHUB_OUTPUT"
- name: Extract release notes
id: notes
shell: bash
run: |
BODY=$(node -e "
const p = require('./packages/sbot/package.json');
const en = p.releasenoteEn || '';
const zh = p.releasenoteZh || '';
process.stdout.write([en, zh].filter(Boolean).join('\n\n'));
")
[ -z "$BODY" ] && BODY="sbot v${{ steps.version.outputs.version }}"
{
echo "body<<RELEASE_NOTES_EOF"
echo "$BODY"
echo "RELEASE_NOTES_EOF"
} >> "$GITHUB_OUTPUT"
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm --filter @qingfeng346/sbot publish --no-git-checks --access public
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker image
run: node packages/sbot/scripts/docker.js build
- name: Push Docker image
run: node packages/sbot/scripts/docker.js publish
- name: Create GitHub Release
if: github.event_name == 'push'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: 'sbot ${{ steps.version.outputs.tag }}'
body: ${{ steps.notes.outputs.body }}
draft: false
prerelease: false