Skip to content

Commit 96fa647

Browse files
committed
chore: wip
1 parent 0799e82 commit 96fa647

File tree

4 files changed

+86
-51
lines changed

4 files changed

+86
-51
lines changed

.github/homebrew/README.homebrew.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Stacks is available via Homebrew for macOS and Linux users, making installation
77
The fastest way to install Stacks is with our one-line installation script:
88

99
```bash
10-
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/stacksjs/stacks/main/.github/homebrew/install.sh)"
10+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/stacksjs/stacks/main/.github/scripts/install.sh)"
1111
```
1212

1313
This script:

.github/scripts/create-github-app.sh

Lines changed: 84 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,40 @@ echo "GitHub App Creation Helper for Stacks Homebrew Automation"
66
echo "================================================================"
77
echo
88

9+
# Try to load from .env file if it exists
10+
if [ -f ".env" ] || [ -f "../../.env" ]; then
11+
source .env 2>/dev/null || source ../../.env 2>/dev/null
12+
fi
13+
914
if [ -z "$GITHUB_TOKEN" ]; then
10-
echo "Please set the GITHUB_TOKEN environment variable with a personal access token that has"
11-
echo "admin:org and repo permissions."
15+
echo "❌ Error: GITHUB_TOKEN environment variable is not set"
16+
echo
17+
echo "To fix this, you need to:"
18+
echo "1. Create a Personal Access Token (PAT):"
19+
echo " - Go to: https://github.com/settings/tokens/new"
20+
echo " - Click 'Generate new token (classic)'"
21+
echo " - Give it a name like 'Stacks Homebrew Automation'"
22+
echo " - Set expiration (recommended: 90 days)"
23+
echo " - Select these scopes:"
24+
echo " ✓ admin:org (Full control of orgs and teams)"
25+
echo " ✓ repo (Full control of private repositories)"
26+
echo " - Click 'Generate token' and copy the token"
1227
echo
13-
echo "Example: GITHUB_TOKEN=your_token_here .github/scripts/create-github-app.sh"
28+
echo "2. Set the token in one of these ways:"
29+
echo " a. Export it directly:"
30+
echo " export GITHUB_TOKEN=your_token_here"
31+
echo " b. Or add it to your .env file:"
32+
echo " echo 'GITHUB_TOKEN=your_token_here' >> .env"
33+
echo
34+
echo "3. Run this script again:"
35+
echo " ./github/scripts/create-github-app.sh"
36+
echo
37+
echo "Note: The token will only be shown once. Make sure to copy it!"
38+
echo " You can revoke it anytime at: https://github.com/settings/tokens"
1439
exit 1
1540
fi
1641

17-
echo "1. Going to create a GitHub App via GitHub CLI..."
42+
echo "1. Going to help you create a GitHub App..."
1843

1944
# Check if gh CLI is installed
2045
if ! command -v gh &> /dev/null; then
@@ -27,75 +52,85 @@ fi
2752
# Authenticate with GitHub CLI if needed
2853
gh auth status || (echo "Authenticating with GitHub CLI..." && echo "$GITHUB_TOKEN" | gh auth login --with-token)
2954

30-
# Create manifest file for GitHub App
31-
cat > app-manifest.json << EOL
32-
{
33-
"name": "Stacks Homebrew Automation",
34-
"url": "https://github.com/stacksjs/stacks",
35-
"hook_attributes": {
36-
"active": false
37-
},
38-
"redirect_url": "https://github.com/stacksjs/stacks",
39-
"public": false,
40-
"default_permissions": {
41-
"administration": "write",
42-
"contents": "write",
43-
"metadata": "read"
44-
},
45-
"default_events": []
46-
}
47-
EOL
48-
49-
echo "2. Please complete the GitHub App creation process in your browser:"
50-
echo " - You'll need to follow the link that appears below"
51-
echo " - Click 'Create GitHub App' on the page that opens"
52-
echo " - On the next page, note your App ID for the next step"
53-
echo " - Generate a private key and download the .pem file"
55+
echo
56+
echo "2. Opening GitHub App creation page in your browser..."
57+
echo " IMPORTANT: You need to create this app in the stacksjs organization!"
58+
echo " - Go to: https://github.com/organizations/stacksjs/settings/apps/new"
59+
echo " - If that doesn't work, go to github.com/stacksjs, click Settings → Developer settings → GitHub Apps → New GitHub App"
60+
echo
61+
echo " Please fill in the following details:"
62+
echo " - GitHub App name: Stacks Homebrew Automation"
63+
echo " - Homepage URL: https://github.com/stacksjs/stacks"
64+
echo " - Callback URL: (leave blank)"
65+
echo " - Description: App for managing Homebrew tap for Stacks"
66+
echo
67+
echo " - Webhook section:"
68+
echo " ✗ Active: UNCHECK this box (this makes the URL and secret optional)"
69+
echo " (With Active unchecked, you can ignore the Webhook URL and Secret fields)"
70+
echo
71+
echo " - Under Repository permissions, select:"
72+
echo " ✓ Contents: Read & write"
73+
echo " ✓ Metadata: Read-only"
74+
echo
75+
echo " - Under Organization permissions, select:"
76+
echo " ✓ Administration: Read & write"
77+
echo
78+
echo " - At the bottom, select 'Only on this account' for installation"
5479
echo
5580

