-
Notifications
You must be signed in to change notification settings - Fork 3
174 lines (151 loc) · 7.92 KB
/
prep-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
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
name: Prepare Plugin Releases
on:
workflow_dispatch:
inputs:
proxy_version:
description: 'New Framework Proxy Version (x.y.z)'
required: true
pattern: '^\d+\.\d+\.\d+$'
ios_version:
description: 'iOS SDK Version (x.y.z)'
required: false
pattern: '^\d+\.\d+\.\d+$'
android_version:
description: 'Android SDK Version (x.y.z)'
required: false
pattern: '^\d+\.\d+\.\d+$'
env:
GITHUB_TOKEN: ${{ secrets.MOBILE_PLUGIN_RELEASE_PAT }}
jobs:
trigger-releases:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Fetch current proxy version (based on latest tags)
id: current_proxy
run: |
# Fetch the top 2 tags so we can fall back to the previous one if the latest equals the new version
readarray -t PROXY_TAGS < <(gh api repos/urbanairship/airship-mobile-framework-proxy/tags?per_page=2 \
--header "Authorization: token $GITHUB_TOKEN" --jq '.[].name')
LATEST_PROXY_TAG="${PROXY_TAGS[0]}"
PREVIOUS_PROXY_TAG="${PROXY_TAGS[1]}"
# If the latest tag equals the requested proxy_version and there's a previous tag, use that for comparison
if [ "$LATEST_PROXY_TAG" = "${{ github.event.inputs.proxy_version }}" ] && [ -n "$PREVIOUS_PROXY_TAG" ]; then
echo "current_proxy_version=$PREVIOUS_PROXY_TAG" >> $GITHUB_OUTPUT
else
echo "current_proxy_version=$LATEST_PROXY_TAG" >> $GITHUB_OUTPUT
fi
- name: Determine increment type
id: increment_type
run: |
IFS='.' read -r OLD_MAJOR OLD_MINOR OLD_PATCH <<< "${{ steps.current_proxy.outputs.current_proxy_version }}"
IFS='.' read -r NEW_MAJOR NEW_MINOR NEW_PATCH <<< "${{ github.event.inputs.proxy_version }}"
INC_TYPE="patch"
if [ "$NEW_MAJOR" -gt "$OLD_MAJOR" ]; then
INC_TYPE="major"
elif [ "$NEW_MINOR" -gt "$OLD_MINOR" ]; then
INC_TYPE="minor"
fi
echo "increment_type=$INC_TYPE" >> $GITHUB_OUTPUT
- name: Fetch React Native Version (latest tag)
id: rn
run: |
RN_VERSION=$(gh api repos/urbanairship/react-native-airship/tags?per_page=1 \
--header "Authorization: token $GITHUB_TOKEN" --jq '.[0].name')
echo "rn_version=$RN_VERSION" >> $GITHUB_OUTPUT
- name: Fetch Flutter Version (latest tag)
id: flutter
run: |
FLUTTER_VERSION=$(gh api repos/urbanairship/airship-flutter/tags?per_page=1 \
--header "Authorization: token $GITHUB_TOKEN" --jq '.[0].name')
echo "flutter_version=$FLUTTER_VERSION" >> $GITHUB_OUTPUT
- name: Fetch Capacitor Version (latest tag)
id: capacitor
run: |
CAPACITOR_VERSION=$(gh api repos/urbanairship/capacitor-airship/tags?per_page=1 \
--header "Authorization: token $GITHUB_TOKEN" --jq '.[0].name')
echo "capacitor_version=$CAPACITOR_VERSION" >> $GITHUB_OUTPUT
- name: Fetch Cordova Version (latest tag)
id: cordova
run: |
CORDOVA_VERSION=$(gh api repos/urbanairship/urbanairship-cordova/tags?per_page=1 \
--header "Authorization: token $GITHUB_TOKEN" --jq '.[0].name')
echo "cordova_version=$CORDOVA_VERSION" >> $GITHUB_OUTPUT
- name: Bump plugin versions
id: bump_plugins
run: |
function bump_version() {
local ver="$1"
local inc="$2"
IFS='.' read -r maj min pat <<< "$ver"
case "$inc" in
major) ((maj++)); min=0; pat=0;;
minor) ((min++)); pat=0;;
patch) ((pat++));;
esac
echo "${maj}.${min}.${pat}"
}
RN_BUMPED=$(bump_version "${{ steps.rn.outputs.rn_version }}" "${{ steps.increment_type.outputs.increment_type }}")
FLUTTER_BUMPED=$(bump_version "${{ steps.flutter.outputs.flutter_version }}" "${{ steps.increment_type.outputs.increment_type }}")
CAPACITOR_BUMPED=$(bump_version "${{ steps.capacitor.outputs.capacitor_version }}" "${{ steps.increment_type.outputs.increment_type }}")
CORDOVA_BUMPED=$(bump_version "${{ steps.cordova.outputs.cordova_version }}" "${{ steps.increment_type.outputs.increment_type }}")
echo "rn_bumped=$RN_BUMPED" >> $GITHUB_OUTPUT
echo "flutter_bumped=$FLUTTER_BUMPED" >> $GITHUB_OUTPUT
echo "capacitor_bumped=$CAPACITOR_BUMPED" >> $GITHUB_OUTPUT
echo "cordova_bumped=$CORDOVA_BUMPED" >> $GITHUB_OUTPUT
- name: Trigger React Native Release
run: |
gh workflow run prep-release.yml \
-R urbanairship/react-native-airship \
-f react_native_version="${{ steps.bump_plugins.outputs.rn_bumped }}" \
-f proxy_version="${{ github.event.inputs.proxy_version }}" \
$([ -n "${{ github.event.inputs.ios_version }}" ] && echo "-f ios_version=${{ github.event.inputs.ios_version }}") \
$([ -n "${{ github.event.inputs.android_version }}" ] && echo "-f android_version=${{ github.event.inputs.android_version }}")
- name: Trigger Flutter Release
run: |
gh workflow run prep-release.yml \
-R urbanairship/airship-flutter \
-f flutter_version="${{ steps.bump_plugins.outputs.flutter_bumped }}" \
-f proxy_version="${{ github.event.inputs.proxy_version }}" \
$([ -n "${{ github.event.inputs.ios_version }}" ] && echo "-f ios_version=${{ github.event.inputs.ios_version }}") \
$([ -n "${{ github.event.inputs.android_version }}" ] && echo "-f android_version=${{ github.event.inputs.android_version }}")
- name: Trigger Capacitor Release
run: |
gh workflow run prep-release.yaml \
-R urbanairship/capacitor-airship \
-f capacitor_version="${{ steps.bump_plugins.outputs.capacitor_bumped }}" \
-f proxy_version="${{ github.event.inputs.proxy_version }}" \
$([ -n "${{ github.event.inputs.ios_version }}" ] && echo "-f ios_version=${{ github.event.inputs.ios_version }}") \
$([ -n "${{ github.event.inputs.android_version }}" ] && echo "-f android_version=${{ github.event.inputs.android_version }}")
- name: Trigger Cordova Release
run: |
gh workflow run prep-release.yaml \
-R urbanairship/urbanairship-cordova \
-f cordova_version="${{ steps.bump_plugins.outputs.cordova_bumped }}" \
-f proxy_version="${{ github.event.inputs.proxy_version }}" \
$([ -n "${{ github.event.inputs.ios_version }}" ] && echo "-f ios_version=${{ github.event.inputs.ios_version }}") \
$([ -n "${{ github.event.inputs.android_version }}" ] && echo "-f android_version=${{ github.event.inputs.android_version }}")
- name: Handle Success
if: success()
run: echo "Successfully triggered release preparations for all plugins"
- name: Handle Failure
if: failure()
run: |
echo "::error::Failed to trigger one or more plugin releases. Check the logs for details."
exit 1
# - name: Slack Notification (Success)
# if: success()
# uses: homoluctus/slatify@master
# with:
# type: success
# job_name: ":tada: Plugin release preparations triggered :tada:"
# message: "@mobile-team Release preparations have been triggered for all plugins with proxy version v${{ github.event.inputs.proxy_version }} :rocket:"
# url: ${{ secrets.MOBILE_SLACK_WEBHOOK }}
# - name: Slack Notification (Failure)
# if: failure()
# uses: homoluctus/slatify@master
# with:
# type: failure
# job_name: ":disappointed: Plugin Release Preparations Failed :disappointed:"
# message: "@crow Failed to trigger plugin release preparations. Please check the workflow logs. :sob:"
# url: ${{ secrets.MOBILE_SLACK_WEBHOOK }}