Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for Linux-homebrew installation #5085

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/actions/checksum/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'Checksum'
description: 'Calculate checksum for URL'
inputs:
url:
description: 'URL to checksum'
required: true
outputs:
sha256:
description: "SHA256 checksum"
value: ${{ steps.checksum.outputs.sha256 }}
runs:
using: "composite"
steps:
- id: checksum
run: |
set -o pipefail

if ! checksum=$(curl -sSL --fail "${{ env.URL }}" | shasum -a 256 | cut -d ' ' -f 1);
then
echo "Failed to fetch URL ${{ env.URL }}"
exit 1
fi

echo "sha256=$checksum" >> "$GITHUB_OUTPUT"
shell: bash
env:
URL: ${{ inputs.url }}
81 changes: 46 additions & 35 deletions .github/workflows/reusable-create-homebrew-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,53 @@ permissions:
contents: read

jobs:
fetch-release-checksums:
homebrew-sha256:
runs-on: ubuntu-latest
env:
ARM_TARBALL_URL: https://download.garden.io/core/${{ inputs.release-version }}/garden-${{ inputs.release-version }}-macos-arm64.tar.gz
AMD_TARBALL_URL: https://download.garden.io/core/${{ inputs.release-version }}/garden-${{ inputs.release-version }}-macos-amd64.tar.gz
MACOS_ARM_TARBALL_URL: https://download.garden.io/core/${{ inputs.release-version }}/garden-${{ inputs.release-version }}-macos-arm64.tar.gz
MACOS_AMD_TARBALL_URL: https://download.garden.io/core/${{ inputs.release-version }}/garden-${{ inputs.release-version }}-macos-amd64.tar.gz
LINUX_ARM_TARBALL_URL: https://download.garden.io/core/${{ inputs.release-version }}/garden-${{ inputs.release-version }}-linux-arm64.tar.gz
LINUX_AMD_TARBALL_URL: https://download.garden.io/core/${{ inputs.release-version }}/garden-${{ inputs.release-version }}-linux-amd64.tar.gz
outputs:
arm-sha256: ${{ steps.fetch-arm-sha256.outputs.sha256 }}
amd-sha256: ${{ steps.fetch-amd-sha256.outputs.sha256 }}
arm-tarball-url: ${{ env.ARM_TARBALL_URL }}
amd-tarball-url: ${{ env.AMD_TARBALL_URL }}
macos-arm-tarball-url: ${{ env.MACOS_ARM_TARBALL_URL }}
macos-amd-tarball-url: ${{ env.MACOS_AMD_TARBALL_URL }}
macos-arm-sha256: ${{ steps.macos-arm.outputs.sha256 }}
macos-amd-sha256: ${{ steps.macos-amd.outputs.sha256 }}
linux-arm-tarball-url: ${{ env.LINUX_ARM_TARBALL_URL }}
linux-amd-tarball-url: ${{ env.LINUX_AMD_TARBALL_URL }}
linux-arm-sha256: ${{ steps.linux-arm.outputs.sha256 }}
linux-amd-sha256: ${{ steps.linux-amd.outputs.sha256 }}
steps:
- name: Fetch arm sha256
id: fetch-arm-sha256
if: inputs.release-condition != 'false'
run: |
set -o pipefail
- name: Checkout garden repo
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # 4.0.0

if ! checksum=$(curl -sSL --fail ${{ env.ARM_TARBALL_URL }} | shasum -a 256 | cut -d ' ' -f 1);
then
echo "Failed to fetch binary from ${{ env.ARM_TARBALL_URL }}"
exit 1
fi
- name: Checksum Linux ARM64
id: linux-arm
uses: ./.github/actions/checksum
with:
url: ${{ env.LINUX_ARM_TARBALL_URL }}

echo "sha256=$checksum" >> "$GITHUB_OUTPUT"
- name: Fetch amd sha256
id: fetch-amd-sha256
if: inputs.release-condition != 'false'
run: |
set -o pipefail
- name: Checksum Linux AMD64
id: linux-amd
uses: ./.github/actions/checksum
with:
url: ${{ env.LINUX_AMD_TARBALL_URL }}

