-
Notifications
You must be signed in to change notification settings - Fork 5
89 lines (71 loc) · 2.21 KB
/
cd.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: CI
on:
schedule:
- cron: '0 0 * * *'
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
actions: read
checks: write
deployments: write
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install Dependencies
run: npm install
- name: Check if package.json has changed
id: check
run: |
if [ $(git diff --name-only HEAD^1 HEAD | grep 'package.json' | wc -l) -eq 0 ]; then
echo "No version change detected in package.json."
else
echo "Version change detected."
fi
- name: Create npm package
run: npm pack
- name: Extract package contents
run: npm pack
id: npm_pack
- name: Checkout release branch
uses: actions/checkout@v4
path: './release'
- name: Checkout release branch
run: |
cd ./release
git checkout release
- name: Extract package contents
run: |
tar -xzf *.tgz --strip-components=1 -C ./release
- name: Set up Git use
run: |
git config --global user.email "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Push package contents to a new branch
run: |
VERSION=$(jq -r '.version' package.json)
cd ./release
git add .
git commit -m "Release ${VERSION}"
- name: Generate release notes
run: |
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^1)
GIT_LOG=$(git log --pretty=format:"%h - %s (%an)" "${PREV_TAG}..HEAD")
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
echo "${GIT_LOG}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Printing release notes
run: |
echo ${{ env.RELEASE_NOTES }}
echo ${{ env.GIT_LOG }}
echo ${{ env.RELEASE_NOTES }}
echo v${{ steps.check.outputs.version }}