Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/actions/publish-live-update/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ inputs:
description: Release version (with or without the leading v).
required: true
git-ref:
description: Git ref (commit SHA) recorded with the bundle.
description: >
Commit SHA recorded on the uploaded bundle as a custom property
(`commit=<sha>`). Not passed as Capawesome `--git-ref` (that requires
linking a git repository to the Cloud app via `apps:link`).
required: false
default: ${{ github.sha }}
cli-version:
Expand Down
16 changes: 9 additions & 7 deletions .github/actions/publish-live-update/publish-live-update.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function channelCreateArgs({ cliVersion, appId, channel }) {
}

export function uploadArgs({ cliVersion, appId, channel, bundlePath, privateKeyPath, buildNumber, gitRef, version, rolloutPercentage }) {
return [
const args = [
cli(cliVersion),
'apps:liveupdates:upload',
'--app-id',
Expand All @@ -58,14 +58,17 @@ export function uploadArgs({ cliVersion, appId, channel, bundlePath, privateKeyP
String(buildNumber),
'--ios-max',
String(buildNumber),
'--git-ref',
gitRef,
'--custom-property',
`version=${version}`,
'--rollout-percentage',
String(rolloutPercentage),
'--yes',
];
// Capawesome `--git-ref` requires the Cloud app to have a linked git repository
// (`apps:link`). Local CI uploads do not need that — record the commit as a
// custom property instead so apps without a linked repo still publish.
if (gitRef) {
args.push('--custom-property', `commit=${gitRef}`);
}
args.push('--rollout-percentage', String(rolloutPercentage), '--yes');
return args;
}

/**
Expand Down Expand Up @@ -93,7 +96,6 @@ export function resolveOptions(args, env = {}) {
channel: options.channel,
'build-number': options.buildNumber,
version: options.version,
'git-ref': options.gitRef,
CAPAWESOME_TOKEN: options.token,
CAPAWESOME_LIVE_UPDATE_PRIVATE_KEY: options.privateKey,
};
Expand Down
21 changes: 20 additions & 1 deletion .github/actions/publish-live-update/publish-live-update.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,32 @@ describe('command builders', () => {
});
expect(args).toContain('apps:liveupdates:upload');
expect(args).toContain('--yes');
expect(args).not.toContain('--git-ref');
for (const flag of ['--android-min', '--android-max', '--ios-min', '--ios-max']) {
expect(args[args.indexOf(flag) + 1]).toBe('9000000');
}
expect(args[args.indexOf('--custom-property') + 1]).toBe('version=9.0.0');
expect(args.filter((_, index) => args[index - 1] === '--custom-property')).toEqual([
'version=9.0.0',
'commit=deadbeef',
]);
expect(args[args.indexOf('--rollout-percentage') + 1]).toBe('100');
expect(args[args.indexOf('--private-key') + 1]).toBe('private.pem');
});

it('uploadArgs omits commit custom property when gitRef is empty', () => {
const args = uploadArgs({
cliVersion: '4.15.0',
appId: 'a',
channel: 'production-1',
bundlePath: 'bundle.zip',
privateKeyPath: 'private.pem',
buildNumber: '1',
gitRef: undefined,
version: '1.0.0',
rolloutPercentage: '100',
});
expect(args.filter((_, index) => args[index - 1] === '--custom-property')).toEqual(['version=1.0.0']);
});
});

describe('resolveOptions', () => {
Expand Down