-
Notifications
You must be signed in to change notification settings - Fork 4
82 lines (71 loc) · 2.27 KB
/
release.yaml
File metadata and controls
82 lines (71 loc) · 2.27 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
77
78
79
80
81
82
name: Create Release on Merge from Devel to Main
on:
push:
branches:
- main
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v2
- name: Get Latest Tag
id: get_latest_tag
run: |
git fetch --tags
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
latest_tag=${latest_tag:-'v0.0.0'}
echo "latest_tag=${latest_tag}" >> $GITHUB_ENV
- name: Determine Version Bump
id: version_bump
run: |
echo "Determining version bump from commit messages..."
major=0
minor=0
patch=0
# Get commit messages from last release tag to HEAD
commits=$(git log ${GITHUB_ENV[latest_tag]..HEAD --oneline --pretty=%B)
for commit in $commits; do
if [[ "$commit" == *"BREAKING CHANGE"* ]]; then
major=1
break
elif [[ "$commit" == *"feat:"* ]]; then
minor=1
elif [[ "$commit" == *"fix:"* ]]; then
patch=1
fi
done
IFS='.' read -r vmajor vminor vpatch <<< "${GITHUB_ENV[latest_tag]#v}"
if [[ "$major" -eq 1 ]]; then
vmajor=$((vmajor + 1))
vminor=0
vpatch=0
elif [[ "$minor" -eq 1 ]]; then
vminor=$((vminor + 1))
vpatch=0
elif [[ "$patch" -eq 1 ]]; then
vpatch=$((vpatch + 1))
fi
new_version="v${vmajor}.${vminor}.${vpatch}"
echo "new_version=${new_version}" >> $GITHUB_ENV
echo "New version is $new_version"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.new_version }}
release_name: Release ${{ env.new_version }}
draft: false
prerelease: false
- name: Upload Release Asset
if: steps.create_release.outputs.upload_url != ''
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: path/to/your/asset.zip
asset_name: asset.zip
asset_content_type: application/zip