-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (102 loc) · 3.47 KB
/
Copy pathrelease.yml
File metadata and controls
119 lines (102 loc) · 3.47 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build:
name: Build Release
runs-on: macos-latest
outputs:
sha256: ${{ steps.sha.outputs.sha256 }}
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Get version
id: version
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Build
run: make
- name: Create tarball
run: |
VERSION=${{ steps.version.outputs.version }}
mkdir -p release/mac-free-${VERSION}
cp bin/free release/mac-free-${VERSION}/
cp README.md LICENSE release/mac-free-${VERSION}/
cd release && tar -czvf mac-free-${VERSION}-darwin-arm64.tar.gz mac-free-${VERSION}
- name: Calculate SHA256
id: sha
run: |
VERSION=${{ steps.version.outputs.version }}
SHA256=$(shasum -a 256 release/mac-free-${VERSION}-darwin-arm64.tar.gz | cut -d ' ' -f 1)
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
echo "SHA256: $SHA256"
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: release-tarball
path: release/*.tar.gz
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Download artifact
uses: actions/download-artifact@v8
with:
name: release-tarball
path: ./release
- name: Create Release
uses: softprops/action-gh-release@v3
with:
files: release/*.tar.gz
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
homebrew:
name: Update Homebrew Tap
runs-on: ubuntu-latest
needs: [build, release]
steps:
- name: Checkout homebrew-tap
uses: actions/checkout@v7
with:
repository: techquestsdev/homebrew-tap
token: ${{ secrets.REPO_READ }}
- name: Create/Update Homebrew formula
env:
VERSION: ${{ needs.build.outputs.version }}
SHA256: ${{ needs.build.outputs.sha256 }}
run: |
cat > mac-free.rb << 'EOF'
class MacFree < Formula
desc "A 'free' command replacement for macOS - displays memory usage like Linux free"
homepage "https://github.com/techquestsdev/mac-free"
url "https://github.com/techquestsdev/mac-free/releases/download/${VERSION}/mac-free-${VERSION}-darwin-arm64.tar.gz"
sha256 "${SHA256}"
license "MIT"
def install
bin.install "free"
end
test do
system "#{bin}/free", "-V"
end
end
EOF
# Replace variables in the formula
sed -i "s|\${VERSION}|${VERSION}|g" mac-free.rb
sed -i "s|\${SHA256}|${SHA256}|g" mac-free.rb
cat mac-free.rb
- name: Commit and push formula
env:
HOMEBREW_TOKEN: ${{ secrets.HOMEBREW_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git remote set-url origin https://x-access-token:${HOMEBREW_TOKEN}@github.com/techquestsdev/homebrew-tap.git
git add mac-free.rb
git commit -m "Update mac-free to ${{ needs.build.outputs.version }}" || echo "No changes to commit"
git push