Skip to content

Commit 3f7d6d3

Browse files
chore: Support multiple targets (#4)
* chore: Support multiple targets * chore: Add max attempts * chore: Use platform query * docs: Update README with correct tag
1 parent 61067c0 commit 3f7d6d3

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ jobs:
2121
uses: actions/checkout@v4
2222

2323
- name: Upload Release Notes to TestFlight
24-
uses: nthState/[email protected].0
24+
uses: nthState/[email protected].1
2525
with:
2626
ISSUER_ID: ${{ secrets.APPCONNECT_API_ISSUER }}
2727
KEY_ID: ${{ secrets.APPCONNECT_API_KEY_ID }}
2828
PRIVATE_KEY: ${{ secrets.APPCONNECT_API_KEY_PRIVATE }}
2929
APP_ID: id of the app
3030
WHATS_NEW: "detail item that has changed"
3131
BUILD_NUMBER: the build number you want to change
32+
PLATFORM: the platform to target, IOS, MAC_OS, TV_OS, VISION_OS
3233

3334
```
3435

@@ -41,6 +42,7 @@ export PRIVATE_KEY=appstore connect api private key
4142
export APP_ID=app id
4243
export WHATS_NEW="Your update text, max 4000 chars"
4344
export BUILD_NUMBER= your build number
45+
export PLATFORM= IOS, MAC_OS, TV_OS, VISION_OS
4446
python3 ./main.py
4547
```
4648

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ inputs:
2020
BUILD_NUMBER:
2121
description: 'The build number to target'
2222
required: true
23+
PLATFORM:
24+
description: 'The platform to target, IOS, MAC_OS, TV_OS, VISION_OS'
25+
required: false
2326

2427
runs:
2528
using: 'composite'
@@ -36,6 +39,7 @@ runs:
3639
APP_ID: ${{ inputs.APP_ID }}
3740
WHATS_NEW: ${{ inputs.WHATS_NEW }}
3841
BUILD_NUMBER: ${{ inputs.BUILD_NUMBER }}
42+
PLATFORM: ${{ inputs.PLATFORM }}
3943
run: |
4044
mkdir -p api_venv
4145
cd api_venv

main.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def generateToken(self, issuer_id, key_id, private_key):
2626

2727
return encoded_token
2828

29-
def uploadNotes(self, app_id, token, whats_new, build_number):
29+
def uploadNotes(self, app_id, token, whats_new, build_number, platform):
3030
# Create Header
3131
HEAD = {
3232
'Authorization': 'Bearer ' + token
@@ -37,28 +37,40 @@ def uploadNotes(self, app_id, token, whats_new, build_number):
3737

3838
# Find builds
3939
versionId = ""
40-
while versionId == "":
40+
versionIdCounter = 0
41+
while versionId == "" and versionIdCounter < 100:
4142

4243
print("---Finding Build---")
43-
URL = BASE_URL + 'builds?filter[app]=' + app_id + '&filter[version]=' + build_number
44+
URL = BASE_URL + 'builds?filter[app]=' + app_id + '&filter[version]=' + build_number + '&filter[preReleaseVersion.platform]=' + platform
4445
r = requests.get(URL, params={}, headers=HEAD)
4546
try:
46-
versionId = r.json()['data'][0]['id']
47-
except:
47+
data = r.json()['data']
48+
49+
if len(data) > 0:
50+
versionId = data[0]['id']
51+
print(f"found versionId: {versionId}")
52+
53+
except Exception as e:
54+
print(f"Error: {e}")
4855
time.sleep(60) #wait for 60 seconds
56+
57+
versionIdCounter += 1
4958

5059
# Find localizations
5160
localizationId = ""
52-
while localizationId == "":
61+
localizationIdCounter = 0
62+
while localizationId == "" and localizationIdCounter < 100:
5363

5464
print("---Finding Localizations---")
5565
URL = BASE_URL + 'builds/' + versionId + '/betaBuildLocalizations'
5666
r = requests.get(URL, params={}, headers=HEAD)
5767
try:
5868
localizationId = r.json()['data'][0]['id']
59-
except:
69+
except Exception as e:
70+
print(f"Error: {e}")
6071
time.sleep(60) #wait for 60 seconds
61-
72+
73+
localizationIdCounter += 1
6274

6375
print("---Update What's New---")
6476
URL = BASE_URL + 'betaBuildLocalizations/' + localizationId
@@ -85,11 +97,13 @@ def main():
8597
whats_new = os.getenv('WHATS_NEW')
8698
build_number = os.getenv('BUILD_NUMBER')
8799

100+
platform = os.getenv('PLATFORM', 'IOS')
101+
88102
print(f"Starting for build: {build_number}")
89103

90104
service = UploadTestFlightReleaseNotes()
91105
token = service.generateToken(issuer_id, key_id, private_key)
92-
reason = service.uploadNotes(app_id, token, whats_new, build_number)
106+
reason = service.uploadNotes(app_id, token, whats_new, build_number, platform)
93107

94108
print(reason)
95109

0 commit comments

Comments
 (0)