Skip to content

Commit cb120cf

Browse files
groups and plist
1 parent b3ef97d commit cb120cf

7 files changed

Lines changed: 104 additions & 3 deletions

File tree

.github/workflows/validate.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ jobs:
107107
build-target: ${{ matrix.build-target }}
108108
log-name: '${{ matrix.build-target }}-Build'
109109
args: '-quit -nographics -batchmode -executeMethod Buildalon.Editor.BuildPipeline.UnityPlayerBuildTools.StartCommandLineBuild -sceneList Assets/Scenes/SampleScene.unity -export -enableAppleAutomaticSigning -bundleIdentifier com.test.buildalon.xcode -versionName ${{ env.VERSION }}'
110+
- name: Update Info.Plist with encription compliance
111+
shell: bash
112+
run: |
113+
# find the Info.plist file in the build directory
114+
INFO_PLIST_PATH=$(find "${{ env.UNITY_PROJECT_PATH }}/Builds/${{ matrix.build-target }}" -name Info.plist)
115+
/usr/libexec/PlistBuddy -c "Add :ATSSettings:ATSStatus string NSAppTransportSecurity" "${INFO_PLIST_PATH}"
110116
- uses: ./ # buildalon/unity-xcode-builder
111117
id: xcode-build
112118
with:
@@ -117,6 +123,8 @@ jobs:
117123
team-id: ${{ secrets.APPLE_TEAM_ID }}
118124
export-option: ${{ env.EXPORT_OPTION }}
119125
notarize: ${{ matrix.unity-version != '6000.x' }}
126+
archive-type: pkg
127+
test-groups: Beta
120128
- name: print outputs
121129
if: always()
122130
run: |

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ This action requires several secrets that need to be setup in the repository or
7171
| `upload` | Whether to upload the exported Xcode project to App Store Connect. | Defaults to `true` if `export-option === app-store-connect`. |
7272
| `whats-new` | When `uploading === true`, Let your testers know what you would like them to test in this build. This information will be available to testers in all groups who have access to this build. | Defaults to the last git commit sha, current branch name, and commit message. |
7373
| `auto-increment-build-number` | Whether to automatically increment the CFBundleVersion in the Xcode project. | Defaults to `true` if `export-option === app-store-connect`. |
74+
| `test-groups` | One or more test groups to automatically add to the build when uploading to TestFlight. When using multiple groups, separate them with commas. | None by default. |
7475

7576
### outputs
7677

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ inputs:
8484
description: Whether to automatically increment the CFBundleVersion in the Xcode project. Defaults to `true` if `export-option === app-store-connect`.
8585
required: false
8686
default: 'true'
87+
test-groups:
88+
description: One or more test groups to automatically add to the build when uploading to TestFlight. When using multiple groups, separate them with commas.
89+
required: false
8790
outputs:
8891
executable:
8992
description: The path to the generated archive executable.

dist/index.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57465,6 +57465,7 @@ exports.GetAppId = GetAppId;
5746557465
exports.GetLatestBundleVersion = GetLatestBundleVersion;
5746657466
exports.UpdateTestDetails = UpdateTestDetails;
5746757467
exports.GetCertificate = GetCertificate;
57468+
exports.AddBuildToTestGroups = AddBuildToTestGroups;
5746857469
const app_store_connect_api_1 = __nccwpck_require__(9073);
5746957470
const utilities_1 = __nccwpck_require__(5739);
5747057471
const core = __nccwpck_require__(2186);
@@ -57745,6 +57746,12 @@ async function UpdateTestDetails(project, whatsNew) {
5774557746
core.info(`Updating beta build localization...`);
5774657747
await updateBetaBuildLocalization(betaBuildLocalization, whatsNew);
5774757748
}
57749+
const betaGroups = core.getInput('beta-groups');
57750+
if (!betaGroups) {
57751+
return;
57752+
}
57753+
const betaGroupNames = betaGroups.split(',').map(group => group.trim());
57754+
await AddBuildToTestGroups(project, build, betaGroupNames);
5774857755
}
5774957756
function normalizeVersion(version) {
5775057757
return version.split('.').map(part => parseInt(part, 10).toString()).join('.');
@@ -57777,6 +57784,42 @@ async function GetCertificate(project, certificateType = null) {
5777757784
});
5777857785
return validCerts.length === 0 ? null : validCerts[0];
5777957786
}
57787+
async function AddBuildToTestGroups(project, build, testGroups) {
57788+
await getOrCreateClient(project);
57789+
const betaGroups = await getBetaGroupsByName(project, testGroups);
57790+
const payload = {
57791+
path: { id: build.id },
57792+
body: { data: betaGroups }
57793+
};
57794+
(0, utilities_1.log)(`POST /builds/${build.id}/relationships/betaGroups\n${JSON.stringify(payload, null, 2)}`);
57795+
const { data: response, error } = await appStoreConnectClient.api.BuildsService.buildsBetaGroupsCreateToManyRelationship(payload);
57796+
if (error) {
57797+
checkAuthError(error);
57798+
throw new Error(`Error adding build to test group: ${JSON.stringify(error, null, 2)}`);
57799+
}
57800+
const responseJson = JSON.stringify(response, null, 2);
57801+
(0, utilities_1.log)(responseJson);
57802+
}
57803+
async function getBetaGroupsByName(project, groupNames) {
57804+
await getOrCreateClient(project);
57805+
const request = {
57806+
query: {
57807+
"filter[name]": groupNames,
57808+
}
57809+
};
57810+
(0, utilities_1.log)(`GET /betaGroups?${JSON.stringify(request.query)}`);
57811+
const { data: response, error } = await appStoreConnectClient.api.BetaGroupsService.betaGroupsGetCollection(request);
57812+
if (error) {
57813+
checkAuthError(error);
57814+
throw new Error(`Error fetching test groups: ${JSON.stringify(error)}`);
57815+
}
57816+
const responseJson = JSON.stringify(response, null, 2);
57817+
if (!response || !response.data || response.data.length === 0) {
57818+
throw new Error(`No test groups found!`);
57819+
}
57820+
(0, utilities_1.log)(responseJson);
57821+
return response.data;
57822+
}
5778057823

