Skip to content

Commit 6ef6002

Browse files
authored
Merge pull request #98 from luke-rogers/master
feat: input for incrementing the version number and build number improvements
2 parents d6ccc6f + 3b6f77c commit 6ef6002

File tree

5 files changed

+117
-5
lines changed

5 files changed

+117
-5
lines changed

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,37 @@ The SDK that should be used for building the application. Default `""`. For exam
140140

141141
Use a custom destination for building the app. Default `""`. For example, `"generic/platform=iOS"`.
142142

143+
### `increment-version-number`
144+
145+
Increment the version number of your project. Supports `"patch"`, `"minor"`, `"major"` or a specific version number. Default `""`.
146+
143147
### `increment-build-number`
144148

145-
Automatically increment the build number by one before building the application. Default `false`.
149+
Increment the build number before building the application. Default `""`.
150+
151+
- `true` - automatically increment the project build number by one
152+
- `testflight` - increment the latest TestFlight build number by one. If this is specified you must also provide `bundle-identifier`, `app-store-connect-api-key-id`, `app-store-connect-api-key-issuer-id` and `app-store-connect-api-key-base64`
153+
- a specific build number e.g. `75`
154+
155+
156+
### `bundle-identifier`
157+
158+
Application bundle identifier. Default `""`.
159+
160+
### `app-store-connect-api-key-id`
161+
162+
App Store Connect API Key ID. Default `""`.
163+
164+
165+
### `app-store-connect-api-key-issuer-id`
166+
167+
App Store Connect API Key Issuer ID. Default `""`.
168+
169+
170+
### `app-store-connect-api-key-base64`
171+
172+
Base64 encoded App Store Connect API Key. Default `""`.
173+
146174

147175
## Contributions Welcome!
148176

action.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,29 @@ inputs:
8787
required: false
8888
default: ""
8989
increment-build-number:
90-
description: "Automatically increment the build number by one before building the application"
90+
description: "Increment the build number before building the application"
9191
required: false
92-
default: false
92+
default: ""
93+
increment-version-number:
94+
description: 'Increment the version number of your project. Supports patch, minor, major or a specific version number.'
95+
required: false
96+
default: ""
97+
bundle-identifier:
98+
description: 'Bundle identifier of the application.'
99+
required: false
100+
default: ""
101+
app-store-connect-api-key-id:
102+
description: 'App Store Connect API Key ID'
103+
required: false
104+
default: ""
105+
app-store-connect-api-key-issuer-id:
106+
description: 'App Store Connect API Key Issuer ID'
107+
required: false
108+
default: ""
109+
app-store-connect-api-key-base64:
110+
description: 'Base64 encoded App Store Connect API Key'
111+
required: false
112+
default: ""
93113
runs:
94114
using: "node12"
95115
main: "dist/index.js"

dist/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ async function run() {
2828
throw new Error("mobileprovision missing or in the wrong format.");
2929
}
3030

