-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (56 loc) · 1.92 KB
/
create-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
name: Create Release
on:
pull_request:
branches:
- production
types:
- closed
workflow_dispatch:
inputs:
increment_type:
type: choice
description: Version increment type
default: patch
options:
- patch
- minor
- major
version:
type: string
description: Specific release version (e.g., 1.2.3)
jobs:
create_release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Extract release version from Pull Request title
id: extract-version-from-pr-title
shell: bash
if: ${{ !github.event.inputs.version && github.event.pull_request.merged }}
run: |
pr_title="${{ github.event.pull_request.title }}"
if echo "$pr_title" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+"; then
version="${BASH_REMATCH}"
echo "version=$version" >> $GITHUB_OUTPUT
fi
echo "SELECTED_COLOR=$version" >> "$GITHUB_OUTPUT"
- name: Determine incremented release version
id: determine-incremented-release-version
if: ${{ !github.event.inputs.version && !steps.extract-version-from-pr-title.outputs.version }}
uses: reecetech/version-increment@2023.9.3
with:
scheme: semver
increment: ${{ github.event.inputs.increment_type }}
- name: Create release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ github.event.inputs.version ||
steps.extract-version-from-pr-title.outputs.version ||
steps.determine-incremented-release-version.outputs.version }}
generate_release_notes: true
- name: Get color
run: echo "The selected color is ${{ steps.extract-version-from-pr-title.outputs.SELECTED_COLOR }}"