-
Notifications
You must be signed in to change notification settings - Fork 3.7k
179 lines (156 loc) · 6.49 KB
/
createNewVersion.yml
File metadata and controls
179 lines (156 loc) · 6.49 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Create new version
on:
workflow_dispatch:
inputs:
SEMVER_LEVEL:
description: One of {BUILD, PATCH, MINOR, MAJOR}
required: true
default: BUILD
type: string
workflow_call:
inputs:
SEMVER_LEVEL:
description: One of {BUILD, PATCH, MINOR, MAJOR}
required: false
default: BUILD
type: string
outputs:
NEW_VERSION:
description: The new version string
value: ${{ jobs.createNewVersion.outputs.NEW_VERSION }}
secrets:
SLACK_WEBHOOK:
description: Webhook used to comment in slack
required: true
OS_BOTIFY_COMMIT_TOKEN:
description: OSBotify personal access token, used to workaround committing to protected branch
required: true
OP_SERVICE_ACCOUNT_TOKEN:
description: 1Password service account token
required: true
OS_BOTIFY_APP_ID:
description: App ID for OSBotify GitHub App
required: true
OS_BOTIFY_PRIVATE_KEY:
description: Private key for OSBotify GitHub App
required: true
jobs:
createNewVersion:
runs-on: blacksmith-6vcpu-macos-latest
outputs:
NEW_VERSION: ${{ steps.bumpVersion.outputs.NEW_VERSION }}
steps:
- name: Run turnstyle
uses: softprops/turnstyle@49108bdfa571e62371bd2c3094893c547ab3fc03
with:
poll-interval-seconds: 10
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Check out
# v6
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
ref: main
submodules: true
# The OS_BOTIFY_COMMIT_TOKEN is a personal access token tied to osbotify
# This is a workaround to allow pushes to a protected branch
token: ${{ secrets.OS_BOTIFY_COMMIT_TOKEN }}
- name: Validate actor
uses: ./.github/actions/composite/validateActor
with:
OS_BOTIFY_TOKEN: ${{ secrets.OS_BOTIFY_COMMIT_TOKEN }}
- name: Setup git for OSBotify
uses: Expensify/GitHub-Actions/setupGitForOSBotify@main
id: setupGitForOSBotify
with:
OP_VAULT: ${{ vars.OP_VAULT }}
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
SETUP_AS_APP: false
- name: Generate new E/App version (including Mobile-Expensify version bump)
id: bumpVersion
uses: ./.github/actions/javascript/bumpVersion
with:
SEMVER_LEVEL: ${{ inputs.SEMVER_LEVEL }}
- name: Commit new Mobile-Expensify version
working-directory: Mobile-Expensify
run: |
# First commit the version changes on detached HEAD
git add \
./Android/AndroidManifest.xml \
./app/config/config.json \
./iOS/Expensify/Expensify-Info.plist\
./iOS/SmartScanExtension/Info.plist \
./iOS/NotificationServiceExtension/Info.plist
git commit -m "Update version to ${{ steps.bumpVersion.outputs.NEW_VERSION }}"
# Store the commit hash before checkout to ensure we cherry-pick the right commit
DETACHED_COMMIT=$(git rev-parse HEAD)
# Cherry-pick the version bump commit onto main, to safely handle case where new commits exist on main
git checkout main && git pull origin main
git cherry-pick "$DETACHED_COMMIT"
if ! git push origin main; then
echo "Race condition! Mobile-Expensify main was updated while this workflow was running, so push failed. Fetching remote, rebasing, and retrying push once."
git fetch origin main
if ! git rebase origin/main; then
echo "::error:: Rebase failed while retrying Mobile-Expensify push"
exit 1
fi
if ! git push origin main; then
echo "::error:: Mobile-Expensify change failed to push after rebase"
exit 1
fi
fi
- name: Commit new E/App version
run: |
git add \
./package.json \
./package-lock.json \
./android/app/build.gradle \
./ios/NewExpensify/Info.plist \
./ios/NotificationServiceExtension/Info.plist \
./ios/ShareViewController/Info.plist
git commit -m "Update version to ${{ steps.bumpVersion.outputs.NEW_VERSION }}"
- name: Update Mobile-Expensify submodule in E/App
run: |
git add Mobile-Expensify
git commit -m "Update Mobile-Expensify submodule version to ${{ steps.bumpVersion.outputs.NEW_VERSION }}"
MAX_RETRIES=5
RETRY_DELAY=2
for i in $(seq 1 $MAX_RETRIES); do
if git push origin main; then
echo "::notice::Successfully pushed E/App changes on attempt $i"
exit 0
fi
echo "::warning::Push attempt $i failed, retrying in ${RETRY_DELAY}s..."
sleep $RETRY_DELAY
RETRY_DELAY=$((RETRY_DELAY * 2))
if ! git fetch origin main; then
echo "::error::Unable to fetch main on attempt $i"
continue
fi
if ! git rebase origin/main; then
echo "::warning::Rebase failed on attempt $i, aborting and retrying..."
git rebase --abort || true
continue
fi
done
echo "::error::E/App push failed after $MAX_RETRIES attempts"
echo "::error::CRITICAL: Mobile-Expensify has version ${{ steps.bumpVersion.outputs.NEW_VERSION }} but E/App does not!"
echo "::error::Manual intervention required - run the syncVersions workflow to fix"
exit 1
- name: Verify version sync
run: |
APP_VERSION=$(jq -r .version package.json)
ME_VERSION=$(jq -r .meta.version Mobile-Expensify/app/config/config.json)
if [ "$APP_VERSION" != "$ME_VERSION" ]; then
echo "::error::Version mismatch detected after push!"
echo "::error::E/App version: $APP_VERSION"
echo "::error::Mobile-Expensify version: $ME_VERSION"
echo "::error::Run the syncVersions workflow to fix this"
exit 1
fi
echo "::notice::Versions verified: $APP_VERSION"
- name: Announce failed workflow in Slack
if: ${{ failure() }}
uses: ./.github/actions/composite/announceFailedWorkflowInSlack
with:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}