Skip to content

Commit ac26771

Browse files
author
while
committed
工作流
1 parent 8886133 commit ac26771

1 file changed

Lines changed: 89 additions & 0 deletions

File tree

‎.github/workflows/release-sbot.yml‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Release sbot
2+
3+
on:
4+
push:
5+
tags: ['sbot-v*']
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release-sbot:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: pnpm/action-setup@v4
18+
with:
19+
version: 10.33.0
20+
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version: 20
24+
cache: pnpm
25+
registry-url: 'https://registry.npmjs.org'
26+
27+
- run: pnpm install --frozen-lockfile
28+
29+
- name: Build sbot
30+
run: pnpm run build:sbot
31+
32+
- name: Resolve and verify version
33+
id: version
34+
shell: bash
35+
run: |
36+
PKG_VERSION=$(node -p "require('./packages/sbot/package.json').version")
37+
if [ "${{ github.event_name }}" = "push" ]; then
38+
TAG_VERSION="${GITHUB_REF_NAME#sbot-v}"
39+
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
40+
echo "::error::Tag version ($TAG_VERSION) does not match packages/sbot/package.json version ($PKG_VERSION)"
41+
exit 1
42+
fi
43+
fi
44+
echo "version=$PKG_VERSION" >> "$GITHUB_OUTPUT"
45+
echo "tag=sbot-v$PKG_VERSION" >> "$GITHUB_OUTPUT"
46+
47+
- name: Extract release notes
48+
id: notes
49+
shell: bash
50+
run: |
51+
BODY=$(node -e "
52+
const p = require('./packages/sbot/package.json');
53+
const en = p.releasenoteEn || '';
54+
const zh = p.releasenoteZh || '';
55+
process.stdout.write([en, zh].filter(Boolean).join('\n\n'));
56+
")
57+
[ -z "$BODY" ] && BODY="sbot v${{ steps.version.outputs.version }}"
58+
{
59+
echo "body<<RELEASE_NOTES_EOF"
60+
echo "$BODY"
61+
echo "RELEASE_NOTES_EOF"
62+
} >> "$GITHUB_OUTPUT"
63+
64+
- name: Publish to npm
65+
env:
66+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
67+
run: pnpm --filter @qingfeng346/sbot publish --no-git-checks --access public
68+
69+
- name: Login to Docker Hub
70+
uses: docker/login-action@v3
71+
with:
72+
username: ${{ secrets.DOCKERHUB_USERNAME }}
73+
password: ${{ secrets.DOCKERHUB_TOKEN }}
74+
75+
- name: Build Docker image
76+
run: node packages/sbot/scripts/docker.js build
77+
78+
- name: Push Docker image
79+
run: node packages/sbot/scripts/docker.js publish
80+
81+
- name: Create GitHub Release
82+
if: github.event_name == 'push'
83+
uses: softprops/action-gh-release@v2
84+
with:
85+
tag_name: ${{ github.ref_name }}
86+
name: 'sbot ${{ steps.version.outputs.tag }}'
87+
body: ${{ steps.notes.outputs.body }}
88+
draft: false
89+
prerelease: false

0 commit comments

Comments
 (0)