31+
// Validate increment build number
32+
if (
33+
core.getInput("increment-build-number") === "testflight" &&
34+
(!core.getInput("bundle-identifier") || !core.getInput("app-store-connect-api-key-id") || !core.getInput("app-store-connect-api-key-issuer-id") || !core.getInput("app-store-connect-api-key-base64"))
35+
) {
36+
throw new Error("increment-build-number='testflight' requires 'bundle-identifier', 'app-store-connect-api-key-id', 'app-store-connect-api-key-issuer-id' and 'app-store-connect-api-key-base64' to be provided.");
37+
}
38+
3139
// Set environment variables
3240
process.env.P12_BASE64 = core.getInput("p12-base64");
3341
process.env.P12_KEY_BASE64 = core.getInput("p12-key-base64");
@@ -58,6 +66,12 @@ async function run() {
5866
process.env.BUILD_DESTINATION = core.getInput("build-destination");
5967
process.env.ENTITLMENTS_FILE_PATH = core.getInput("entitlements-file-path");
6068
process.env.INCREMENT_BUILD_NUMBER = core.getInput("increment-build-number");
69+
process.env.INCREMENT_VERSION_NUMBER = core.getInput('increment-version-number');
70+
process.env.BUNDLE_IDENTIFIER = core.getInput('bundle-identifier');
71+
process.env.APP_STORE_CONNECT_API_KEY_ID = core.getInput('app-store-connect-api-key-id');
72+
process.env.APP_STORE_CONNECT_API_KEY_ISSUER_ID = core.getInput('app-store-connect-api-key-issuer-id');
73+
process.env.APP_STORE_CONNECT_API_KEY_BASE64 = core.getInput('app-store-connect-api-key-base64');
74+
6175

6276
// Execute build.sh
6377
await exec.exec(`bash ${__dirname}/../build.sh`);

fastlane/Fastfile

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,45 @@ platform :ios do
146146
use_build_destination = !ENV['BUILD_DESTINATION'].empty?
147147
use_cloned_source_packages_path = !ENV['CLONED_SOURCE_PACKAGES_PATH'].empty?
148148

149-
if ENV['INCREMENT_BUILD_NUMBER'] == 'true'
150-
increment_build_number(xcodeproj: ENV['PROJECT_PATH'])
149+
if !ENV['INCREMENT_BUILD_NUMBER'].empty?
150+
if ENV['INCREMENT_BUILD_NUMBER'] == 'true'
151+
increment_build_number(xcodeproj: ENV['PROJECT_PATH'])
152+
elsif ENV['INCREMENT_BUILD_NUMBER'] == 'testflight'
153+
api_key = app_store_connect_api_key(
154+
key_id: ENV['APP_STORE_CONNECT_API_KEY_ID'],
155+
issuer_id: ENV['APP_STORE_CONNECT_API_KEY_ISSUER_ID'],
156+
key_content: ENV['APP_STORE_CONNECT_API_KEY_BASE64'],
157+
is_key_content_base64: true
158+
)
159+
current_testflight_build_number = latest_testflight_build_number(
160+
api_key: api_key,
161+
app_identifier: ENV["BUNDLE_IDENTIFIER"],
162+
team_id: ENV['TEAM_ID']
163+
)
164+
increment_build_number(
165+
build_number: current_testflight_build_number + 1,
166+
xcodeproj: ENV['PROJECT_PATH']
167+
)
168+
else
169+
increment_build_number(
170+
build_number: ENV['INCREMENT_BUILD_NUMBER'],
171+
xcodeproj: ENV['PROJECT_PATH']
172+
)
173+
end
174+
end
175+
176+
if !ENV['INCREMENT_VERSION_NUMBER'].empty?
177+
if ["patch", "minor", "major"].include?(ENV['INCREMENT_VERSION_NUMBER'])
178+
increment_version_number(
179+
bump_type: ENV['INCREMENT_VERSION_NUMBER'],
180+
xcodeproj: ENV['PROJECT_PATH']
181+
)
182+
else
183+
increment_version_number(
184+
version_number: ENV['INCREMENT_VERSION_NUMBER'],
185+
xcodeproj: ENV['PROJECT_PATH']
186+
)
187+
end
151188
end
152189

153190
build_app(

index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ async function run() {
2121
throw new Error("mobileprovision missing or in the wrong format.");
2222
}
2323

24+
// Validate increment build number
25+
if (
26+
core.getInput("increment-build-number") === "testflight" &&
27+
(!core.getInput("bundle-identifier") || !core.getInput("app-store-connect-api-key-id") || !core.getInput("app-store-connect-api-key-issuer-id") || !core.getInput("app-store-connect-api-key-base64"))
28+
) {
29+
throw new Error("increment-build-number='testflight' requires 'bundle-identifier', 'app-store-connect-api-key-id', 'app-store-connect-api-key-issuer-id' and 'app-store-connect-api-key-base64' to be provided.");
30+
}
31+
2432
// Set environment variables
2533
process.env.P12_BASE64 = core.getInput("p12-base64");
2634
process.env.P12_KEY_BASE64 = core.getInput("p12-key-base64");
@@ -51,6 +59,11 @@ async function run() {
5159
process.env.BUILD_DESTINATION = core.getInput("build-destination");
5260
process.env.ENTITLMENTS_FILE_PATH = core.getInput("entitlements-file-path");
5361
process.env.INCREMENT_BUILD_NUMBER = core.getInput("increment-build-number");
62+
process.env.INCREMENT_VERSION_NUMBER = core.getInput('increment-version-number');
63+
process.env.BUNDLE_IDENTIFIER = core.getInput('bundle-identifier');
64+
process.env.APP_STORE_CONNECT_API_KEY_ID = core.getInput('app-store-connect-api-key-id');
65+
process.env.APP_STORE_CONNECT_API_KEY_ISSUER_ID = core.getInput('app-store-connect-api-key-issuer-id');
66+
process.env.APP_STORE_CONNECT_API_KEY_BASE64 = core.getInput('app-store-connect-api-key-base64');
5467

5568
// Execute build.sh
5669
await exec.exec(`bash ${__dirname}/../build.sh`);

0 commit comments

Comments
 (0)