Skip to content

Plugin: updater-composer

Updates the version field in composer.json for PHP projects when explicitly opted in. Because Composer 2.x typically derives package versions from Git tags, this plugin leaves composer.json untouched by default unless update_version_field: "true" is configured.

Terminal window
semrel plugin install @semrel/updater-composer

semrel plugin install downloads the binary to .semrel/plugins/ and updates .semrel.lock. Commit .semrel.lock to pin the version for your team.

Pre-built, signed multi-platform images (linux/amd64, linux/arm64) are published on every release:

Terminal window
docker pull ghcr.io/semrels/updater-composer:latest

Verify the image signature with cosign:

Terminal window
cosign verify ghcr.io/semrels/updater-composer:latest \
--certificate-identity-regexp 'https://github.com/SemRels/updater-composer/.github/workflows/release.yml.*' \
--certificate-oidc-issuer https://token.actions.githubusercontent.com
version: 1
plugins:
- uses: @semrel/updater-composer
phase: pre-tag
args:
file: composer.json
update_version_field: "true"
NameRequiredDefaultDescription
SEMREL_PLUGIN_FILEnocomposer.jsonPath to the Composer manifest to update.
SEMREL_PLUGIN_COMPOSER_FILEno—Alias for SEMREL_PLUGIN_FILE when a Composer-specific variable name is preferred.
SEMREL_PLUGIN_UPDATE_VERSION_FIELDnofalseWhen true, updates or inserts the version field in composer.json.
  • SEMREL_VERSION
  • SEMREL_NEXT_VERSION
  • SEMREL_DRY_RUN

By default the plugin is a safe no-op and logs why it did not modify composer.json. When SEMREL_PLUGIN_UPDATE_VERSION_FIELD=true, it strips any leading v from the release version, writes the bare SemVer string to composer.json, and preserves existing key ordering and formatting.