Skip to content

Commit 5587b13

Browse files
committed
Update release workflow and verify assets script for v0.0.5
1 parent 6a662a3 commit 5587b13

File tree

2 files changed

+81
-1
lines changed

2 files changed

+81
-1
lines changed

β€Ž.github/workflows/release.ymlβ€Ž

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,51 @@ jobs:
9898
name: Verify Release Assets
9999
needs: build
100100
runs-on: ubuntu-latest
101+
permissions:
102+
contents: read
103+
packages: read
104+
actions: read
101105
steps:
106+
- name: Check token permissions
107+
run: |
108+
echo "πŸ” Checking GITHUB_TOKEN permissions..."
109+
echo "πŸ“‘ Making API call to: https://api.github.com/user"
110+
111+
# Capture full response for detailed logging
112+
RESPONSE=$(curl -s -w "\nHTTP_STATUS:%{http_code}\n" \
113+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
114+
-H "Accept: application/vnd.github.v3+json" \
115+
-H "User-Agent: dyad-release-workflow" \
116+
https://api.github.com/user)
117+
118+
# Extract status code
119+
HTTP_STATUS=$(echo "$RESPONSE" | grep "HTTP_STATUS:" | cut -d: -f2)
120+
JSON_RESPONSE=$(echo "$RESPONSE" | sed '/HTTP_STATUS:/d')
121+
122+
echo "πŸ“‘ API Response Status: $HTTP_STATUS"
123+
124+
# Log token scopes and permissions from headers (if available)
125+
echo "πŸ”‘ Token scopes: $(curl -s -I \
126+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
127+
-H "Accept: application/vnd.github.v3+json" \
128+
https://api.github.com/user | grep -i "x-oauth-scopes:" | sed 's/.*: //' || echo "Not available")"
129+
130+
echo "πŸ“‹ Accepted permissions: $(curl -s -I \
131+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
132+
-H "Accept: application/vnd.github.v3+json" \
133+
https://api.github.com/user | grep -i "x-accepted-github-permissions:" | sed 's/.*: //' || echo "Not available")"
134+
135+
if [ "$HTTP_STATUS" -eq 200 ]; then
136+
echo "βœ… Token authentication successful"
137+
echo "πŸ‘€ User data:"
138+
echo "$JSON_RESPONSE" | jq '.login // "Not available"'
139+
echo "πŸ“‹ Permissions:"
140+
echo "$JSON_RESPONSE" | jq '.permissions // empty'
141+
else
142+
echo "❌ Token authentication failed with status: $HTTP_STATUS"
143+
echo "πŸ” Response body: $JSON_RESPONSE"
144+
exit 1
145+
fi
102146
- name: Github checkout
103147
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
104148
- name: Use Node.js

β€Žscripts/verify-release-assets.jsβ€Ž

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,36 @@ async function verifyReleaseAssets() {
1818

1919
// GitHub API configuration
2020
const owner = "SFARPak";
21-
const repo = "dyad";
21+
const repo = "AliFullStack";
2222
const token = process.env.GITHUB_TOKEN;
2323

2424
if (!token) {
2525
throw new Error("GITHUB_TOKEN environment variable is required");
2626
}
2727

28+
// Log token permissions for debugging
29+
console.log(`πŸ” Checking token permissions...`);
30+
try {
31+
const userResponse = await fetch("https://api.github.com/user", {
32+
headers: {
33+
Authorization: `token ${token}`,
34+
Accept: "application/vnd.github.v3+json",
35+
"User-Agent": "dyad-release-verifier",
36+
},
37+
});
38+
39+
if (userResponse.ok) {
40+
const userData = await userResponse.json();
41+
console.log(`πŸ‘€ Authenticated as: ${userData.login}`);
42+
console.log(`πŸ”‘ Token scopes:`, userResponse.headers.get("x-oauth-scopes") || "Not available");
43+
console.log(`πŸ“‹ Accepted permissions:`, userResponse.headers.get("x-accepted-github-permissions") || "Not available");
44+
} else {
45+
console.warn(`⚠️ Could not verify token permissions: ${userResponse.status} ${userResponse.statusText}`);
46+
}
47+
} catch (error) {
48+
console.warn(`⚠️ Error checking token permissions: ${error.message}`);
49+
}
50+
2851
// Fetch all releases (including drafts) with retry logic
2952
const tagName = `v${version}`;
3053
const maxRetries = 5;
@@ -48,6 +71,8 @@ async function verifyReleaseAssets() {
4871
});
4972

5073
console.log(`πŸ“‘ API Response Status: ${response.status} ${response.statusText}`);
74+
console.log(`πŸ”‘ Token scopes:`, response.headers.get("x-oauth-scopes") || "Not available");
75+
console.log(`πŸ“‹ Accepted permissions:`, response.headers.get("x-accepted-github-permissions") || "Not available");
5176

5277
if (!response.ok) {
5378
console.error(`❌ GitHub API error details:`);
@@ -73,6 +98,17 @@ async function verifyReleaseAssets() {
7398
console.log(`πŸ“¦ Total releases found: ${allReleases.length}`);
7499
console.log(`πŸ” Available release tags:`, allReleases.map(r => r.tag_name).slice(0, 10));
75100

101+
// Check if release exists at all
102+
const releaseExists = allReleases.some(r => r.tag_name === tagName);
103+
if (!releaseExists) {
104+
console.error(`❌ Release ${tagName} does not exist in the repository!`);
105+
console.error(`πŸ“‹ All available releases:`);
106+
allReleases.forEach(r => {
107+
console.error(` - ${r.tag_name} (${r.draft ? 'DRAFT' : 'PUBLISHED'})`);
108+
});
109+
throw new Error(`Release ${tagName} not found in repository`);
110+
}
111+
76112
release = allReleases.find((r) => r.tag_name === tagName);
77113

78114
if (release) {

0 commit comments

Comments
Β (0)