diff --git a/.github/workflows/go.build.yaml b/.github/workflows/go.build.yaml index 7a49e57..158e358 100644 --- a/.github/workflows/go.build.yaml +++ b/.github/workflows/go.build.yaml @@ -85,3 +85,63 @@ jobs: asset_path: beach_darwin_amd64.zip asset_name: beach_darwin_amd64.zip asset_content_type: application/zip + + - name: Calculate checksums + id: calculate-checksums + run: | + echo "::set-output name=darwin_sha256sum::$(sha256sum beach_darwin_amd64.zip)" + echo "::set-output name=linux_sha256sum::$(sha256sum beach_linux_amd64.zip)" + + homebrew: + name: Homebrew release + runs-on: ubuntu-latest + needs: build + steps: + + - name: Check out Homebrew code + uses: actions/checkout@v2 + with: + repository: flownative/homebrew-flownative + path: homebrew + + - name: Copy file + uses: canastro/copy-action@0.0.2 + with: + source: .github/workflows/localbeach.rb.tpl + target: homebrew/Formula/localbeach.rb + + - name: Replace version number + uses: shitiomatic/str-replace@master + with: + find: "{{version}}" + replace: ${{ github.ref }} + include: homebrew/Formula/localbeach.rb + + - name: Replace SHA256 sum (darwin) + uses: shitiomatic/str-replace@master + with: + find: "{{{darwin_sha256sum}}" + replace: ${{needs.build.outputs.darwin_sha256sum}} + include: homebrew/Formula/localbeach.rb + + - name: Replace SHA256 sum (linux) + uses: shitiomatic/str-replace@master + with: + find: "{{linux_sha256sum}}" + replace: ${{needs.build.outputs.linux_sha256sum}} + include: homebrew/Formula/localbeach.rb + + - name: Commit update + uses: EndBug/add-and-commit@v5 + with: + add: 'homebrew' + branch: master + cwd: './homebrew' + message: 'localbeach: update to ${{ github.ref }}' + + - name: Push to git + uses: ad-m/github-push-action@v0.6.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + repository: flownative/homebrew-flownative + directory: homebrew diff --git a/.github/workflows/localbeach.rb.tpl b/.github/workflows/localbeach.rb.tpl new file mode 100644 index 0000000..fb0f33c --- /dev/null +++ b/.github/workflows/localbeach.rb.tpl @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +# +# DO NOT EDIT THIS FILE MANUALLY +# +class Localbeach < Formula + desc "Command-line tool for Flownative Beach" + homepage "https://www.flownative.com/beach" + license "GPL-3.0-or-later" + version "{{version}}" + + if RUBY_PLATFORM.downcase.include?("darwin") + url "https://github.com/flownative/localbeach/releases/download/{{version}}/beach_darwin_amd64.zip" + sha256 "{{darwin_sha256sum}}" + else + url "https://github.com/flownative/localbeach/releases/download/{{version}}/beach_linux_amd64.zip" + sha256 "{{linux_sha256sum}}" + end + + bottle :unneeded + + conflicts_with "flownative/flownative/beach-cli", because: "localbeach replaces beach-cli" + + def install + database_path = RUBY_PLATFORM.downcase.include?("darwin") ? "~/Library/Application Support/Flownative/Local Beach/MariaDB" : "~/.Flownative/Local Beach/MariaDB" + + bin.install "beach" => "beach" + system "#{bin}/beach", "setup", "--docker-folder", "#{lib}/localbeach", "--database-folder", database_path + end +end