-
-
Notifications
You must be signed in to change notification settings - Fork 0
206 lines (171 loc) · 6.67 KB
/
release.yml
File metadata and controls
206 lines (171 loc) · 6.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: Releaser
on:
push:
tags:
- 'v*'
permissions:
contents: write
packages: write
id-token: write
jobs:
npm:
name: npm
runs-on: ubuntu-latest
outputs:
version: ${{ env.VERSION }}
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Use Cached node_modules
uses: actions/cache@v5
with:
path: node_modules
key: node-modules-${{ hashFiles('**/bun.lock') }}
restore-keys: |
node-modules-
- name: Install Dependencies
run: bun install
- name: Publish Framework
run: ./storage/framework/scripts/publish
env:
BUN_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Publish Dummy Libraries
run: bun --filter='./storage/framework' run publish:dummy-libs
env:
BUN_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Publish VS Code Extension
run: |
cd storage/framework/defaults/ide/vscode
bun install
bunx --bun vsce publish
cd ../../../../
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
- name: Extract tag version
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Create GitHub Release
uses: stacksjs/action-releaser@v1.2.7
with:
files: |
storage/framework/core/buddy/bin/buddy-linux-x64.zip
storage/framework/core/buddy/bin/buddy-linux-arm64.zip
storage/framework/core/buddy/bin/buddy-windows-x64.zip
storage/framework/core/buddy/bin/buddy-darwin-x64.zip
storage/framework/core/buddy/bin/buddy-darwin-arm64.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
homebrew:
needs: npm
runs-on: macos-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Debug Tag
run: |
echo "Tag: ${GITHUB_REF#refs/tags/}"
echo "Version from previous job: ${{ needs.release.outputs.version }}"
- name: Generate GitHub App Token
id: generate-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- name: Setup GitHub CLI with PAT
run: |
echo "${{ secrets.GH_PAT }}" | gh auth login --with-token
- name: Ensure Homebrew Tap Repository Exists
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
run: |
if ! gh repo view stacksjs/homebrew-tap &>/dev/null; then
echo "Creating homebrew-tap repository..."
gh repo create stacksjs/homebrew-tap --public --description "Homebrew tap for Stacks packages"
else
echo "homebrew-tap repository already exists"
fi
- name: Authenticate GitHub CLI with App Token
run: echo "${{ steps.generate-token.outputs.token }}" | gh auth login --with-token
- name: Wait for Release Assets
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "Waiting for release assets to be available..."
# Wait for assets to be available (max 10 minutes)
TIMEOUT=600
START_TIME=$(date +%s)
while [ $(( $(date +%s) - START_TIME )) -lt $TIMEOUT ]; do
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://github.com/stacksjs/stacks/releases/download/$VERSION/buddy-darwin-arm64)
echo "HTTP response code: $HTTP_CODE"
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "302" ]; then
echo "Assets are available!"
break
fi
echo "Assets not ready yet, waiting 10 seconds..."
sleep 10
done
if [ $(( $(date +%s) - START_TIME )) -ge $TIMEOUT ]; then
echo "Timed out waiting for assets, proceeding anyway..."
fi
# Force continue even if we couldn't detect the file
# Sometimes GitHub's API can be inconsistent
echo "Continuing with asset download..."
- name: Download Binaries Directly
run: |
VERSION=${GITHUB_REF#refs/tags/}
mkdir -p .github/temp
cd .github/temp
# Try direct download with retries
download_with_retry() {
local url=$1
local output=$2
local max_retries=5
local retry=0
while [ $retry -lt $max_retries ]; do
echo "Downloading $url (attempt $(($retry + 1))/$max_retries)"
if curl -L -s -f "$url" -o "$output"; then
echo "Downloaded $output successfully"
return 0
fi
echo "Download failed, retrying in 5 seconds..."
retry=$((retry + 1))
sleep 5
done
echo "Failed to download $url after $max_retries attempts"
return 1
}
download_with_retry "https://github.com/stacksjs/stacks/releases/download/$VERSION/buddy-darwin-arm64" "buddy-darwin-arm64"
download_with_retry "https://github.com/stacksjs/stacks/releases/download/$VERSION/buddy-darwin-x64" "buddy-darwin-x64"
download_with_retry "https://github.com/stacksjs/stacks/releases/download/$VERSION/buddy-linux-arm64" "buddy-linux-arm64"
download_with_retry "https://github.com/stacksjs/stacks/releases/download/$VERSION/buddy-linux-x64" "buddy-linux-x64"
cd ../..
- name: Update Homebrew Formula
run: |
VERSION=${GITHUB_REF#refs/tags/}
bash .github/scripts/update-homebrew-formula.sh $VERSION
- name: Push to Homebrew Tap Repository
run: |
# Clone the tap repo using GitHub App token
git clone https://x-access-token:${{ steps.generate-token.outputs.token }}@github.com/stacksjs/homebrew-tap.git
# Set up Git config
cd homebrew-tap
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Copy the formula to the tap repo
mkdir -p Formula
cp ../.github/homebrew/stacks.rb Formula/
# Check if there are changes to commit
if git status --porcelain | grep -q .; then
# Push the changes to the tap repo
git add Formula/stacks.rb
git commit -m "chore: update stacks formula to ${GITHUB_REF#refs/tags/}"
git push
echo "Successfully updated homebrew formula!"
else
echo "No changes to commit"
fi