-
Notifications
You must be signed in to change notification settings - Fork 5
76 lines (75 loc) · 2.29 KB
/
release.yml
File metadata and controls
76 lines (75 loc) · 2.29 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
name: Create new release
on:
push:
branches:
- master
jobs:
changesets:
runs-on: ubuntu-latest
outputs:
should_publish: ${{ steps.check_release.outputs.should_publish }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get tags
run: git fetch --tags origin
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '24'
- name: Install dependencies
run: npm ci
- name: Create Release Pull Request
id: changesets
uses: changesets/action@v1
with:
title: 'New Release'
commit: 'Release new version'
env:
GITHUB_TOKEN: ${{ secrets.SDK_PUBLISH_TOKEN }}
- name: Create new release
id: check_release
if: steps.changesets.outputs.hasChangesets == 'false'
run: |
npx changeset tag && git push origin --tags
COMMIT_TAG=$(git tag --points-at HEAD)
if [ -n "$COMMIT_TAG" ]; then
echo "A tag is attached to HEAD. Creating a new release..."
echo "${{ secrets.SDK_PUBLISH_TOKEN }}" | gh auth login --with-token
CHANGELOG=$(awk '
BEGIN { recording=0; }
/^## / {
if(recording) { exit; }
recording=1;
next;
}
recording {
print;
}
' CHANGELOG.md)
gh release create $COMMIT_TAG -t "$COMMIT_TAG" -n "$CHANGELOG"
echo "should_publish=true" >> "$GITHUB_OUTPUT"
else
echo "No tag attached to HEAD. No new release needed."
echo "should_publish=false" >> "$GITHUB_OUTPUT"
fi
publish:
needs: changesets
if: needs.changesets.outputs.should_publish == 'true'
runs-on: ubuntu-latest
environment: production
permissions:
id-token: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Publish to npm
run: npm publish