Updates the version: field in pubspec.yaml for Dart and Flutter projects.
This plugin is distributed as the standalone Go binary semrel-plugin-updater-pubspec. Semrel executes the binary as a subprocess, provides plugin configuration through SEMREL_PLUGIN_* environment variables, provides release context through SEMREL_* environment variables, reads standard output, and treats exit code 0 as success and any non-zero exit code as failure. Install the binary in ~/.semrel/plugins/ or anywhere on your $PATH.
go install github.com/SemRels/updater-pubspec/cmd/plugin@latestPre-built, multi-platform images (linux/amd64, linux/arm64) are published to the GitHub Container Registry on every release:
docker pull ghcr.io/semrels/updater-pubspec:latestImages are signed with cosign and include a full SBOM attestation. Verify the signature:
cosign verify ghcr.io/semrels/updater-pubspec:latest \
--certificate-identity-regexp 'https://github.com/SemRels/updater-pubspec/.github/workflows/release.yml.*' \
--certificate-oidc-issuer https://token.actions.githubusercontent.complugins:
- name: updater-pubspec
path: ~/.semrel/plugins/semrel-plugin-updater-pubspec
env:
SEMREL_PLUGIN_PUBSPEC_PATH: "packages/app/pubspec.yaml"
SEMREL_PLUGIN_PUBSPEC_BUILD_STRATEGY: "increment"| Name | Required | Description | Default |
|---|---|---|---|
SEMREL_PLUGIN_PUBSPEC_PATH |
Optional | Path to the pubspec.yaml file to update. |
./pubspec.yaml |
SEMREL_PLUGIN_PUBSPEC_BUILD_STRATEGY |
Optional | Build suffix strategy: none, increment, or release-count. |
none |
SEMREL_PLUGIN_PUBSPEC_BUILD_NUMBER |
Optional | Explicit build number override. When set it always wins and writes SEMREL_VERSION+<number>. |
unset |
| Variable | Description |
|---|---|
SEMREL_VERSION |
Resolved release version for the current run. |
SEMREL_NEXT_VERSION |
Next version computed by semrel for the release. |
SEMREL_DRY_RUN |
Whether semrel is running in dry-run mode. |
SEMREL_RELEASE_COUNT |
Optional release-count input if semrel or the caller provides it. |
SEMREL_BUILD_NUMBER |
Optional build-number input if CI or semrel provides it. |
The plugin always strips a leading v from SEMREL_VERSION / SEMREL_NEXT_VERSION before writing the semver part.
Removes any existing Flutter build suffix and writes only the bare semver.
Before:
version: 1.4.0+42After SEMREL_VERSION=v1.5.0:
version: 1.5.0Reads the current top-level version: line, increments the existing +build number, and preserves the rest of the file unchanged. If no build suffix exists, the plugin starts at +1. If the existing suffix is malformed, the plugin logs a warning to stderr and starts fresh at +1.
Before:
version: 1.4.0+42After SEMREL_VERSION=v1.5.0:
version: 1.5.0+43Use this when you want the Flutter build suffix to mirror a monotonically increasing release or CI counter.
Priority order:
SEMREL_PLUGIN_PUBSPEC_BUILD_NUMBERSEMREL_RELEASE_COUNTSEMREL_BUILD_NUMBER- Fallback to
existing build + 1with a warning if none of the above are set
Semrel's current ecosystem does not appear to expose a dedicated release-count environment variable yet, so callers commonly pass an external counter (for example GITHUB_RUN_NUMBER) through SEMREL_PLUGIN_PUBSPEC_BUILD_NUMBER.
Before:
version: 1.4.0+42After with SEMREL_VERSION=v1.5.0 and SEMREL_PLUGIN_PUBSPEC_BUILD_NUMBER=108:
version: 1.5.0+108With SEMREL_DRY_RUN=true, the plugin validates the file, computes the exact new version: line, prints it, and leaves pubspec.yaml untouched.
The plugin performs a surgical line-based replacement of the top-level version: key so comments, indentation, dependency blocks, and the rest of the YAML file remain untouched.
go test ./...
go vet ./...
go build ./...Apache-2.0