-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (86 loc) · 4.48 KB
/
update-homebrew.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
name: Update Homebrew Tap
on:
release:
types: [published]
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
update-formula:
runs-on: ubuntu-latest
env:
TAG_NAME: ${{ github.event.release.tag_name || 'edge' }}
steps:
- name: Checkout the pops repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Download & compute checksums
id: checksums
run: |
VERSION=${{ env.TAG_NAME }}
# Download each artifact
curl -L -o pops-darwin-amd64 \
https://github.com/prompt-ops/pops/releases/download/${VERSION}/pops-darwin-amd64
curl -L -o pops-darwin-arm64 \
https://github.com/prompt-ops/pops/releases/download/${VERSION}/pops-darwin-arm64
curl -L -o pops-linux-amd64 \
https://github.com/prompt-ops/pops/releases/download/${VERSION}/pops-linux-amd64
curl -L -o pops-linux-arm64 \
https://github.com/prompt-ops/pops/releases/download/${VERSION}/pops-linux-arm64
# Compute checksums
DARWIN_AMD64_SHA=$(sha256sum pops-darwin-amd64 | cut -d ' ' -f1)
DARWIN_ARM64_SHA=$(sha256sum pops-darwin-arm64 | cut -d ' ' -f1)
LINUX_AMD64_SHA=$(sha256sum pops-linux-amd64 | cut -d ' ' -f1)
LINUX_ARM64_SHA=$(sha256sum pops-linux-arm64 | cut -d ' ' -f1)
echo "darwin_amd64_sha=${DARWIN_AMD64_SHA}" >> $GITHUB_ENV
echo "darwin_arm64_sha=${DARWIN_ARM64_SHA}" >> $GITHUB_ENV
echo "linux_amd64_sha=${LINUX_AMD64_SHA}" >> $GITHUB_ENV
echo "linux_arm64_sha=${LINUX_ARM64_SHA}" >> $GITHUB_ENV
- name: Checkout Homebrew Tap
uses: actions/checkout@v4
with:
repository: prompt-ops/homebrew-tap
token: ${{ secrets.POPS_GITHUB_OPS_PAT }}
ref: main
path: homebrew-tap
- name: Update formula
run: |
VERSION=${{ env.TAG_NAME }}
DARWIN_AMD64_SHA=${{ env.darwin_amd64_sha }}
DARWIN_ARM64_SHA=${{ env.darwin_arm64_sha }}
LINUX_AMD64_SHA=${{ env.linux_amd64_sha }}
LINUX_ARM64_SHA=${{ env.linux_arm64_sha }}
cd homebrew-tap
FORMULA_FILE="Formula/pops.rb"
# Use sed to replace version, URLs, and SHAs in the Ruby formula
sed -i.bak "s|^ version \".*\"| version \"${VERSION}\"|" $FORMULA_FILE
# Darwin Intel
sed -i.bak "s|^ url \"https://github.com/prompt-ops/pops/releases/download/.*pops-darwin-amd64\"| url \"https://github.com/prompt-ops/pops/releases/download/${VERSION}/pops-darwin-amd64\"|" $FORMULA_FILE
sed -i.bak "s|^ sha256 \".*\"| sha256 \"${DARWIN_AMD64_SHA}\"|" $FORMULA_FILE
# Darwin ARM
sed -i.bak "s|^ url \"https://github.com/prompt-ops/pops/releases/download/.*pops-darwin-arm64\"| url \"https://github.com/prompt-ops/pops/releases/download/${VERSION}/pops-darwin-arm64\"|" $FORMULA_FILE
sed -i.bak "s|^ sha256 \".*\"| sha256 \"${DARWIN_ARM64_SHA}\"|" $FORMULA_FILE
# Linux Intel
sed -i.bak "s|^ url \"https://github.com/prompt-ops/pops/releases/download/.*pops-linux-amd64\"| url \"https://github.com/prompt-ops/pops/releases/download/${VERSION}/pops-linux-amd64\"|" $FORMULA_FILE
sed -i.bak "s|^ sha256 \".*\"| sha256 \"${LINUX_AMD64_SHA}\"|" $FORMULA_FILE
# Linux ARM
sed -i.bak "s|^ url \"https://github.com/prompt-ops/pops/releases/download/.*pops-linux-arm64\"| url \"https://github.com/prompt-ops/pops/releases/download/${VERSION}/pops-linux-arm64\"|" $FORMULA_FILE
sed -i.bak "s|^ sha256 \".*\"| sha256 \"${LINUX_ARM64_SHA}\"|" $FORMULA_FILE
# Remove backup files
rm -f $FORMULA_FILE.bak
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.POPS_GITHUB_OPS_PAT }}
path: "homebrew-tap"
committer: pops-ci-bot <pops-ci-bot@users.noreply.github.com>
author: pops-ci-bot <pops-ci-bot@users.noreply.github.com>
signoff: true
commit-message: "chore: Update pops formula to ${{ env.TAG_NAME }}"
title: "Update pops formula to ${{ env.TAG_NAME }}"
body: "This PR was automatically created by GitHub Actions to bump pops to ${{ env.TAG_NAME }}."
base: main
branch: update-pops-${{ env.TAG_NAME }}
delete-branch: true