-
Notifications
You must be signed in to change notification settings - Fork 16
51 lines (49 loc) · 1.77 KB
/
gh-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
name: "GitHub release"
on:
workflow_run:
workflows: [Test - DEV]
types:
- completed
permissions:
actions: 'write'
jobs:
github-release:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Create a GitHub release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.CICD_PAT_TOKEN }}
- name: Get last commit message
id: get-last-commit-message
run: echo COMMIT_MESSAGE="$(git log -1 --pretty=%B | cat | head -n 1)" >> "$GITHUB_OUTPUT"
- name: Cancel run if not a release commit
run: |
# done this way instead of "exit 1" to avoid having a failed run in the logs
IS_RELEASE_COMMIT=${{ contains(steps.get-last-commit-message.outputs.COMMIT_MESSAGE, format('chore(CI/CD){0} bump version', ':')) }}
if ! $IS_RELEASE_COMMIT; then
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}
fi
env:
GH_TOKEN: ${{ secrets.CICD_PAT_TOKEN }}
- name: Configure Git user
run: |
git config --local user.name "Kraina CI/CD"
git config --local user.email "cicd@kraina.ai"
- name: Extract release notes
id: extract-release-notes
uses: ffurrer2/extract-release-notes@v1
- name: Extract version
id: extract-version
uses: winterjung/split@v2
with:
msg: ${{ steps.get-last-commit-message.outputs.COMMIT_MESSAGE }}
- name: Release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.CICD_PAT_TOKEN }}
tag_name: ${{ steps.extract-version.outputs._5 }}
body: ${{ steps.extract-release-notes.outputs.release_notes }}