-
Notifications
You must be signed in to change notification settings - Fork 4
72 lines (62 loc) · 2.09 KB
/
Copy pathCI-build.yml
File metadata and controls
72 lines (62 loc) · 2.09 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
# build, create a release, and publish to npm after successful CI
name: CI build
on:
workflow_run:
workflows:
- "CI"
types:
- "completed"
branches: [master]
jobs:
on-success:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
permissions:
contents: write
id-token: write
steps:
- name: Generate release token
id: app-token
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
- uses: actions/checkout@v6
with:
ref: master
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- uses: actions/setup-node@v6
with:
node-version: 22
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- run: corepack enable npm && corepack prepare npm@11.13.0 --activate
# build dist folder
- run: npm ci
- run: npm run build
- name: Set up Git commit author
run: |
git config --local user.name "bitsocial-release-bot[bot]"
git config --local user.email "3419549+bitsocial-release-bot[bot]@users.noreply.github.com"
- name: Get current version
id: before
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Create Github Release
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: npm run release -- --ci
- name: Check if released
id: release
run: |
AFTER=$(node -p "require('./package.json').version")
if [ "${{ steps.before.outputs.version }}" != "$AFTER" ]; then
echo "Released v$AFTER"
echo "released=true" >> $GITHUB_OUTPUT
else
echo "No new version to release"
echo "released=false" >> $GITHUB_OUTPUT
fi
- name: Publish to npm
if: steps.release.outputs.released == 'true'
run: npx --yes npm@latest publish --access public --provenance