56-
echo "3. Opening GitHub App manifest creation flow..."
57-
gh api --method POST /organizations/stacksjs/github-apps/manifests \
58-
--field manifest="$(cat app-manifest.json)" \
59-
--jq '.html_url' | xargs open
81+
# Open the URL in the browser for the stacksjs organization
82+
open "https://github.com/organizations/stacksjs/settings/apps/new" 2>/dev/null || xdg-open "https://github.com/organizations/stacksjs/settings/apps/new" 2>/dev/null || echo "Please open this URL in your browser: https://github.com/organizations/stacksjs/settings/apps/new"
6083

6184
echo
62-
echo "4. After completing the steps above, please enter the App ID: "
85+
echo "3. After clicking 'Create GitHub App':"
86+
echo " a. You'll be redirected to the App settings page"
87+
echo " b. Note your App ID (shown at the top)"
88+
echo " c. Generate a private key by clicking 'Generate a private key'"
89+
echo " d. Save the downloaded .pem file"
90+
echo
91+
92+
echo "4. Please enter the App ID from the settings page: "
6393
read APP_ID
6494

95+
if [ -z "$APP_ID" ]; then
96+
echo "Error: No App ID provided"
97+
exit 1
98+
fi
99+
65100
echo
66-
echo "5. Please paste the path to the downloaded .pem private key file: "
101+
echo "5. Please enter the path to the downloaded .pem private key file: "
67102
read PEM_PATH
68103

69104
if [ ! -f "$PEM_PATH" ]; then
70105
echo "Error: Private key file not found at $PEM_PATH"
71106
exit 1
72107
fi
73108

74-
PRIVATE_KEY=$(cat "$PEM_PATH")
109+
PEM_KEY=$(cat "$PEM_PATH")
110+
111+
echo "6. Successfully registered GitHub App with ID: $APP_ID"
75112

76113
# Create GitHub repository secrets
77-
echo
78-
echo "6. Creating GitHub repository secrets..."
114+
echo "7. Creating GitHub repository secrets..."
79115

80116
# Create secrets in the repository
81117
echo "Creating GH_APP_ID secret..."
82118
gh secret set GH_APP_ID -b"$APP_ID" -R stacksjs/stacks
83119

84120
echo "Creating GH_APP_PRIVATE_KEY secret..."
85-
gh secret set GH_APP_PRIVATE_KEY -b"$PRIVATE_KEY" -R stacksjs/stacks
121+
gh secret set GH_APP_PRIVATE_KEY -b"$PEM_KEY" -R stacksjs/stacks
86122

87123
echo
88-
echo "7. Installation:"
89-
echo " - If you haven't already, install the app to your organization"
90-
echo " - Navigate to the GitHub App page and click 'Install App'"
91-
echo " - Choose 'Only select repositories' and select 'stacksjs/stacks'"
124+
echo "8. Installation:"
125+
echo " - On the App settings page, click 'Install App' in the sidebar"
126+
echo " - You should see the stacksjs organization listed"
127+
echo " - Click 'Install' next to stacksjs"
128+
echo " - On the next page, choose 'All repositories' or 'Only select repositories'"
129+
echo " - If 'Only select repositories', make sure to select 'stacks'"
130+
echo " - Click 'Install'"
92131
echo
93132

94133
echo "Setup completed successfully!"
95-
echo
96-
echo "You can now run your GitHub Actions workflow, which will automatically"
97-
echo "create and manage the homebrew tap repository."
98-
echo "================================================================"
99-
100-
# Clean up
101-
rm -f app-manifest.json
134+
echo "The GitHub App ID is: $APP_ID"
135+
echo "These values have been set as repository secrets."
136+
echo "================================================================"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ We would like to extend our thanks to the following sponsors for funding Stacks
382382

383383
## Credits
384384

385-
- [Laravel](https://laravel.com) _many thanks to their community_
385+
- [Laravel](https://laravel.com) _many thanks to their community_
386386
- [Chris Breuer](https://github.com/chrisbbreuer)
387387
- [All Contributors](../../contributors)
388388

0 commit comments

Comments
 (0)