- name: Checksum MacOS ARM
id: macos-arm
uses: ./.github/actions/checksum
with:
url: ${{ env.MACOS_ARM_TARBALL_URL }}

if ! checksum=$(curl -sSL --fail ${{ env.AMD_TARBALL_URL }} | shasum -a 256 | cut -d ' ' -f 1);
then
echo "Failed to fetch binary from ${{ env.AMD_TARBALL_URL }}"
exit 1
fi
- name: Checksum MacOS AMD
id: macos-amd
uses: ./.github/actions/checksum
with:
url: ${{ env.MACOS_AMD_TARBALL_URL }}

echo "sha256=$checksum" >> "$GITHUB_OUTPUT"
homebrew-create-pr:
runs-on: ubuntu-latest
needs: fetch-release-checksums
needs: homebrew-sha256
steps:
- name: Checks release pre-condition
if: inputs.release-condition == 'false'
Expand Down Expand Up @@ -92,11 +99,15 @@ jobs:
strict: true
variables: |
version=${{ inputs.release-version }}
armTarballUrl=${{ needs.fetch-release-checksums.outputs.arm-tarball-url }}
amdTarballUrl=${{ needs.fetch-release-checksums.outputs.amd-tarball-url }}
armSha256=${{ needs.fetch-release-checksums.outputs.arm-sha256 }}
amdSha256=${{ needs.fetch-release-checksums.outputs.amd-sha256 }}

macosArmTarballUrl=${{ needs.homebrew-sha256.outputs.macos-arm-tarball-url }}
macosAmdTarballUrl=${{ needs.homebrew-sha256.outputs.macos-amd-tarball-url }}
macosArmSha256=${{ needs.homebrew-sha256.outputs.macos-arm-sha256 }}
macosAmdSha256=${{ needs.homebrew-sha256.outputs.macos-amd-sha256 }}
linuxArmTarballUrl=${{ needs.homebrew-sha256.outputs.linux-arm-tarball-url }}
linuxAmdTarballUrl=${{ needs.homebrew-sha256.outputs.linux-amd-tarball-url }}
linuxArmSha256=${{ needs.homebrew-sha256.outputs.linux-arm-sha256 }}
linuxAmdSha256=${{ needs.homebrew-sha256.outputs.linux-amd-sha256 }}

- name: Create PR on Homebrew Repository
if: inputs.release-condition != 'false'
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # 5.0.2
Expand Down
24 changes: 17 additions & 7 deletions support/homebrew-formula.rb.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@ class GardenCli < Formula

depends_on "rsync"

# Determine architecture
if Hardware::CPU.arm?
url "{{armTarballUrl}}"
sha256 "{{armSha256}}"
if OS.linux?
if Hardware::CPU.arm?
url "{{linuxArmTarballUrl}}"
sha256 "{{linuxArmSha256}}"
else
url "{{linuxAmdTarballUrl}}"
sha256 "{{linuxAmdSha256}}"
end
else
url "{{amdTarballUrl}}"
sha256 "{{amdSha256}}"
end
# macos
if Hardware::CPU.arm?
url "{{macosArmTarballUrl}}"
sha256 "{{macosArmSha256}}"
else
url "{{macosAmdTarballUrl}}"
sha256 "{{macosAmdSha256}}"
end
end

def install
libexec.install "garden", "fsevents.node", "static"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formula doesn't work on linux, I am getting a weird error:

steffen@lima-default:~$ brew install garden-cli
Running `brew update --auto-update`...
==> Fetching garden-io/garden/garden-cli
==> Downloading https://download.garden.io/core/0.13.13/garden-0.13.13-linux-amd64.tar.gz
Already downloaded: /home/steffen.linux/.cache/Homebrew/downloads/f852a6a846822bbdd4f0f27cb714d1d92ed7f36400a52f3a54cb61178e746b06--garden-0.13.13-linux-amd64.tar.gz
==> Installing garden-cli from garden-io/garden
Error: The following formula cannot be installed from bottle and must be
built from source.
  garden-cli
Install Clang or run `brew install gcc`.

When debugging I noticed that the linux archive does not contain an fsevents.node file, but even if I do not copy that file I still get this error. I got stuck there and gave up for now.

Expand Down