Skip to content

Commit c30f734

Browse files
authored
Merge pull request #106 from sass/homebrew
Automate Homebrew deployment
2 parents 1603d12 + bfffaec commit c30f734

File tree

5 files changed

+77
-1
lines changed

5 files changed

+77
-1
lines changed

.travis.yml

+11
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@ jobs:
9999
skip_cleanup: true
100100
on: {tags: true}
101101

102+
# Deploy to Homebrew.
103+
- name: Homebrew
104+
if: *deploy-if
105+
env: *github-env
106+
script: skip
107+
deploy:
108+
provider: script
109+
script: pub run grinder update-homebrew
110+
skip_cleanup: true
111+
on: {tags: true}
112+
102113
# Deploy to Chocolatey.
103114
- name: Chocolatey
104115
if: *deploy-if

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.0-beta.1
2+
3+
* Too many changes to list.
4+
15
## 1.0.0-alpha.5
26

37
* **Breaking change**: Remove `lib/runner.dart`. This package is only meant to

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass_migrator
2-
version: 1.0.0-dev
2+
version: 1.0.0-beta.1
33
description: A tool for running migrations on Sass files
44
author: Jennifer Thakar <[email protected]>
55
homepage: https://github.com/sass/migrator

tool/grind.dart

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:grinder/grinder.dart';
77
export 'grind/chocolatey.dart';
88
export 'grind/npm.dart';
99
export 'grind/github.dart';
10+
export 'grind/homebrew.dart';
1011
export 'grind/sanity_check.dart';
1112
export 'grind/standalone.dart';
1213

tool/grind/homebrew.dart

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
import 'dart:convert';
7+
8+
import 'package:crypto/crypto.dart';
9+
import 'package:grinder/grinder.dart';
10+
import 'package:path/path.dart' as p;
11+
12+
import 'utils.dart';
13+
14+
/// A regular expression for locating the URL and SHA256 hash of the Sass
15+
/// archive in the `homebrew-sass` formula.
16+
final _homebrewRegExp = RegExp(r'\n( *)url "[^"]+"'
17+
r'\n *sha256 "[^"]+"');
18+
19+
@Task('Update the Homebrew formula for the current version.')
20+
updateHomebrew() async {
21+
ensureBuild();
22+
23+
var process = await Process.start("git",
24+
["archive", "--prefix=migrator-$version/", "--format=tar.gz", version]);
25+
var digest = await sha256.bind(process.stdout).first;
26+
var stderr = await utf8.decodeStream(process.stderr);
27+
if ((await process.exitCode) != 0) {
28+
fail('git archive "$version" failed:\n$stderr');
29+
}
30+
31+
var repo = await cloneOrPull("https://github.com/sass/homebrew-sass.git");
32+
33+
var formula = File(p.join(repo, "migrator.rb"));
34+
log("updating ${formula.path}");
35+
formula.writeAsStringSync(formula.readAsStringSync().replaceFirstMapped(
36+
_homebrewRegExp,
37+
(match) => '\n${match[1]}url '
38+
'"https://github.com/sass/migrator/archive/$version.tar.gz"'
39+
'\n${match[1]}sha256 "$digest"'));
40+
41+
run("git",
42+
arguments: [
43+
"commit",
44+
"--all",
45+
"--message",
46+
"Update the Sass migrator to $version"
47+
],
48+
workingDirectory: repo,
49+
runOptions: sassBotEnvironment);
50+
51+
var username = environment('GITHUB_USER');
52+
var password = environment('GITHUB_AUTH');
53+
await runAsync("git",
54+
arguments: [
55+
"push",
56+
"https://$username:$password@github.com/sass/homebrew-sass.git",
57+
"HEAD:master"
58+
],
59+
workingDirectory: repo);
60+
}

0 commit comments

Comments
 (0)