5778157824

5778257825
/***/ }),
@@ -58924,7 +58967,7 @@ async function UploadApp(projectRef) {
5892458967
await (0, AppStoreConnectClient_1.UpdateTestDetails)(projectRef, whatsNew);
5892558968
}
5892658969
catch (error) {
58927-
(0, utilities_1.log)(`Failed to upload test details!\n${error}`, 'error');
58970+
(0, utilities_1.log)(`Failed to update test details!\n${error}`, 'error');
5892858971
}
5892958972
}
5893058973
async function getWhatsNew() {

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/AppStoreConnectClient.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import {
1313
PreReleaseVersionsGetCollectionData,
1414
BetaBuildLocalizationCreateRequest,
1515
CertificatesGetCollectionData,
16+
BetaGroupsGetCollectionData,
17+
BuildsBetaGroupsCreateToManyRelationshipData,
18+
BetaGroup,
1619
Certificate,
1720
} from '@rage-against-the-pixel/app-store-connect-api/dist/app_store_connect_api';
1821
import { log } from './utilities';
@@ -298,6 +301,10 @@ export async function UpdateTestDetails(project: XcodeProject, whatsNew: string)
298301
core.info(`Updating beta build localization...`);
299302
await updateBetaBuildLocalization(betaBuildLocalization, whatsNew);
300303
}
304+
const betaGroups = core.getInput('beta-groups');
305+
if (!betaGroups) { return; }
306+
const betaGroupNames = betaGroups.split(',').map(group => group.trim());
307+
await AddBuildToTestGroups(project, build, betaGroupNames);
301308
}
302309

303310
function normalizeVersion(version: string): string {
@@ -333,3 +340,42 @@ export async function GetCertificate(project: XcodeProject, certificateType: 'AP
333340
});
334341
return validCerts.length === 0 ? null : validCerts[0];
335342
}
343+
344+
export async function AddBuildToTestGroups(project: XcodeProject, build: Build, testGroups: string[]): Promise<void> {
345+
await getOrCreateClient(project);
346+
const betaGroups = await getBetaGroupsByName(project, testGroups);
347+
// POST https://api.appstoreconnect.apple.com/v1/builds/{id}/relationships/betaGroups
348+
const payload: BuildsBetaGroupsCreateToManyRelationshipData = {
349+
path: { id: build.id },
350+
body: { data: betaGroups }
351+
};
352+
log(`POST /builds/${build.id}/relationships/betaGroups\n${JSON.stringify(payload, null, 2)}`);
353+
const { data: response, error } = await appStoreConnectClient.api.BuildsService.buildsBetaGroupsCreateToManyRelationship(payload);
354+
if (error) {
355+
checkAuthError(error);
356+
throw new Error(`Error adding build to test group: ${JSON.stringify(error, null, 2)}`);
357+
}
358+
const responseJson = JSON.stringify(response, null, 2);
359+
log(responseJson);
360+
}
361+
362+
async function getBetaGroupsByName(project: XcodeProject, groupNames: string[]): Promise<BetaGroup[]> {
363+
await getOrCreateClient(project);
364+
const request: BetaGroupsGetCollectionData = {
365+
query: {
366+
"filter[name]": groupNames,
367+
}
368+
}
369+
log(`GET /betaGroups?${JSON.stringify(request.query)}`);
370+
const { data: response, error } = await appStoreConnectClient.api.BetaGroupsService.betaGroupsGetCollection(request);
371+
if (error) {
372+
checkAuthError(error);
373+
throw new Error(`Error fetching test groups: ${JSON.stringify(error)}`);
374+
}
375+
const responseJson = JSON.stringify(response, null, 2);
376+
if (!response || !response.data || response.data.length === 0) {
377+
throw new Error(`No test groups found!`);
378+
}
379+
log(responseJson);
380+
return response.data;
381+
}

src/xcode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ export async function UploadApp(projectRef: XcodeProject) {
911911
core.info(`\n--------------- what's new ---------------\n${whatsNew}\n------------------------------------------\n`);
912912
await UpdateTestDetails(projectRef, whatsNew);
913913
} catch (error) {
914-
log(`Failed to upload test details!\n${error}`, 'error');
914+
log(`Failed to update test details!\n${error}`, 'error');
915915
}
916916
}
917917

0 commit comments

Comments
 (0)