From 17b88e5c13932c498ad7f28a78b96d5d986447fc Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 1 Oct 2019 16:27:39 -0700 Subject: [PATCH 1/2] Automate Homebrew deployment Closes #26 --- .travis.yml | 11 ++++++++ tool/grind.dart | 1 + tool/grind/homebrew.dart | 60 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 tool/grind/homebrew.dart diff --git a/.travis.yml b/.travis.yml index c1d8436a..75c846ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -99,6 +99,17 @@ jobs: skip_cleanup: true on: {tags: true} + # Deploy to Homebrew. + - name: Homebrew + if: *deploy-if + env: *github-env + script: skip + deploy: + provider: script + script: pub run grinder update-homebrew + skip_cleanup: true + on: {tags: true} + # Deploy to Chocolatey. - name: Chocolatey if: *deploy-if diff --git a/tool/grind.dart b/tool/grind.dart index 294c8737..6cbeaac7 100644 --- a/tool/grind.dart +++ b/tool/grind.dart @@ -7,6 +7,7 @@ import 'package:grinder/grinder.dart'; export 'grind/chocolatey.dart'; export 'grind/npm.dart'; export 'grind/github.dart'; +export 'grind/homebrew.dart'; export 'grind/sanity_check.dart'; export 'grind/standalone.dart'; diff --git a/tool/grind/homebrew.dart b/tool/grind/homebrew.dart new file mode 100644 index 00000000..52c28c25 --- /dev/null +++ b/tool/grind/homebrew.dart @@ -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); +} From bfffaec1189b88fc5f592e24f67d3750b1e220d4 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 1 Oct 2019 16:28:40 -0700 Subject: [PATCH 2/2] Bump the pubspec for a beta release This is testing the release infrastructure more than anything. --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca34e9a2..b65f6744 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.0-beta.1 + +* Too many changes to list. + ## 1.0.0-alpha.5 * **Breaking change**: Remove `lib/runner.dart`. This package is only meant to diff --git a/pubspec.yaml b/pubspec.yaml index aabbbc75..6ad631c8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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 homepage: https://github.com/sass/migrator