-
Notifications
You must be signed in to change notification settings - Fork 6
61 lines (52 loc) · 2.24 KB
/
tag-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
59
60
61
name: Tag release
on:
pull_request:
types: [ closed ]
branches:
- dev
- release/*
jobs:
# Creates a new tag if a release branch is merged
tag-bump:
if: |
github.event.pull_request.merged == true &&
((startsWith(github.event.pull_request.head.ref, 'release/') && github.event.pull_request.base.ref == 'dev') ||
(startsWith(github.event.pull_request.head.ref, 'hotfix/') && startsWith(github.event.pull_request.base.ref, 'release/')))
runs-on: ubuntu-latest
steps:
- name: Git config
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global url."https://${{ secrets.REPO_TOKEN }}@github.com/".insteadOf ssh://[email protected]
git config --global url."https://${{ secrets.REPO_TOKEN }}@github.com".insteadOf https://github.com
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version
id: get-version
run: |
VERSION=$(echo "${{ github.event.pull_request.head.ref }}" | cut -d'/' -f 2)
RELEASE_BRANCH="${{ startsWith(github.event.pull_request.head.ref, 'release/') && github.event.pull_request.head.ref || github.event.pull_request.base.ref }}"
if [[ "${{ startsWith(github.event.pull_request.head.ref, 'release/') }}" == "true" ]]; then
VERSION="${VERSION}.0"
fi
git tag -a $VERSION -m "$VERSION" origin/$RELEASE_BRANCH
git push origin $VERSION --follow-tags
echo "version=$VERSION" | tee -a "$GITHUB_OUTPUT"
echo "RELEASE_BRANCH=$RELEASE_BRANCH" | tee -a "$GITHUB_ENV"
- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v5
with:
toTag: ${{ steps.get-version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
uses: ncipollo/release-action@v1
with:
body: ${{ steps.github_release.outputs.changelog }}
tag: ${{ steps.get-version.outputs.version }}
commit: ${{ env.RELEASE_BRANCH }}
allowUpdates: true