diff --git a/.github/actions/publish-live-update/action.yml b/.github/actions/publish-live-update/action.yml index 32dae13..76b99ad 100644 --- a/.github/actions/publish-live-update/action.yml +++ b/.github/actions/publish-live-update/action.yml @@ -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=`). 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: diff --git a/.github/actions/publish-live-update/publish-live-update.mjs b/.github/actions/publish-live-update/publish-live-update.mjs index 67c7aee..fbc544b 100644 --- a/.github/actions/publish-live-update/publish-live-update.mjs +++ b/.github/actions/publish-live-update/publish-live-update.mjs @@ -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', @@ -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; } /** @@ -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, }; diff --git a/.github/actions/publish-live-update/publish-live-update.spec.mjs b/.github/actions/publish-live-update/publish-live-update.spec.mjs index b77b195..7dec30e 100644 --- a/.github/actions/publish-live-update/publish-live-update.spec.mjs +++ b/.github/actions/publish-live-update/publish-live-update.spec.mjs @@ -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', () => {