Skip to content

Commit

Permalink
feat: update VERSION file in PHP repo if it exists (#2153)
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer authored Dec 5, 2023
1 parent f2472e1 commit a7d3b73
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/strategies/php.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {Changelog} from '../updaters/changelog';
// PHP Specific.
import {RootComposerUpdatePackages} from '../updaters/php/root-composer-update-packages';
import {BaseStrategy, BuildUpdatesOptions, BaseStrategyOptions} from './base';
import {DefaultUpdater} from '../updaters/default';
import {Update} from '../update';
import {VersionsMap} from '../version';

Expand Down Expand Up @@ -67,6 +68,15 @@ export class PHP extends BaseStrategy {
}),
});

// update VERSION file
updates.push({
path: this.addPath('VERSION'),
createIfMissing: false,
updater: new DefaultUpdater({
version,
}),
});

return updates;
}
}
4 changes: 3 additions & 1 deletion test/strategies/php.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {TagName} from '../../src/util/tag-name';
import {Version} from '../../src/version';
import {Changelog} from '../../src/updaters/changelog';
import {RootComposerUpdatePackages} from '../../src/updaters/php/root-composer-update-packages';
import {DefaultUpdater} from '../../src/updaters/default';

const sandbox = sinon.createSandbox();

Expand Down Expand Up @@ -95,9 +96,10 @@ describe('PHP', () => {
latestRelease
);
const updates = release!.updates;
expect(updates).lengthOf(2);
expect(updates).lengthOf(3);
assertHasUpdate(updates, 'CHANGELOG.md', Changelog);
assertHasUpdate(updates, 'composer.json', RootComposerUpdatePackages);
assertHasUpdate(updates, 'VERSION', DefaultUpdater);
});
});
});

0 comments on commit a7d3b73

Please sign in to comment.