Skip to content

Commit 3368e89

Browse files
authored
Add a grind script to sanity-check a release (#563)
Add a grind script to sanity-check a release This will help avoid accidentally releasing dev versions 😖.
1 parent e3ae470 commit 3368e89

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

.travis.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,15 @@ script: tool/travis/test.sh
7373

7474
jobs:
7575
include:
76-
# Deploy to GitHub.
77-
- stage: deploy 1
76+
# Sanity check before releasing anywhere.
77+
- stage: sanity check
7878
if: &deploy-if
7979
(type IN (push, api)) AND (repo = sass/dart-sass) AND tag =~ ^\d+\.\d+\.\d+([+-].*)?$
80+
script: pub run grinder sanity-check-before-release
81+
82+
# Deploy to GitHub.
83+
- stage: deploy 1
84+
if: *deploy-if
8085
env: &github-env
8186
- GITHUB_USER=sassbot
8287
# GITHUB_AUTH="..."

tool/grind.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export 'grind/chocolatey.dart';
1313
export 'grind/github.dart';
1414
export 'grind/homebrew.dart';
1515
export 'grind/npm.dart';
16+
export 'grind/sanity_check.dart';
1617
export 'grind/standalone.dart';
1718
export 'grind/synchronize.dart';
1819

tool/grind/sanity_check.dart

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2019 Google Inc. Use of this source code is governed by an
2+
// MIT-style license that can be found in the LICENSE file or at
3+
// https://opensource.org/licenses/MIT.
4+
5+
import 'dart:io';
6+
7+
import 'package:collection/collection.dart';
8+
import 'package:grinder/grinder.dart';
9+
import 'package:pub_semver/pub_semver.dart';
10+
11+
import 'utils.dart';
12+
13+
@Task('Verify that the package is in a good state to release.')
14+
sanityCheckBeforeRelease() {
15+
var travisTag = environment("TRAVIS_TAG");
16+
if (travisTag != version) {
17+
fail("TRAVIS_TAG $travisTag is different than pubspec version $version.");
18+
}
19+
20+
if (const ListEquality().equals(Version.parse(version).preRelease, ["dev"])) {
21+
fail("$version is a dev release.");
22+
}
23+
24+
var versionHeader =
25+
RegExp("^## ${RegExp.escape(version)}\$", multiLine: true);
26+
if (!File("CHANGELOG.md").readAsStringSync().contains(versionHeader)) {
27+
fail("There's no CHANGELOG entry for $version.");
28+
}
29+
}

0 commit comments

Comments
 (0)