Skip to content

Instantly share code, notes, and snippets.

@f3ath
Last active June 26, 2020 10:43
Show Gist options
  • Save f3ath/6d925b812ba27eeebbcb1d1dbe861d03 to your computer and use it in GitHub Desktop.
Save f3ath/6d925b812ba27eeebbcb1d1dbe861d03 to your computer and use it in GitHub Desktop.
Dart package release automation

Automating Dart package release in 3 steps

Everyone who maintains a Dart package has to maintain the changelog and release updates once in a while. It can become cumbersome to keep the pubspec version and the changelog in sync manually. These two small tools can make release process fun.

1. Install the tools

pub global activate change
pub global activate pubspec_version
  • change is a changelog manipulation tool. It can add entries and generate release sections with diff links and dates.
  • pubspec_version can bump the current package version. It is smart enough to understand breaking, major, minor, patch, and build versions.

2. Create the release script

Create a shell script with the following code:

#!/usr/bin/env bash
change release $(pubver bump "$1") -l "https://github.com/name/project/compare/%from%...%to%"

and put it somwhere handy, e.g. in ci/release.sh. Replace the name and project in the link, but keep the %% placeholders.

3. Enjoy

  • change added "New *cool* feature" - adds a new entry to te Unreleased section of the changelog
  • ./ci/release.sh minor - bumps the minor version in pubspec.yaml and creates a new release section in the changelog

For the complete feature list, see change and pubspec_version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment