-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from sass/homebrew
Automate Homebrew deployment
- Loading branch information
Showing
5 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: sass_migrator | ||
version: 1.0.0-dev | ||
version: 1.0.0-beta.1 | ||
description: A tool for running migrations on Sass files | ||
author: Jennifer Thakar <[email protected]> | ||
homepage: https://github.com/sass/migrator | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2019 Google Inc. Use of this source code is governed by an | ||
// MIT-style license that can be found in the LICENSE file or at | ||
// https://opensource.org/licenses/MIT. | ||
|
||
import 'dart:io'; | ||
import 'dart:convert'; | ||
|
||
import 'package:crypto/crypto.dart'; | ||
import 'package:grinder/grinder.dart'; | ||
import 'package:path/path.dart' as p; | ||
|
||
import 'utils.dart'; | ||
|
||
/// A regular expression for locating the URL and SHA256 hash of the Sass | ||
/// archive in the `homebrew-sass` formula. | ||
final _homebrewRegExp = RegExp(r'\n( *)url "[^"]+"' | ||
r'\n *sha256 "[^"]+"'); | ||
|
||
@Task('Update the Homebrew formula for the current version.') | ||
updateHomebrew() async { | ||
ensureBuild(); | ||
|
||
var process = await Process.start("git", | ||
["archive", "--prefix=migrator-$version/", "--format=tar.gz", version]); | ||
var digest = await sha256.bind(process.stdout).first; | ||
var stderr = await utf8.decodeStream(process.stderr); | ||
if ((await process.exitCode) != 0) { | ||
fail('git archive "$version" failed:\n$stderr'); | ||
} | ||
|
||
var repo = await cloneOrPull("https://github.com/sass/homebrew-sass.git"); | ||
|
||
var formula = File(p.join(repo, "migrator.rb")); | ||
log("updating ${formula.path}"); | ||
formula.writeAsStringSync(formula.readAsStringSync().replaceFirstMapped( | ||
_homebrewRegExp, | ||
(match) => '\n${match[1]}url ' | ||
'"https://github.com/sass/migrator/archive/$version.tar.gz"' | ||
'\n${match[1]}sha256 "$digest"')); | ||
|
||
run("git", | ||
arguments: [ | ||
"commit", | ||
"--all", | ||
"--message", | ||
"Update the Sass migrator to $version" | ||
], | ||
workingDirectory: repo, | ||
runOptions: sassBotEnvironment); | ||
|
||
var username = environment('GITHUB_USER'); | ||
var password = environment('GITHUB_AUTH'); | ||
await runAsync("git", | ||
arguments: [ | ||
"push", | ||
"https://$username:$password@github.com/sass/homebrew-sass.git", | ||
"HEAD:master" | ||
], | ||
workingDirectory: repo); | ||
} |