11name : Generate Version Code
22description : Generates version code from GitHub run number
33
4+ inputs :
5+ official :
6+ type : boolean
7+ required : true
8+ os :
9+ type : string
10+ required : true
11+ FASTLANE_GOOGLE_SERVICE_ACCOUNT :
12+ type : string
13+ required : true
14+ APP_STORE_CONNECT_API_KEY_BASE64 :
15+ type : string
16+ required : true
17+ MATCH_KEYCHAIN_NAME :
18+ type : string
19+ required : false
20+ MATCH_KEYCHAIN_PASSWORD :
21+ type : string
22+ required : false
23+ MATCH_PASSWORD :
24+ type : string
25+ required : false
26+ APP_STORE_CONNECT_API_KEY_ID :
27+ type : string
28+ required : false
29+ APP_STORE_CONNECT_API_KEY_ISSUER_ID :
30+ type : string
31+ required : false
32+ FASTLANE_REPO_PAT :
33+ type : string
34+ required : false
35+
436outputs :
537 VERSIONCODE :
638 description : " Generated version code"
@@ -9,16 +41,73 @@ outputs:
941runs :
1042 using : " composite"
1143 steps :
44+ - name : Set up Xcode
45+ if : ${{ inputs.os == 'ios' }}
46+ uses : maxim-lobanov/setup-xcode@v1
47+ with :
48+ xcode-version : ' 16.2'
49+
50+ - name : Set up Ruby and Bundler
51+ uses : ruby/setup-ruby@v1
52+ with :
53+ ruby-version : 2.7.7
54+ bundler-cache : true
55+
56+ - name : Install Fastlane
57+ if : ${{ inputs.os == 'android' }}
58+ working-directory : android
59+ run : |
60+ bundle install --path gems
61+ shell : bash
62+
63+ - name : Store the Google service account key
64+ if : ${{ inputs.os == 'android' }}
65+ working-directory : android
66+ run : |
67+ echo "${{ inputs.FASTLANE_GOOGLE_SERVICE_ACCOUNT }}" | base64 --decode > service_account.json
68+ shell : bash
69+
70+ - name : Decode p8
71+ if : ${{ inputs.os == 'ios' }}
72+ run : |
73+ echo ${{ inputs.APP_STORE_CONNECT_API_KEY_BASE64 }} | base64 --decode > ./ios/fastlane/app_store_connect_api_key.p8
74+ shell : bash
75+
76+ - name : Compute VERSIONCODE (iOS)
77+ id : compute-versioncode-ios
78+ if : ${{ inputs.os == 'ios' }}
79+ shell : bash
80+ run : |
81+ VERSIONCODE=$(bundle exec fastlane ios get_testflight_version | grep 'VERSIONCODE=' | cut -d '=' -f2)
82+ echo "LATEST_VERSIONCODE=$VERSIONCODE" >> $GITHUB_OUTPUT
83+ working-directory : ios
84+ env :
85+ MATCH_KEYCHAIN_NAME : ${{ inputs.MATCH_KEYCHAIN_NAME }}
86+ MATCH_KEYCHAIN_PASSWORD : ${{ inputs.MATCH_KEYCHAIN_PASSWORD }}
87+ MATCH_PASSWORD : ${{ inputs.MATCH_PASSWORD }}
88+ APP_STORE_CONNECT_API_KEY_ID : ${{ inputs.APP_STORE_CONNECT_API_KEY_ID }}
89+ APP_STORE_CONNECT_API_KEY_ISSUER_ID : ${{ inputs.APP_STORE_CONNECT_API_KEY_ISSUER_ID }}
90+ FASTLANE_REPO_PAT : ${{ inputs.FASTLANE_REPO_PAT }}
91+
92+ - name : Compute VERSIONCODE (Android)
93+ id : compute-versioncode-android
94+ if : ${{ inputs.os == 'android' }}
95+ shell : bash
96+ run : |
97+ VERSIONCODE=$(bundle exec fastlane android version_code | grep 'VERSIONCODE=' | cut -d '=' -f2)
98+ echo "LATEST_VERSIONCODE=$VERSIONCODE" >> $GITHUB_OUTPUT
99+ working-directory : android
100+
12101 - name : Compute VERSIONCODE
13102 id : compute
14103 shell : bash
15- env :
16- GITHUB_RUN_NUMBER : ${{ github.run_number }}
17104 run : |
18- # This offset is from CircleCI after we migrated to Github Actions in order to have sequential builds
105+ VERSION_IOS="${{ steps.compute-versioncode-ios.outputs.LATEST_VERSIONCODE }}"
106+ VERSION_ANDROID="${{ steps.compute-versioncode-android.outputs.LATEST_VERSIONCODE }}"
19107
20- OFFSET=87750
21- VERSIONCODE=$((OFFSET + GITHUB_RUN_NUMBER))
108+ LATEST_VERSIONCODE="${VERSION_IOS:-$VERSION_ANDROID}"
109+
110+ VERSIONCODE=$((LATEST_VERSIONCODE + 1))
22111 echo "VERSIONCODE=$VERSIONCODE" >> $GITHUB_OUTPUT
23112
24113 echo "### 📦 Version Code Generated" >> $GITHUB_STEP_SUMMARY
0 commit comments