Skip to content

Commit 6ca966a

Browse files
authored
chore: improved build version logic with repo variable (#6571)
1 parent 5eac5bd commit 6ca966a

File tree

13 files changed

+92
-235
lines changed

13 files changed

+92
-235
lines changed

.github/actions/build-android/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ inputs:
44
type:
55
description: 'Build type: official or experimental'
66
required: true
7-
VERSIONCODE:
8-
description: 'Version code for build'
7+
BUILD_VERSION:
8+
description: 'Build version for build'
99
required: true
1010
BUGSNAG_KEY:
1111
description: 'Bugsnag API key for build'
@@ -90,7 +90,7 @@ runs:
9090
echo -e "reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64" >> ./gradle.properties
9191
echo -e "newArchEnabled=true" >> ./gradle.properties
9292
echo -e "hermesEnabled=true" >> ./gradle.properties
93-
echo -e "VERSIONCODE=${{ inputs.VERSIONCODE }}" >> ./gradle.properties
93+
echo -e "VERSIONCODE=${{ inputs.BUILD_VERSION }}" >> ./gradle.properties
9494
9595
if [[ "${{ inputs.type }}" == "experimental" ]]; then
9696
echo -e "APPLICATION_ID=chat.rocket.reactnative" >> ./gradle.properties

.github/actions/build-ios/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ inputs:
44
type:
55
description: 'Build type: official or experimental'
66
required: true
7-
VERSIONCODE:
8-
description: 'Version Code'
7+
BUILD_VERSION:
8+
description: 'Build version'
99
required: true
1010
APP_STORE_CONNECT_API_KEY_BASE64:
1111
description: 'Base64 encoded App Store Connect API Key'
@@ -84,7 +84,7 @@ runs:
8484
- name: Configure Info.plist and build version
8585
working-directory: ios
8686
run: |
87-
agvtool new-version -all ${{ inputs.VERSIONCODE }}
87+
agvtool new-version -all ${{ inputs.BUILD_VERSION }}
8888
if [[ ${{ inputs.type }} == "official" ]]; then
8989
/usr/libexec/PlistBuddy -c "Set :bugsnag:apiKey ${{ inputs.BUGSNAG_KEY_OFFICIAL }}" ./RocketChatRN/Info.plist
9090
/usr/libexec/PlistBuddy -c "Set :bugsnag:apiKey ${{ inputs.BUGSNAG_KEY_OFFICIAL }}" ./ShareRocketChatRN/Info.plist
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Generate Build Version
2+
3+
inputs:
4+
RN_VARIABLES_PAT:
5+
required: true
6+
type: string
7+
8+
outputs:
9+
BUILD_VERSION:
10+
description: "Generated build version"
11+
value: ${{ steps.compute.outputs.BUILD_VERSION }}
12+
13+
runs:
14+
using: "composite"
15+
steps:
16+
- name: Get BUILD_VERSION from repo variable
17+
id: build_version
18+
shell: bash
19+
run: |
20+
RESPONSE=$(
21+
curl -s -L \
22+
-H "Accept: application/vnd.github+json" \
23+
-H "Authorization: Bearer ${{ inputs.RN_VARIABLES_PAT }}" \
24+
-H "X-GitHub-Api-Version: 2022-11-28" \
25+
https://api.github.com/repos/${{ github.repository }}/actions/variables/BUILD_VERSION
26+
)
27+
28+
VALUE=$(echo "$RESPONSE" | jq -r '.value')
29+
echo "LATEST_BUILD_VERSION=$VALUE" >> $GITHUB_OUTPUT
30+
31+
- name: Compute BUILD_VERSION
32+
id: compute
33+
shell: bash
34+
run: |
35+
LATEST_BUILD_VERSION="${{ steps.build_version.outputs.LATEST_BUILD_VERSION }}"
36+
BUILD_VERSION=$((LATEST_BUILD_VERSION + 1))
37+
echo "BUILD_VERSION=$BUILD_VERSION" >> $GITHUB_OUTPUT
38+
39+
echo "### 📦 Build Version Generated" >> $GITHUB_STEP_SUMMARY
40+
echo "\`Build Version: $BUILD_VERSION\`" >> $GITHUB_STEP_SUMMARY
41+
42+
- name: Update BUILD_VERSION in repo variable
43+
shell: bash
44+
run: |
45+
curl -s -L \
46+
-H "Accept: application/vnd.github+json" \
47+
-H "Authorization: Bearer ${{ inputs.RN_VARIABLES_PAT }}" \
48+
-H "X-GitHub-Api-Version: 2022-11-28" \
49+
-X PATCH \
50+
-d '{"name": "BUILD_VERSION", "value": "${{ steps.compute.outputs.BUILD_VERSION }}"}' \
51+
https://api.github.com/repos/${{ github.repository }}/actions/variables/BUILD_VERSION

.github/actions/generate-version-code/action.yml

Lines changed: 0 additions & 114 deletions
This file was deleted.

.github/actions/upload-android/action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ inputs:
1010
GITHUB_TOKEN:
1111
description: 'GitHub token for commenting'
1212
required: true
13-
VERSIONCODE:
14-
description: 'Version code for build'
13+
BUILD_VERSION:
14+
description: 'Build version for build'
1515
required: true
1616
trigger:
1717
description: 'Trigger for build'
@@ -74,7 +74,7 @@ runs:
7474
GH_TOKEN: ${{ inputs.GITHUB_TOKEN }}
7575
PR_NUMBER: ${{ github.event.pull_request.number }}
7676
BUILD_TYPE: ${{ inputs.type }}
77-
VERSION_CODE: ${{ inputs.VERSIONCODE }}
77+
BUILD_VERSION: ${{ inputs.BUILD_VERSION }}
7878
run: |
7979
if [[ "$BUILD_TYPE" == "official" ]]; then
8080
app_name="Rocket.Chat"
@@ -85,7 +85,7 @@ runs:
8585
gradle_file="android/app/build.gradle"
8686
VERSION_NAME=$(grep versionName $gradle_file | head -n 1 | sed -E 's/.*versionName[[:space:]]+"([^"]+)".*/\1/')
8787
88-
version_info="$app_name $VERSION_NAME.$VERSION_CODE"
88+
version_info="$app_name $VERSION_NAME.$BUILD_VERSION"
8989
9090
message="**Android Build Available**"$'\n\n'"$version_info"
9191

.github/actions/upload-internal-android/action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ inputs:
1010
GITHUB_TOKEN:
1111
description: 'GitHub token for commenting'
1212
required: true
13-
VERSIONCODE:
14-
description: 'Version code for build'
13+
BUILD_VERSION:
14+
description: 'Build version for build'
1515
required: true
1616
trigger:
1717
description: 'Trigger for build'
@@ -84,7 +84,7 @@ runs:
8484
GH_TOKEN: ${{ inputs.GITHUB_TOKEN }}
8585
PR_NUMBER: ${{ github.event.pull_request.number }}
8686
BUILD_TYPE: ${{ inputs.type }}
87-
VERSION_CODE: ${{ inputs.VERSIONCODE }}
87+
BUILD_VERSION: ${{ inputs.BUILD_VERSION }}
8888
run: |
8989
if [[ -z "$INTERNAL_SHARING_URL" ]]; then
9090
echo "No internal sharing URL found in env"
@@ -97,7 +97,7 @@ runs:
9797
app_name="Rocket.Chat Experimental"
9898
fi
9999
100-
version_info="$app_name $VERSION_NAME.$VERSION_CODE"
100+
version_info="$app_name $VERSION_NAME.$BUILD_VERSION"
101101
102102
message="**Android Build Available**"$'\n\n'"$version_info"$'\n\n'"Internal App Sharing: $INTERNAL_SHARING_URL"
103103

.github/actions/upload-ios/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ runs:
135135
plist="ios/RocketChatRN/Info.plist"
136136
137137
version_name=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$plist")
138-
version_code=$(/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "$plist")
138+
build_version=$(/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "$plist")
139139
140140
echo "VERSION_NAME=$version_name" >> $GITHUB_ENV
141-
echo "VERSION_CODE=$version_code" >> $GITHUB_ENV
141+
echo "BUILD_VERSION=$build_version" >> $GITHUB_ENV
142142
shell: bash
143143

144144
- name: Comment on PR with TestFlight Info
@@ -154,7 +154,7 @@ runs:
154154
app_name="Rocket.Chat Experimental"
155155
fi
156156
157-
message="**iOS Build Available**"$'\n\n'"$app_name $VERSION_NAME.$VERSION_CODE"
157+
message="**iOS Build Available**"$'\n\n'"$app_name $VERSION_NAME.$BUILD_VERSION"
158158
159159
gh pr comment "$PR_NUMBER" --body "$message"
160160
shell: bash

.github/workflows/build-android.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
needs: [build-hold]
2727
if: ${{ inputs.type == 'experimental' && (always() && (needs.build-hold.result == 'success' || needs.build-hold.result == 'skipped')) }}
2828
outputs:
29-
VERSIONCODE: ${{ steps.version.outputs.VERSIONCODE }}
29+
BUILD_VERSION: ${{ steps.version.outputs.BUILD_VERSION }}
3030
steps:
3131
- name: Checkout Repository
3232
uses: actions/checkout@v4
@@ -39,13 +39,11 @@ jobs:
3939
with:
4040
build_name: 'android-experimental'
4141

42-
- name: Generate Version Code
42+
- name: Generate Build Version
4343
id: version
44-
uses: ./.github/actions/generate-version-code
44+
uses: ./.github/actions/generate-build-version
4545
with:
46-
official: false
47-
os: android
48-
FASTLANE_GOOGLE_SERVICE_ACCOUNT: ${{ secrets.FASTLANE_GOOGLE_SERVICE_ACCOUNT }}
46+
RN_VARIABLES_PAT: ${{ secrets.RN_VARIABLES_PAT }}
4947

5048
- name: Build Android
5149
uses: ./.github/actions/build-android
@@ -58,7 +56,7 @@ jobs:
5856
KEYSTORE_EXPERIMENTAL_PASSWORD: ${{ secrets.KEYSTORE_EXPERIMENTAL_PASSWORD }}
5957
KEYSTORE_EXPERIMENTAL_ALIAS: ${{ secrets.KEYSTORE_EXPERIMENTAL_ALIAS }}
6058
GOOGLE_SERVICES_ANDROID: ${{ secrets.GOOGLE_SERVICES_ANDROID }}
61-
VERSIONCODE: ${{ steps.version.outputs.VERSIONCODE }}
59+
BUILD_VERSION: ${{ steps.version.outputs.BUILD_VERSION }}
6260

6361
upload-hold:
6462
name: Upload Hold
@@ -67,7 +65,7 @@ jobs:
6765
if: ${{ inputs.trigger == 'pr' }}
6866
environment: upload_experimental_android
6967
outputs:
70-
VERSIONCODE: ${{ needs.build-android.outputs.VERSIONCODE }}
68+
BUILD_VERSION: ${{ needs.build-android.outputs.BUILD_VERSION }}
7169
steps:
7270
- run: echo "Waiting for manual approval..."
7371

@@ -90,7 +88,7 @@ jobs:
9088
trigger: ${{ inputs.trigger }}
9189
FASTLANE_GOOGLE_SERVICE_ACCOUNT: ${{ secrets.FASTLANE_GOOGLE_SERVICE_ACCOUNT }}
9290
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93-
VERSIONCODE: ${{ needs.upload-hold.outputs.VERSIONCODE }}
91+
BUILD_VERSION: ${{ needs.upload-hold.outputs.BUILD_VERSION }}
9492

9593
upload-internal:
9694
name: Internal Sharing
@@ -110,4 +108,4 @@ jobs:
110108
type: experimental
111109
FASTLANE_GOOGLE_SERVICE_ACCOUNT: ${{ secrets.FASTLANE_GOOGLE_SERVICE_ACCOUNT }}
112110
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113-
VERSIONCODE: ${{ needs.build-android.outputs.VERSIONCODE }}
111+
BUILD_VERSION: ${{ needs.build-android.outputs.BUILD_VERSION }}

.github/workflows/build-ios.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,11 @@ jobs:
3737
with:
3838
build_name: 'ios-experimental'
3939

40-
- name: Generate Version Code
40+
- name: Generate Build Version
4141
id: version
42-
uses: ./.github/actions/generate-version-code
42+
uses: ./.github/actions/generate-build-version
4343
with:
44-
official: false
45-
os: ios
46-
APP_STORE_CONNECT_API_KEY_BASE64: ${{ secrets.APP_STORE_CONNECT_API_KEY_BASE64 }}
47-
MATCH_KEYCHAIN_NAME: ${{ secrets.MATCH_KEYCHAIN_NAME }}
48-
MATCH_KEYCHAIN_PASSWORD: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }}
49-
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
50-
APP_STORE_CONNECT_API_KEY_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_ID }}
51-
APP_STORE_CONNECT_API_KEY_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_ISSUER_ID }}
52-
FASTLANE_REPO_PAT: ${{ secrets.FASTLANE_REPO_PAT }}
44+
RN_VARIABLES_PAT: ${{ secrets.RN_VARIABLES_PAT }}
5345

5446
- name: Build iOS
5547
uses: ./.github/actions/build-ios
@@ -66,7 +58,7 @@ jobs:
6658
APP_STORE_CONNECT_API_KEY_BASE64: ${{ secrets.APP_STORE_CONNECT_API_KEY_BASE64 }}
6759
GOOGLE_SERVICES_IOS: ${{ secrets.GOOGLE_SERVICES_IOS }}
6860
GOOGLE_SERVICES_IOS_EXPERIMENTAL: ${{ secrets.GOOGLE_SERVICES_IOS_EXPERIMENTAL }}
69-
VERSIONCODE: ${{ steps.version.outputs.VERSIONCODE }}
61+
BUILD_VERSION: ${{ steps.version.outputs.BUILD_VERSION }}
7062

7163
upload-ios:
7264
name: Upload

0 commit comments

Comments
 (0)