-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (162 loc) · 5.58 KB
/
create-version.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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Create Version
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
versionIncrementType:
description: 'Version Increment Type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
- manual
manualVersionNumber:
description: 'Manually Enter Version Number (Requires manual Version Increment Type)'
required: false
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
version_increment_is_bump:
name: Check If Version Increment Is Bump
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
outputs:
isBump: ${{ steps.check_if_increment_is_bump.outputs.value }}
steps:
- name: Check If Version Increment Is Bump
id: check_if_increment_is_bump
run: |
if [ ${{ inputs.versionIncrementType }} == 'patch' ]; then
echo "value=true" >> "$GITHUB_OUTPUT"
elif [ ${{ inputs.versionIncrementType }} == 'minor' ]; then
echo "value=true" >> "$GITHUB_OUTPUT"
elif [ ${{ inputs.versionIncrementType }} == 'major' ]; then
echo "value=true" >> "$GITHUB_OUTPUT"
else
echo echo "value=false" >> "$GITHUB_OUTPUT"
fi
current_version:
name: Store Current Version
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set Version Output
id: version
run: grep s\\.version\\s SocialAuthentication.podspec | sed 's/s.//' | sed "s/'//g" | sed 's/ //g' >> $GITHUB_OUTPUT
print_current_version:
name: Print Current Version
runs-on: ubuntu-latest
needs: [ current_version ]
steps:
- name: Print Current Version
env:
VERSION: ${{ needs.current_version.outputs.version }}
run: |
printf '%s\n' "$VERSION"
bump_version:
name: Store Bump Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
needs: [ current_version, version_increment_is_bump ]
steps:
- name: Bump Version
if: ${{ needs.version_increment_is_bump.outputs.isBump == 'true' }}
id: bump-semver
uses: actions-ecosystem/action-bump-semver@v1
with:
current_version: ${{ needs.current_version.outputs.version }}
level: ${{ inputs.versionIncrementType }}
- name: Store Bump Version
id: version
run: |
echo "version=${{ steps.bump-semver.outputs.new_version }}" >> $GITHUB_OUTPUT
print_bump_version:
name: Print Bump Version
runs-on: ubuntu-latest
needs: [ bump_version, version_increment_is_bump ]
if: ${{ needs.version_increment_is_bump.outputs.isBump == 'true' }}
steps:
- name: Print Bump Version
env:
VERSION: ${{ needs.bump_version.outputs.version }}
run: |
printf '%s\n' "$VERSION"
manual_version:
name: Store Manual Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
if: inputs.versionIncrementType == 'manual'
steps:
- name: Store Manual Version
id: version
run: |
echo "version=${{ inputs.manualVersionNumber }}" >> $GITHUB_OUTPUT
print_manual_version:
name: Print Manual Version
runs-on: ubuntu-latest
needs: [ manual_version ]
if: inputs.versionIncrementType == 'manual'
steps:
- name: Print Manual Version
env:
VERSION: ${{ needs.manual_version.outputs.version }}
run: |
printf '%s\n' "$VERSION"
new_version:
name: Store New Version
runs-on: ubuntu-latest
needs: [ version_increment_is_bump, bump_version ]
if: ${{ needs.version_increment_is_bump.outputs.isBump == 'true' || inputs.versionIncrementType == 'manual' }}
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Store New Version
id: version
run: |
if [ ${{ needs.version_increment_is_bump.outputs.isBump }} == 'true' ]; then
echo "version=${{ needs.bump_version.outputs.version }}" >> $GITHUB_OUTPUT
elif [ ${{ inputs.versionIncrementType }} == 'manual' ]; then
echo "version=${{ inputs.manualVersionNumber }}" >> $GITHUB_OUTPUT
else
echo "No Version"
fi
print_new_version:
name: Print New Version
runs-on: ubuntu-latest
needs: [ new_version ]
steps:
- name: Print New Version
env:
VERSION: ${{ needs.new_version.outputs.version }}
run: |
printf '%s\n' "$VERSION"
create_version_branch_and_pull_request:
name: Create Version Branch and PR
runs-on: ubuntu-latest
needs: [ current_version, new_version ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set Podspec Version to New Version
run: |
sed -i "s/s.version = '${{ needs.current_version.outputs.version }}'/s.version = '${{ needs.new_version.outputs.version }}'/g" SocialAuthentication.podspec
- name: Create Version Branch and PR
uses: peter-evans/create-pull-request@v6
with:
branch: "versions/${{ needs.new_version.outputs.version }}"
title: "Version ${{needs.new_version.outputs.version}}"
commit-message: "Increase version to ${{needs.new_version.outputs.version}}"