-
-
Notifications
You must be signed in to change notification settings - Fork 10
72 lines (59 loc) · 1.94 KB
/
publish.yml
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
name: Publish to GitHub Releases
on:
push:
branches: [master]
jobs:
build-and-deploy:
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20
- name: Cache dependencies and build outputs
uses: actions/cache@v2
with:
path: ~/.npm
key: "${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}"
restore-keys: ${{ runner.os }}-node-
- name: Install dependencies
run: npm ci
- name: Check version changes
id: check-version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "VERSION=$VERSION" >> $GITHUB_ENV
if git tag | grep -q "v$VERSION"; then
echo "The version has not changed."
echo "::set-output name=changed::false"
else
echo "The version has changed."
echo "::set-output name=changed::true"
fi
- name: Build
run: npm run build
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: build
path: dist/
- name: Extract release notes
id: release-notes
run: |
RELEASE_NOTES=$(awk -v version="$VERSION" '/## \[/{flag=0} /## \['$version'\]/{flag=1} flag' CHANGELOG.md)
echo "RELEASE_NOTES=$RELEASE_NOTES" >> $GITHUB_ENV
- name: Create a GitHub Release
if: steps.check-version.outputs.changed == 'true'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: v${{ env.VERSION }}
draft: false
prerelease: false
body: |
**What's new in this release?**
${{ env.RELEASE_NOTES }}