-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (83 loc) · 3.17 KB
/
bump-packmind-formula.yml
File metadata and controls
99 lines (83 loc) · 3.17 KB
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
name: Bump Packmind CLI formula
on:
repository_dispatch:
types: [packmind-cli-release]
workflow_dispatch:
inputs:
version:
description: "CLI version to bump to (e.g. 0.21.0)"
required: true
jobs:
bump:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "repository_dispatch" ]; then
VERSION="${{ github.event.client_payload.version }}"
else
VERSION="${{ github.event.inputs.version }}"
fi
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "Invalid version format: $VERSION"
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Checkout tap repo
uses: actions/checkout@v4
- name: Check if already up to date
run: |
CURRENT=$(grep 'version "' Formula/packmind-cli.rb | head -1 | sed 's/.*version "//;s/"//')
if [ "$CURRENT" = "${{ steps.version.outputs.version }}" ]; then
echo "Formula already at version ${{ steps.version.outputs.version }}, skipping."
exit 0
fi
- name: Download binaries and compute checksums
id: checksums
run: |
VERSION="${{ steps.version.outputs.version }}"
BASE_URL="https://github.com/PackmindHub/packmind/releases/download/release-cli/${VERSION}"
for PLATFORM in macos-arm64 linux-arm64 linux-x64; do
FILE="packmind-cli-${PLATFORM}-${VERSION}"
curl -sL -o "$FILE" "${BASE_URL}/${FILE}"
SHA=$(sha256sum "$FILE" | awk '{print $1}')
KEY=$(echo "$PLATFORM" | tr '-' '_')
echo "${KEY}=${SHA}" >> "$GITHUB_OUTPUT"
done
- name: Update formula
run: |
VERSION="${{ steps.version.outputs.version }}"
FORMULA="Formula/packmind-cli.rb"
sed -i "s/version \"[^\"]*\"/version \"${VERSION}\"/" "$FORMULA"
# Update sha256 values in order of appearance (macos-arm64, linux-arm64, linux-x64)
python3 -c "
import re, sys
sha_values = [
'${{ steps.checksums.outputs.macos_arm64 }}',
'${{ steps.checksums.outputs.linux_arm64 }}',
'${{ steps.checksums.outputs.linux_x64 }}',
]
with open('$FORMULA', 'r') as f:
content = f.read()
idx = 0
def replace_sha(match):
global idx
new = f'sha256 \"{sha_values[idx]}\"'
idx += 1
return new
content = re.sub(r'sha256 \"[a-f0-9]{64}\"', replace_sha, content)
with open('$FORMULA', 'w') as f:
f.write(content)
"
- name: Verify Ruby syntax
run: ruby -c Formula/packmind-cli.rb
- name: Commit and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/packmind-cli.rb
git commit -m "bump packmind-cli to ${{ steps.version.outputs.version }}"
git push