-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (86 loc) · 4.19 KB
/
update-formula.yml
File metadata and controls
104 lines (86 loc) · 4.19 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
100
101
102
103
104
name: "Update Formula"
on:
workflow_dispatch:
inputs:
version:
description: 'Version to update to (e.g., v1.2.5)'
required: true
type: string
jobs:
update-formula:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Calculate new hashes
id: hashes
run: |
# Get version from workflow dispatch input
VERSION="${{ github.event.inputs.version }}"
BASE_URL="https://github.com/interline-io/transitland-lib/releases/download/${VERSION}"
# Create temporary directory
TEMP_DIR=$(mktemp -d)
cd "$TEMP_DIR"
# Download and calculate hashes
echo "Downloading files for version ${VERSION}..."
# macOS Intel
curl -L "${BASE_URL}/transitland-macos-intel" -o transitland-macos-intel
MACOS_INTEL_HASH=$(sha256sum transitland-macos-intel | cut -d' ' -f1)
echo "macos_intel_hash=${MACOS_INTEL_HASH}" >> $GITHUB_OUTPUT
# macOS Apple Silicon
curl -L "${BASE_URL}/transitland-macos-apple" -o transitland-macos-apple
MACOS_APPLE_HASH=$(sha256sum transitland-macos-apple | cut -d' ' -f1)
echo "macos_apple_hash=${MACOS_APPLE_HASH}" >> $GITHUB_OUTPUT
# Linux
curl -L "${BASE_URL}/transitland-linux" -o transitland-linux
LINUX_HASH=$(sha256sum transitland-linux | cut -d' ' -f1)
echo "linux_hash=${LINUX_HASH}" >> $GITHUB_OUTPUT
# Store version for later use
echo "version=${VERSION}" >> $GITHUB_OUTPUT
# Clean up
cd - > /dev/null
rm -rf "$TEMP_DIR"
echo "Calculated hashes:"
echo "Version: ${VERSION}"
echo "macOS Intel: ${MACOS_INTEL_HASH}"
echo "macOS Apple: ${MACOS_APPLE_HASH}"
echo "Linux: ${LINUX_HASH}"
- name: Update Homebrew formula
run: |
VERSION="${{ steps.hashes.outputs.version }}"
FORMULA_FILE="transitland-lib.rb"
# Update version
sed -i "s/version \"v[0-9.]*\"/version \"${VERSION}\"/" "$FORMULA_FILE"
# Update hashes
sed -i "s/sha256 \"[a-f0-9]\{64\}\" # macOS Intel/sha256 \"${{ steps.hashes.outputs.macos_intel_hash }}\" # macOS Intel/" "$FORMULA_FILE"
sed -i "s/sha256 \"[a-f0-9]\{64\}\" # macOS Apple/sha256 \"${{ steps.hashes.outputs.macos_apple_hash }}\" # macOS Apple/" "$FORMULA_FILE"
sed -i "s/sha256 \"[a-f0-9]\{64\}\" # Linux/sha256 \"${{ steps.hashes.outputs.linux_hash }}\" # Linux/" "$FORMULA_FILE"
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
path: .
branch: update-formula-${{ steps.hashes.outputs.version }}
title: "Update transitland-lib to ${{ steps.hashes.outputs.version }}"
body: |
This PR updates the Homebrew formula for transitland-lib to version ${{ steps.hashes.outputs.version }}.
## Changes
- Updated version to ${{ steps.hashes.outputs.version }}
- Updated SHA256 hashes for all platform binaries:
- macOS Intel: `${{ steps.hashes.outputs.macos_intel_hash }}`
- macOS Apple Silicon: `${{ steps.hashes.outputs.macos_apple_hash }}`
- Linux: `${{ steps.hashes.outputs.linux_hash }}`
## Release
https://github.com/interline-io/transitland-lib/releases/tag/${{ steps.hashes.outputs.version }}
---
*Auto-generated by GitHub Actions*
commit-message: "Update transitland-lib to ${{ steps.hashes.outputs.version }}"
delete-branch: true
- name: Log PR creation results
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
echo "✅ Pull Request created successfully!"
echo "PR Number: ${{ steps.cpr.outputs.pull-request-number }}"
echo "PR URL: ${{ steps.cpr.outputs.pull-request-url }}"
echo "Branch: ${{ steps.cpr.outputs.pull-request-branch }}"