-
Notifications
You must be signed in to change notification settings - Fork 2
97 lines (77 loc) · 3.67 KB
/
update_homebrew_formula.yml
File metadata and controls
97 lines (77 loc) · 3.67 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
name: Update Homebrew Formula
on:
workflow_dispatch:
inputs:
release_tag:
description: 'Release tag (e.g. v0.6.3)'
required: false
workflow_run:
workflows: ["Release"]
types:
- completed
permissions:
contents: write
jobs:
update-homebrew:
name: Update Homebrew Formula
runs-on: macos-latest
environment: packaging
if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success'
steps:
- name: Checkout this repository
uses: actions/checkout@v4
- name: Install gnu-sed
run: brew install gnu-sed
- name: Determine version tag
id: get_version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.release_tag }}" ]; then
echo "VERSION=${{ github.event.inputs.release_tag }}" >> $GITHUB_ENV
else
TAG=$(gh api repos/${{ github.repository }}/releases/latest --jq .tag_name)
echo "VERSION=$TAG" >> $GITHUB_ENV
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clone Homebrew tap repository
run: |
git clone https://x-access-token:${{ secrets.HOMEBREW_TAP_TOKEN }}@github.com/lablup/homebrew-tap.git
cd homebrew-tap
git config user.name "GitHub Action"
git config user.email "actions@github.com"
- name: Download release artifacts and calculate SHA256
run: |
cd homebrew-tap
RAW_VERSION="${{ env.VERSION }}"
VERSION="${RAW_VERSION#v}" # Remove leading 'v'
echo "VERSION_NO_V=$VERSION" >> $GITHUB_ENV # Export version without 'v' to GitHub env
MAC_URL="https://github.com/lablup/bssh/releases/download/v${VERSION}/bssh-macos-aarch64.zip"
LINUX_ARM_URL="https://github.com/lablup/bssh/releases/download/v${VERSION}/bssh-linux-aarch64.tar.gz"
LINUX_X86_URL="https://github.com/lablup/bssh/releases/download/v${VERSION}/bssh-linux-x86_64.tar.gz"
mkdir -p tmp
curl -Ls "$MAC_URL" -o tmp/mac.zip
curl -Ls "$LINUX_ARM_URL" -o tmp/linux-arm.tar.gz
curl -Ls "$LINUX_X86_URL" -o tmp/linux-x86.tar.gz
echo "mac_url=$MAC_URL" >> $GITHUB_ENV
echo "linux_arm_url=$LINUX_ARM_URL" >> $GITHUB_ENV
echo "linux_x86_url=$LINUX_X86_URL" >> $GITHUB_ENV
echo "mac_sha=$(shasum -a 256 tmp/mac.zip | awk '{print $1}')" >> $GITHUB_ENV
echo "linux_arm_sha=$(shasum -a 256 tmp/linux-arm.tar.gz | awk '{print $1}')" >> $GITHUB_ENV
echo "linux_x86_sha=$(shasum -a 256 tmp/linux-x86.tar.gz | awk '{print $1}')" >> $GITHUB_ENV
- name: Update formula
run: |
cd homebrew-tap
VERSION="${{ env.VERSION_NO_V }}" # Use version without 'v'
gsed -i "s/^ version .*/ version \"${VERSION}\"/" Formula/bssh.rb
gsed -i "s|https://github.com/.*/bssh-macos-aarch64.zip|${mac_url}|" Formula/bssh.rb
gsed -i "/macos-aarch64.zip\"/!b;n;c\ sha256 \"${mac_sha}\"" Formula/bssh.rb
gsed -i "s|https://github.com/.*/bssh-linux-aarch64.tar.gz|${linux_arm_url}|" Formula/bssh.rb
gsed -i "/linux-aarch64.tar.gz\"/!b;n;c\ sha256 \"${linux_arm_sha}\"" Formula/bssh.rb
gsed -i "s|https://github.com/.*/bssh-linux-x86_64.tar.gz|${linux_x86_url}|" Formula/bssh.rb
gsed -i "/linux-x86_64.tar.gz\"/!b;n;c\ sha256 \"${linux_x86_sha}\"" Formula/bssh.rb
- name: Commit and push changes to tap
run: |
cd homebrew-tap
git add Formula/bssh.rb
git commit -m "bump: bssh to v${{ env.VERSION_NO_V }}"
git push origin main