forked from opensearch-project/opensearch-java
-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (140 loc) · 5.45 KB
/
bump-version.yml
File metadata and controls
159 lines (140 loc) · 5.45 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Bump Version
on:
create:
workflow_dispatch:
inputs:
branch:
description: 'Branch to bump version on'
required: true
version:
description: 'Version to bump to'
required: true
jobs:
bump-version-manual:
name: Bump Version (Manual)
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Generate GitHub App Token
id: github_app_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout .github/actions directory
uses: actions/checkout@v6
with:
path: gh
sparse-checkout: |
.github/actions
sparse-checkout-cone-mode: false
- name: Bump Version On ${{ inputs.branch }} Branch
uses: ./gh/.github/actions/create-version-bump-pr
with:
branch: ${{ inputs.branch }}
version: ${{ inputs.version }}
token: ${{ steps.github_app_token.outputs.token }}
bump-version-auto:
name: Bump Version On New Git Ref
if: github.event_name == 'create' && github.repository == 'opensearch-project/opensearch-java'
runs-on: ubuntu-latest
steps:
- name: Checkout .github/actions directory
uses: actions/checkout@v6
with:
path: gh
sparse-checkout: |
.github/actions
sparse-checkout-cone-mode: false
- name: Determine Git Ref Type
id: type
run: |
echo "Determining type of Git ref: ${GITHUB_REF}"
is_minor_indev_branch=false
is_patch_indev_branch=false
is_version_tag=false
major="0"
minor="0"
patch="0"
is_major_bump=false
is_minor_bump=false
if [[ "${GITHUB_REF}" =~ ^refs/heads/([0-9]+)\.x$ ]]; then
is_minor_indev_branch=true
major="${BASH_REMATCH[1]}"
fi
if [[ "${GITHUB_REF}" =~ ^refs/heads/([0-9]+)\.([0-9]+)$ ]]; then
is_patch_indev_branch=true
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
fi
if [[ "${GITHUB_REF}" =~ ^refs/tags/v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
is_version_tag=true
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
patch="${BASH_REMATCH[3]}"
if [[ "${patch}" == "0" ]]; then
is_minor_bump=true
if [[ "${minor}" == "0" ]]; then
is_major_bump=true
fi
fi
fi
{
echo "is_minor_indev_branch=${is_minor_indev_branch}"
echo "is_patch_indev_branch=${is_patch_indev_branch}"
echo "is_version_tag=${is_version_tag}"
echo "major=${major}"
echo "minor=${minor}"
echo "patch=${patch}"
echo "next_major_version=$((major + 1)).0.0"
echo "next_minor_version=${major}.$((minor + 1)).0"
echo "next_patch_version=${major}.${minor}.$((patch + 1))"
echo "minor_indev_branch_name=${major}.x"
echo "patch_indev_branch_name=${major}.${minor}"
echo "is_major_bump=${is_major_bump}"
echo "is_minor_bump=${is_minor_bump}"
} | tee -a "${GITHUB_ENV}"
- name: Generate GitHub App Token
id: github_app_token
uses: actions/create-github-app-token@v2
if: env.is_version_tag == 'true' || env.is_patch_indev_branch == 'true' || env.is_minor_indev_branch == 'true'
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Create ${{ env.patch_indev_branch_name }} Branch
if: false && env.is_minor_bump == 'true'
uses: peterjgrainger/action-create-branch@v3.0.0
with:
branch: ${{ env.patch_indev_branch_name }}
sha: ${{ github.sha }}
env:
GITHUB_TOKEN: ${{ steps.github_app_token.outputs.token }}
- name: Create ${{ env.minor_indev_branch_name }} Branch
if: env.is_major_bump == 'true'
uses: peterjgrainger/action-create-branch@v3.0.0
with:
branch: ${{ env.minor_indev_branch_name }}
sha: ${{ github.sha }}
env:
GITHUB_TOKEN: ${{ steps.github_app_token.outputs.token }}
- name: Bump Version On ${{ env.patch_indev_branch_name }} Branch
if: env.is_patch_indev_branch == 'true' || (env.is_version_tag == 'true' && env.patch > 0)
uses: ./gh/.github/actions/create-version-bump-pr
with:
branch: ${{ env.patch_indev_branch_name }}
version: ${{ env.next_patch_version }}
token: ${{ steps.github_app_token.outputs.token }}
- name: Bump Version On ${{ env.minor_indev_branch_name }} Branch
if: env.is_minor_indev_branch == 'true' || env.is_minor_bump == 'true'
uses: ./gh/.github/actions/create-version-bump-pr
with:
branch: ${{ env.minor_indev_branch_name }}
version: ${{ env.next_minor_version }}
token: ${{ steps.github_app_token.outputs.token }}
- name: Bump Version On main Branch
if: env.is_major_bump == 'true'
uses: ./gh/.github/actions/create-version-bump-pr
with:
branch: main
version: ${{ env.next_major_version }}
token: ${{ steps.github_app_token.outputs.token }}