-
Notifications
You must be signed in to change notification settings - Fork 25
105 lines (90 loc) · 3.92 KB
/
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 Formula
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: 'Release tag to update Homebrew formula (e.g., v1.2.3)'
required: true
default: ''
jobs:
update-homebrew:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract release version
id: extract_version
run: |
if [ "${{ github.event_name }}" == "release" ]; then
TAG="${{ github.event.release.tag_name }}"
VERSION="${TAG#v}"
echo "Using release tag: $TAG"
elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
TAG="${{ github.event.inputs.tag }}"
VERSION="${TAG#v}"
echo "Using workflow_dispatch tag: $TAG"
else
echo "Unsupported event: $GITHUB_EVENT_NAME"
exit 1
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create temporary directory
run: mkdir temp
- name: Download macOS tarball
run: |
wget https://github.com/deggja/netfetch/releases/download/v${{ env.VERSION }}/netfetch_${{ env.VERSION }}_darwin_amd64.tar.gz -O temp/netfetch_darwin_amd64.tar.gz
- name: Calculate macOS SHA256
run: |
SHA=$(sha256sum temp/netfetch_darwin_amd64.tar.gz | awk '{print $1}')
echo "MACOS_SHA256=$SHA" >> $GITHUB_ENV
- name: Download Linux tarball
run: |
wget https://github.com/deggja/netfetch/releases/download/v${{ env.VERSION }}/netfetch_${{ env.VERSION }}_linux_amd64.tar.gz -O temp/netfetch_linux_amd64.tar.gz
- name: Calculate Linux SHA256
run: |
SHA=$(sha256sum temp/netfetch_linux_amd64.tar.gz | awk '{print $1}')
echo "LINUX_SHA256=$SHA" >> $GITHUB_ENV
- name: Update Homebrew Formula
run: |
FORMULA_FILE="formula/netfetch.rb"
sed -i "s|url \".*darwin_amd64\.tar\.gz\"|url \"https://github.com/deggja/netfetch/releases/download/v${{ env.VERSION }}/netfetch_${{ env.VERSION }}_darwin_amd64.tar.gz\"|" $FORMULA_FILE
sed -i "s|sha256 \".*\"|sha256 \"${{ env.MACOS_SHA256 }}\"|" $FORMULA_FILE
sed -i "s|url \".*linux_amd64\.tar\.gz\"|url \"https://github.com/deggja/netfetch/releases/download/v${{ env.VERSION }}/netfetch_${{ env.VERSION }}_linux_amd64.tar.gz\"|" $FORMULA_FILE
sed -i "s|sha256 \".*\"|sha256 \"${{ env.LINUX_SHA256 }}\"|" $FORMULA_FILE
- name: Fetch Latest Changes from Main
run: |
git fetch origin main
git checkout main
git pull origin main
- name: Remove temp directory
run: rm -rf temp
- name: Commit and Push changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: update homebrew formula for v${{ env.VERSION }}"
branch: chore/homebrew-${{ env.VERSION }}
create_branch: true
file_pattern: "formula/netfetch.rb"
commit_user_name: "Netfetch Bot"
commit_author: "Netfetch Bot <[email protected]>"
commit_user_email: "[email protected]"
- name: Create Pull Request Using GitHub CLI
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create \
--title "chore: update homebrew formula for v${{ env.VERSION }}" \
--body "This is an automated pull request. This pull request updates the Homebrew formula to version v${{ env.VERSION }} with the latest binary URLs and checksums." \
--base main \
--head chore/homebrew-${{ env.VERSION }} \
--label homebrew,automated \
--reviewer deggja \