Skip to content

Commit

Permalink
Add a double-check to verify that we bump versions (#1498)
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 authored Sep 21, 2021
1 parent a881eb6 commit 0806763
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ jobs:
- uses: dart-lang/setup-dart@v1
- run: dart pub get
- name: Run checks
run: dart pub run grinder sanity-check-before-release
run: dart pub run grinder double-check-before-release

bootstrap:
name: "Bootstrap ${{ matrix.bootstrap_version }}"
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dev_dependencies:
grinder: ^0.9.0
node_preamble: ^2.0.0
pedantic: ^1.11.0
pub_api_client: ^2.1.1
pub_semver: ^2.0.0
pubspec_parse: ^1.0.0
stream_channel: ^2.1.0
Expand Down
2 changes: 1 addition & 1 deletion tool/grind.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import 'grind/synchronize.dart';

export 'grind/bazel.dart';
export 'grind/benchmark.dart';
export 'grind/double_check.dart';
export 'grind/frameworks.dart';
export 'grind/sanity_check.dart';
export 'grind/subpackages.dart';
export 'grind/synchronize.dart';

Expand Down
23 changes: 22 additions & 1 deletion tool/grind/sanity_check.dart → tool/grind/double_check.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import 'dart:io';

import 'package:cli_pkg/cli_pkg.dart' as pkg;
import 'package:grinder/grinder.dart';
import 'package:path/path.dart' as p;
import 'package:pub_api_client/pub_api_client.dart';
import 'package:pubspec_parse/pubspec_parse.dart';

import 'package:sass/src/utils.dart';

import 'utils.dart';

@Task('Verify that the package is in a good state to release.')
void sanityCheckBeforeRelease() {
Future<void> doubleCheckBeforeRelease() async {
var ref = environment("GITHUB_REF");
if (ref != "refs/tags/${pkg.version}") {
fail("GITHUB_REF $ref is different than pubspec version ${pkg.version}.");
Expand All @@ -27,4 +30,22 @@ void sanityCheckBeforeRelease() {
if (!File("CHANGELOG.md").readAsStringSync().contains(versionHeader)) {
fail("There's no CHANGELOG entry for ${pkg.version}.");
}

var client = PubClient();
try {
for (var dir in [
".",
...Directory("pkg").listSync().map((entry) => entry.path)
]) {
var pubspec = Pubspec.parse(File("$dir/pubspec.yaml").readAsStringSync(),
sourceUrl: p.toUri("$dir/pubspec.yaml"));

var package = await client.packageInfo(pubspec.name);
if (pubspec.version == package.latestPubspec.version) {
fail("${pubspec.name} ${pubspec.version} has already been released!");
}
}
} finally {
client.close();
}
}

0 comments on commit 0806763

Please sign in to comment.