4646
4747 - name : Create GitHub Release
4848 id : create_release
49- uses : stacksjs/action-releaser@v1.0 .0
49+ uses : stacksjs/action-releaser@v1.1 .0
5050 with :
5151 files : |
5252 ./packages/rpx/bin/rpx-linux-x64.zip
@@ -66,125 +66,8 @@ jobs:
6666 sha256sum ./packages/rpx/bin/rpx-darwin-arm64.zip > checksums/darwin-arm64.sha256
6767
6868 - name : Upload Checksums Artifact
69- uses : actions/upload-artifact@v3
69+ uses : actions/upload-artifact@v4
7070 with :
7171 name : checksums
7272 path : checksums/
7373 retention-days : 1
74-
75- homebrew :
76- needs : npm
77- runs-on : macos-latest
78- steps :
79- - name : Checkout Repository
80- uses : actions/checkout@v4
81- with :
82- fetch-depth : 0
83-
84- - name : Setup Bun
85- uses : oven-sh/setup-bun@v2
86-
87- - name : Generate GitHub App Token
88- id : generate-token
89- uses : tibdex/github-app-token@v2
90- with :
91- app_id : ${{ secrets.GH_APP_ID }}
92- private_key : ${{ secrets.GH_APP_PRIVATE_KEY }}
93-
94- - name : Setup GitHub CLI
95- run : |
96- echo "${{ steps.generate-token.outputs.token }}" | gh auth login --with-token
97-
98- - name : Ensure Homebrew Tap Repository Exists
99- env :
100- GH_TOKEN : ${{ steps.generate-token.outputs.token }}
101- run : |
102- if ! gh repo view stacksjs/homebrew-tap &>/dev/null; then
103- echo "Creating homebrew-tap repository..."
104- gh repo create stacksjs/homebrew-tap --public --description "Homebrew tap for Stacks packages"
105- else
106- echo "homebrew-tap repository already exists"
107- fi
108-
109- - name : Wait for Release Assets
110- run : |
111- VERSION=${GITHUB_REF#refs/tags/}
112- echo "Waiting for release assets to be available..."
113-
114- # Wait for assets to be available (max 10 minutes)
115- TIMEOUT=600
116- START_TIME=$(date +%s)
117-
118- while [ $(( $(date +%s) - START_TIME )) -lt $TIMEOUT ]; do
119- HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://github.com/stacksjs/rpx/releases/download/$VERSION/rpx-darwin-arm64.zip)
120- echo "HTTP response code: $HTTP_CODE"
121-
122- if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "302" ]; then
123- echo "Assets are available!"
124- break
125- fi
126-
127- echo "Assets not ready yet, waiting 10 seconds..."
128- sleep 10
129- done
130-
131- if [ $(( $(date +%s) - START_TIME )) -ge $TIMEOUT ]; then
132- echo "Timed out waiting for assets, proceeding anyway..."
133- fi
134-
135- - name : Download Artifacts
136- uses : actions/download-artifact@v3
137- with :
138- name : checksums
139- path : checksums
140-
141- - name : Update Homebrew Formula
142- run : |
143- VERSION=${GITHUB_REF#refs/tags/v}
144- LINUX_X64_SHA=$(cat checksums/linux-x64.sha256 | awk '{print $1}')
145- LINUX_ARM64_SHA=$(cat checksums/linux-arm64.sha256 | awk '{print $1}')
146- DARWIN_X64_SHA=$(cat checksums/darwin-x64.sha256 | awk '{print $1}')
147- DARWIN_ARM64_SHA=$(cat checksums/darwin-arm64.sha256 | awk '{print $1}')
148-
149- # Check if tap/rpx.rb exists
150- if [ ! -f "tap/rpx.rb" ]; then
151- echo "Error: tap/rpx.rb file is missing"
152- exit 1
153- fi
154-
155- # Update checksums in the formula
156- sed -i '' "s|sha256 \".*\" # darwin-arm64|sha256 \"${DARWIN_ARM64_SHA}\" # darwin-arm64|g" tap/rpx.rb
157- sed -i '' "s|sha256 \".*\" # darwin-x64|sha256 \"${DARWIN_X64_SHA}\" # darwin-x64|g" tap/rpx.rb
158- sed -i '' "s|sha256 \".*\" # linux-arm64|sha256 \"${LINUX_ARM64_SHA}\" # linux-arm64|g" tap/rpx.rb
159- sed -i '' "s|sha256 \".*\" # linux-x64|sha256 \"${LINUX_X64_SHA}\" # linux-x64|g" tap/rpx.rb
160-
161- # Verify that the version in tap/rpx.rb matches our release version
162- if ! grep -q "version \"${VERSION}\"" tap/rpx.rb; then
163- echo "Warning: Version mismatch in tap/rpx.rb. Setting to ${VERSION}"
164- sed -i '' "s|version \".*\"|version \"${VERSION}\"|g" tap/rpx.rb
165- fi
166-
167- - name : Push to Homebrew Tap Repository
168- run : |
169- # Clone the tap repo using GitHub App token
170- git clone https://x-access-token:${{ steps.generate-token.outputs.token }}@github.com/stacksjs/homebrew-tap.git
171-
172- # Set up Git config
173- cd homebrew-tap
174- git config user.name "github-actions[bot]"
175- git config user.email "github-actions[bot]@users.noreply.github.com"
176-
177- # Copy the formula to the tap repo
178- mkdir -p Formula
179- cp ../tap/rpx.rb Formula/
180-
181- # Check if there are changes to commit
182- if git status --porcelain | grep -q .; then
183- # Push the changes to the tap repo
184- git add Formula/rpx.rb
185- git commit -m "chore: update rpx formula to ${GITHUB_REF#refs/tags/}"
186- git push
187- echo "Successfully updated homebrew formula!"
188- else
189- echo "No changes to commit"
190- fi
0 commit comments