Skip to content

Commit

Permalink
Create deployment pipeline for Homebrew (#669)
Browse files Browse the repository at this point in the history
* Update upload-binary.yml

* test CI 3

* test CI 5

* test CI 6

* test CI 7

* tes CI 8

* test CI 9

* create monika.rb

* add script tbump version

* try comment

* use action brew

* add example rb file

* use minimized code

* add workflow run trigger

Co-authored-by: Nico Prananta <[email protected]>
  • Loading branch information
raosan and nicnocquee authored May 25, 2022
1 parent d3eb10c commit 2b2444f
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 2 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/publish-homebrew.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish to Homebrew

on:
workflow_dispatch:
workflow_run: # Only trigger, when the npm-publish workflow succeeded
workflows: ["Node.js Package"]
types:
- completed

jobs:
homebrew:
name: Bump Homebrew formula
runs-on: ubuntu-latest
steps:
- name: Get Package Version
id: package-version
uses: martinbeentjes/npm-get-version-action@master

- uses: mislav/bump-homebrew-formula-action@v2
with:
formula-name: monika
download-url: https://registry.npmjs.org/@hyperjumptech/monika/-/monika-${{ steps.package-version.outputs.current-version }}.tgz
env:
COMMITTER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/upload-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,14 @@ jobs:
run: cat ./chocolatey/tools/chocolateyinstall.ps1

- run: echo ${{ steps.get_version.outputs.VERSION }} | sed 's/^.//' > version_number.txt
name: Write version number without preftix
name: Write version number without prefix
if: runner.os == 'Windows'

- name: See version_number.txt content
if: runner.os == 'Windows'
run: cat version_number.txt

- name: Read version number without preftix
- name: Read version number without prefix
if: runner.os == 'Windows'
id: read_version
uses: juliangruber/read-file-action@v1
Expand Down
44 changes: 44 additions & 0 deletions homebrew/monika.example.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This file is an example file and generated using https://github.com/zmwangx/homebrew-npm-noob
require "language/node"

class Monika < Formula
desc "Synthetic monitoring made easy"
homepage "https://monika.hyperjump.tech"
url "https://registry.npmjs.org/@hyperjumptech/monika/-/monika-1.7.2.tgz"
sha256 "ec1e6a934ab1343c3dc5e576dcb73a78cdd6852f8353891889fec0ad4db18bf5"
license "MIT"

depends_on "node"

def install
system "npm", "install", *Language::Node.std_npm_install_args(libexec)
bin.install_symlink Dir["#{libexec}/bin/*"]

# Remove unexpected universal binaries
deuniversalize_machos
end

test do
(testpath/"config.yml").write <<~EOS
notifications:
- id: 5b3052ed-4d92-4f5d-a949-072b3ebb2497
type: desktop
probes:
- id: 696a3f57-a674-44b5-8125-a62bd2709ac5
name: 'test brew.sh'
requests:
- url: https://brew.sh
body: {}
timeout: 10000
EOS

monika_stdout = (testpath/"monika.log")
fork do
$stdout.reopen(monika_stdout)
exec bin/"monika", "-r", "1", "-c", testpath/"config.yml"
end
sleep 5

assert_match "Starting Monika. Probes: 1. Notifications: 1", monika_stdout.read
end
end

0 comments on commit 2b2444f

Please sign in to comment.