Skip to content

Commit 281838e

Browse files
authored
Deploy to Bazel on release (#358)
Closes bazelbuild/rules_sass#28
1 parent c97e364 commit 281838e

File tree

5 files changed

+69
-6
lines changed

5 files changed

+69
-6
lines changed

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ jobs:
119119
skip_cleanup: true
120120
on: {tags: true}
121121

122+
# Deploy to Bazel.
123+
- if: *deploy-if
124+
env: *github-env
125+
script: skip
126+
deploy:
127+
provider: script
128+
script: pub run grinder update_bazel
129+
skip_cleanup: true
130+
on: {tags: true}
131+
122132
# Deploy to Chocolatey.
123133
- if: *deploy-if
124134
env:

tool/grind.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:grinder/grinder.dart';
77
import 'grind/npm.dart';
88
import 'grind/synchronize.dart';
99

10+
export 'grind/bazel.dart';
1011
export 'grind/benchmark.dart';
1112
export 'grind/chocolatey.dart';
1213
export 'grind/github.dart';

tool/grind/bazel.dart

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright 2018 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:grinder/grinder.dart';
8+
import 'package:path/path.dart' as p;
9+
10+
import 'utils.dart';
11+
12+
@Task('Update the Bazel rules for the current version.')
13+
update_bazel() async {
14+
ensureBuild();
15+
16+
var repo = await cloneOrPull("https://github.com/bazelbuild/rules_sass.git");
17+
18+
var packageFile = new File(p.join(repo, "sass", "package.json"));
19+
log("updating ${packageFile.path}");
20+
packageFile.writeAsStringSync(packageFile
21+
.readAsStringSync()
22+
.replaceFirst(new RegExp(r'"sass": "[^"]+"'), '"sass": "$version"'));
23+
24+
run("git",
25+
arguments: [
26+
"commit",
27+
"--all",
28+
"--message",
29+
"Update Dart Sass to $version"
30+
],
31+
workingDirectory: repo,
32+
runOptions: sassBotEnvironment);
33+
34+
run("git",
35+
arguments: ["tag", version],
36+
workingDirectory: repo,
37+
runOptions: sassBotEnvironment);
38+
39+
var username = environment('GITHUB_USER');
40+
var password = environment('GITHUB_AUTH');
41+
await runAsync("git",
42+
arguments: [
43+
"push",
44+
"--tags",
45+
"https://$username:$password@github.com/bazelbuild/rules_sass.git",
46+
"master:master"
47+
],
48+
workingDirectory: repo);
49+
}

tool/grind/homebrew.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,7 @@ update_homebrew() async {
4646
"Update Dart Sass to $version"
4747
],
4848
workingDirectory: repo,
49-
runOptions: new RunOptions(environment: {
50-
"GIT_AUTHOR_NAME": "Sass Bot",
51-
"GIT_AUTHOR_EMAIL": "sass.bot.beep.boop@gmail.com",
52-
"GIT_COMMITTER_NAME": "Sass Bot",
53-
"GIT_COMMITTER_EMAIL": "sass.bot.beep.boop@gmail.com"
54-
}));
49+
runOptions: sassBotEnvironment);
5550

5651
var username = environment('GITHUB_USER');
5752
var password = environment('GITHUB_AUTH');

tool/grind/utils.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ final String version =
2020
final Version dartVersion =
2121
new Version.parse(Platform.version.split(" ").first);
2222

23+
/// Options for [run] that tell Git to commit using SassBot's name and email.
24+
final sassBotEnvironment = new RunOptions(environment: {
25+
"GIT_AUTHOR_NAME": "Sass Bot",
26+
"GIT_AUTHOR_EMAIL": "sass.bot.beep.boop@gmail.com",
27+
"GIT_COMMITTER_NAME": "Sass Bot",
28+
"GIT_COMMITTER_EMAIL": "sass.bot.beep.boop@gmail.com"
29+
});
30+
2331
/// Whether we're using a dev Dart SDK.
2432
bool get isDevSdk => dartVersion.isPreRelease;
2533

0 commit comments

Comments
 (0)