-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (48 loc) · 1.98 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
49
50
51
52
53
54
55
56
57
58
# This workflow will create a new release every time a new version is encountered in package.json on the main branch
name: Release
on:
push:
branches:
- main
jobs:
tag:
runs-on: ubuntu-latest
steps:
- name: Checkout commit
uses: actions/checkout@v2
with:
fetch-depth: 0
ssh-key: ${{ secrets.HFC_BOT_SSH_KEY }}
- name: git config
run: |
git config user.name hfc-bot
git config user.email [email protected]
- name: Check if tag already exists
run: |
# Get version from package.json (head is needed because this also returns "version" npm script line)
sed -n '/version/s/,*\r*$//p' package.json | cut -d ':' -f2,3 | sed -e 's/^ "//' -e 's/"$//' | head -n 1 > app_version.tmp
export VERSION_TAG="v$(cat app_version.tmp)"
echo "package_version=$(cat app_version.tmp)" >> $GITHUB_ENV
# Check if tag already exists
if [ $(git tag -l "$VERSION_TAG") ]; then
echo "Tag already exists, please increment version to create release"
echo "create_release=no" >> $GITHUB_ENV
else
echo "create_release=yes" >> $GITHUB_ENV
fi
- name: Generate Changelog
run: cat CHANGELOG.md | grep -Pzo "## ${{ env.package_version }}\s+((.|\n)+?)(?=\n##\s)" | head -n -1 > ${{ github.workflow }}-CHANGELOG.md
- name: Create Tag (from hfc-bot)
if: ${{ env.create_release == 'yes' }}
run: |
git tag -a v${{ env.package_version }} -m "v${{ env.package_version }}"
git push --follow-tags
- name: Release
uses: softprops/action-gh-release@master
if: ${{ env.create_release == 'yes' }}
with:
body_path: ${{ github.workflow }}-CHANGELOG.md
tag_name: v${{ env.package_version }}
target_commitish: ${{ github.sha }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}