Skip to content

Commit cc0dbb8

Browse files
committed
add apply bash step to publish
1 parent fa2612b commit cc0dbb8

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

.github/workflows/publish.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,25 @@ jobs:
5353
run: |
5454
yarn install
5555
56-
# TODO: apply deferred version
56+
- name: Apply deferred version bump and commit
57+
id: version-bump
58+
working-directory: .
59+
run: |
60+
CURRENT_VERSION=$(cat ./code/package.json | jq '.version')
61+
DEFERRED_NEXT_VERSION=$(cat ./code/package.json | jq '.deferredNextVersion')
62+
63+
if [[ "$DEFERRED_NEXT_VERSION" == "null" ]]; then
64+
echo "No deferred version set, not bumping versions"
65+
exit 0
66+
fi
67+
cd scripts
68+
yarn release:version --apply --verbose
69+
70+
git config --global user.name 'github-actions[bot]'
71+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
72+
git add .
73+
git commit -m "Bump version from $CURRENT_VERSION to $DEFERRED_NEXT_VERSION" || true
74+
git push origin ${{ github.ref_name }}
5775
5876
- name: Get current version
5977
id: version

scripts/release/__tests__/version.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,20 @@ describe('Version', () => {
189189
`);
190190
});
191191

192+
it('should throw when applying without a "deferredNextVersion" set', async () => {
193+
fsExtra.__setMockFiles({
194+
[CODE_PACKAGE_JSON_PATH]: JSON.stringify({ version: '1.0.0' }),
195+
});
196+
197+
await expect(version({ apply: true })).rejects.toThrowErrorMatchingInlineSnapshot(
198+
`"The 'deferredNextVersion' property in code/package.json is unset. This is necessary to apply a deferred version bump"`
199+
);
200+
201+
expect(fsExtra.writeJson).not.toHaveBeenCalled();
202+
expect(fsExtra.writeFile).not.toHaveBeenCalled();
203+
expect(execaCommand).not.toHaveBeenCalled();
204+
});
205+
192206
it.each([
193207
// prettier-ignore
194208
{ releaseType: 'major', currentVersion: '1.1.1', expectedVersion: '2.0.0' },

0 commit comments

Comments
 (0)