-
Notifications
You must be signed in to change notification settings - Fork 275
122 lines (109 loc) · 4.53 KB
/
reusable-create-homebrew-pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: Reusable create homebrew PR
on:
workflow_call:
inputs:
release-condition:
type: string
required: false
description: "Example: false"
release-version:
type: string
required: true
description: "Example: 0.48.0"
commit-message:
type: string
description: "Commit message for homebrew repository."
default: |
For more info: https://github.com/garden-io/garden
permissions:
contents: read
jobs:
fetch-release-checksums:
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
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 }}
steps:
- name: Fetch arm sha256
id: fetch-arm-sha256
if: inputs.release-condition != 'false'
run: |
set -o pipefail
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
echo "sha256=$checksum" >> "$GITHUB_OUTPUT"
- name: Fetch amd sha256
id: fetch-amd-sha256
if: inputs.release-condition != 'false'
run: |
set -o pipefail
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
echo "sha256=$checksum" >> "$GITHUB_OUTPUT"
homebrew-create-pr:
runs-on: ubuntu-latest
needs: fetch-release-checksums
steps:
- name: Checks release pre-condition
if: inputs.release-condition == 'false'
run: |
echo The release-condition evaluated to false.
echo Skipping all the next steps.
- name: Checkout garden repo
if: inputs.release-condition != 'false'
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
repository: garden-io/garden
path: garden
- name: Checkout homebrew repo
if: inputs.release-condition != 'false'
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
repository: garden-io/homebrew-garden
ref: main
path: homebrew-garden
token: ${{ secrets.COMMITTER_TOKEN }}
- name: Template Homebrew Formula
if: inputs.release-condition != 'false'
uses: ajeffowens/jinja2-action@90dab3da2215932ea86d2875224f06bbd6798617 # v2.0.0
with:
template: garden/support/homebrew-formula.rb.j2
output_file: homebrew-garden/Formula/garden-cli.rb
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 }}
- name: Create PR on Homebrew Repository
if: inputs.release-condition != 'false'
uses: peter-evans/create-pull-request@b1ddad2c994a25fbc81a28b3ec0e368bb2021c50 # 6.0.0
with:
path: ${{ github.workspace }}/homebrew-garden
token: ${{ secrets.COMMITTER_TOKEN }}
commit-message: |
Bump garden-cli.rb to ${{ inputs.release-version }}
${{ inputs.commit-message }}
title: Bump garden-cli to ${{ inputs.release-version }}
body: |
Bump garden-cli.rb to ${{ inputs.release-version }}
${{ inputs.commit-message}}
branch: garden-cli-${{ inputs.release-version }}
reviewers: ${{ github.triggering_actor }}
- name: Adding markdown summary
if: inputs.release-condition != 'false'
run: |
echo '### Manual Steps required to finish publishing to Homebrew' >> "$GITHUB_STEP_SUMMARY"
echo 'Please review the new PR in https://github.com/garden-io/homebrew-garden/pulls' >> "$GITHUB_STEP_SUMMARY"