-
Notifications
You must be signed in to change notification settings - Fork 23
48 lines (43 loc) · 1.47 KB
/
release.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
name: Release
on:
push:
branches:
- main
jobs:
publish-github:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Extract version
id: version
run: |
OLD_VERSION=$(git describe --tags --abbrev=0)
NEW_VERSION_NUMBER_ONLY=$(node -p 'require("./package.json").version')
NEW_VERSION=v${NEW_VERSION_NUMBER_ONLY}
echo "OLD_VERSION=$OLD_VERSION" >> $GITHUB_ENV
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
if [ "$NEW_VERSION" != "$OLD_VERSION" ]; then
echo "New version $NEW_VERSION detected"
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
git log "$OLD_VERSION"..HEAD --pretty=format:"* %s" --invert-grep --grep="$NEW_VERSION_NUMBER_ONLY" > CHANGELOG.md
else
echo "Version $OLD_VERSION hasn't changed, skipping the release"
fi
- name: Create a git tag
if: env.NEW_VERSION != env.OLD_VERSION
run: git tag $NEW_VERSION && git push --tags
- name: GitHub release
if: env.NEW_VERSION != env.OLD_VERSION
uses: actions/create-release@v1
id: create_release
with:
draft: false
prerelease: false
release_name: ${{ env.NEW_VERSION }}
tag_name: ${{ env.NEW_VERSION }}
body_path: CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}