-
Notifications
You must be signed in to change notification settings - Fork 1
78 lines (69 loc) · 2.73 KB
/
create-tag-and-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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Tag and Release
on:
pull_request:
types: [ closed ]
jobs:
extract-info:
# PR이 merge 되었을 때만 실행 (merge가 아닌 close는 제외)
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
repository-projects: write
outputs:
module: ${{ steps.module_prefix.outputs.module }}
tag: ${{ steps.tag_version.outputs.new_tag }}
steps:
- name: Checkout PR
uses: actions/checkout@v4
# PR 제목으로 부터 모듈명 추출 (ex. Api, Batch, Admin, Socket)
- name: extract PR info
id: module_prefix
run: |
PR_TITLE="${{ github.event.pull_request.title }}"
echo "PR title : $PR_TITLE"
if [[ "$PR_TITLE" =~ ^(Api|Batch|Admin|Socket): ]]; then
PREFIX="${BASH_REMATCH[1]}"
echo "Prefix: $PREFIX"
echo "module=$PREFIX" >> $GITHUB_OUTPUT
else
echo "PR title does not match the pattern"
exit 1
fi
# 병합된 PR commit 이력으로 부터 버전 추출 (ex. v1.0.0)
- name: version and tag
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: patch
release_branches: main,dev.*
custom_release_rules: release:major, feat:minor:Features, refactor:minor:Refactoring, fix:patch:Bug Fixes, hotfix:patch:Hotfixes, docs:patch:Documentation, style:patch:Styles, perf:patch:Performance Improvements, test:patch:Tests, ci:patch:Continuous Integration, chore:patch:Chores, revert:patch:Reverts
tag_prefix: '${{ steps.module_prefix.outputs.module }}-v'
# 추출된 버전 및 변경 이력 로그 출력
- name: check output
run: |
echo "new_tag : ${{ steps.tag_version.outputs.new_tag }}"
echo "change_log : ${{ steps.tag_version.outputs.changelog }}"
# GitHub Release 생성
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
call-external-api-deploy:
needs: extract-info
if: ${{ needs.extract-info.outputs.module == 'Api' }}
uses: ./.github/workflows/deploy-external-api.yml
secrets: inherit
with:
tags: ${{ needs.extract-info.outputs.tag }}
call-batch-deploy:
needs: extract-info
if: ${{ needs.extract-info.outputs.module == 'Batch' }}
uses: ./.github/workflows/deploy-batch.yml
secrets: inherit
with:
tags: ${{ needs.extract-info.outputs.tag }}