-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (74 loc) · 2.75 KB
/
Copy pathrelease-cli.yml
File metadata and controls
86 lines (74 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Release CLI
on:
push:
tags: ['cli-v*']
workflow_dispatch:
permissions:
contents: write
concurrency:
group: release-cli-${{ github.ref }}
cancel-in-progress: false
jobs:
release-cli:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: while-coder/workflows/.github/actions/setup-pnpm@main
- run: pnpm install --frozen-lockfile
- name: Build cli
run: pnpm run build:cli
- name: Resolve and verify version
id: version
shell: bash
run: |
PKG_VERSION=$(node -p "require('./packages/apps/sbot-cli/package.json').version")
if [ "${{ github.event_name }}" = "push" ]; then
TAG_VERSION="${GITHUB_REF_NAME#cli-v}"
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
echo "::error::Tag version ($TAG_VERSION) does not match packages/apps/sbot-cli/package.json version ($PKG_VERSION)"
exit 1
fi
fi
echo "version=$PKG_VERSION" >> "$GITHUB_OUTPUT"
echo "tag=cli-v$PKG_VERSION" >> "$GITHUB_OUTPUT"
- name: Extract release notes
id: notes
shell: bash
run: |
BODY=$(node -e "
const p = require('./packages/apps/sbot-cli/package.json');
const en = p.releasenoteEn || '';
const zh = p.releasenoteZh || '';
process.stdout.write([en, zh].filter(Boolean).join('\n\n'));
")
[ -z "$BODY" ] && BODY="sbot-cli v${{ steps.version.outputs.version }}"
{
echo "body<<RELEASE_NOTES_EOF"
echo "$BODY"
echo "RELEASE_NOTES_EOF"
} >> "$GITHUB_OUTPUT"
- name: Check npm package version
id: npm
if: github.event_name == 'push'
shell: bash
run: |
if npm view "sbot-cli@${{ steps.version.outputs.version }}" version >/dev/null 2>&1; then
echo "published=true" >> "$GITHUB_OUTPUT"
echo "sbot-cli@${{ steps.version.outputs.version }} is already published; skipping npm publish."
else
echo "published=false" >> "$GITHUB_OUTPUT"
fi
- name: Publish to npm
if: github.event_name == 'push' && steps.npm.outputs.published != 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm --filter sbot-cli publish --no-git-checks
- name: Recreate GitHub Release
if: github.event_name == 'push'
uses: while-coder/workflows/.github/actions/recreate-github-release@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
title: sbot-cli v${{ steps.version.outputs.version }}
notes: ${{ steps.notes.outputs.body }}
draft: 'true'