Skip to content

Commit 126e4d5

Browse files
committed
Update release.yml
1 parent 4893ff7 commit 126e4d5

File tree

1 file changed

+45
-7
lines changed

1 file changed

+45
-7
lines changed

.github/workflows/release.yml

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ jobs:
3333
echo "$NOTES" >> $GITHUB_ENV
3434
echo "EOF" >> $GITHUB_ENV
3535
36-
- name: Update formula version
36+
- name: Create formulas for this version
3737
run: |
38-
sed -i 's/version "[0-9]\+\.[0-9]\+\.[0-9]\+"/version "'$VERSION'"/' Formula/tctl.rb
39-
4038
# Get new checksums for the binaries
4139
INTEL_URL="https://binaries.dl.tetrate.io/public/raw/versions/darwin-amd64-$VERSION/tctl"
4240
ARM_URL="https://binaries.dl.tetrate.io/public/raw/versions/darwin-arm64-$VERSION/tctl"
@@ -48,15 +46,50 @@ jobs:
4846
INTEL_SHA=$(shasum -a 256 /tmp/tctl-checksums/tctl-intel | cut -d ' ' -f 1)
4947
ARM_SHA=$(shasum -a 256 /tmp/tctl-checksums/tctl-arm | cut -d ' ' -f 1)
5048
51-
# Update the SHA256 checksums in the formula
52-
sed -i 's/sha256 "[a-f0-9]\{64\}" # Intel/sha256 "'$INTEL_SHA'" # Intel/' Formula/tctl.rb
53-
sed -i 's/sha256 "[a-f0-9]\{64\}" # ARM/sha256 "'$ARM_SHA'" # ARM/' Formula/tctl.rb
49+
# 1. Update the main formula
50+
sed -i 's/version "[0-9]\+\.[0-9]\+\.[0-9]\+"/version "'$VERSION'"/g' Formula/tctl.rb
51+
sed -i 's/sha256 "[a-f0-9]\{64\}" # Intel/sha256 "'$INTEL_SHA'" # Intel/g' Formula/tctl.rb
52+
sed -i 's/sha256 "[a-f0-9]\{64\}" # ARM/sha256 "'$ARM_SHA'" # ARM/g' Formula/tctl.rb
53+
54+
# 2. Create versioned formula
55+
mkdir -p Formula/Versions
56+
57+
# Format version for class name (remove dots)
58+
VERSION_NO_DOTS=$(echo $VERSION | tr -d '.')
59+
60+
cat > Formula/Versions/tctl@$VERSION.rb << EOF
61+
class Tctl${VERSION_NO_DOTS} < Formula
62+
desc "Tetrate Service Bridge Command Line Interface ${VERSION}"
63+
homepage "https://docs.tetrate.io/service-bridge/reference/cli/guide/"
64+
version "${VERSION}"
65+
license "Commercial"
66+
conflicts_with "tctl", because: "Provides the same binary"
67+
68+
if Hardware::CPU.intel?
69+
url "https://binaries.dl.tetrate.io/public/raw/versions/darwin-amd64-${VERSION}/tctl"
70+
sha256 "${INTEL_SHA}" # Intel
71+
else
72+
url "https://binaries.dl.tetrate.io/public/raw/versions/darwin-arm64-${VERSION}/tctl"
73+
sha256 "${ARM_SHA}" # ARM
74+
end
75+
76+
def install
77+
bin.install "tctl" => "tctl-${VERSION}"
78+
bin.install_symlink "tctl-${VERSION}" => "tctl@${VERSION}"
79+
end
80+
81+
test do
82+
assert_match version.to.s, shell_output("\#{bin}/tctl@${VERSION} version 2>&1")
83+
end
84+
end
85+
EOF
5486
5587
- name: Commit formula updates
5688
run: |
5789
git config --local user.email "action@github.com"
5890
git config --local user.name "GitHub Action"
59-
git commit -am "Update formula for version $VERSION"
91+
git add Formula/tctl.rb Formula/Versions/tctl@$VERSION.rb
92+
git commit -m "Update formulas for version $VERSION"
6093
git push
6194
6295
- name: Create Release
@@ -67,8 +100,13 @@ jobs:
67100
body: |
68101
To install this release:
69102
```
103+
# Latest version
70104
brew tap smarunich/tctl
71105
brew install smarunich/tctl/tctl
106+
107+
# This specific version
108+
brew tap smarunich/tctl
109+
brew install smarunich/tctl/tctl@${{ env.VERSION }}
72110
```
73111
74112
${{ env.NOTES }}

0 commit comments

Comments
 (0)