-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrelease.sh
More file actions
58 lines (45 loc) · 1.39 KB
/
Copy pathrelease.sh
File metadata and controls
58 lines (45 loc) · 1.39 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
#!/bin/bash
set -e
# Required env vars:
# ZIP_PATH, GIT_TOKEN, BUILD_TIME
# GitHub automatically provides: GITHUB_REPOSITORY
TAG_NAME="${TARGET_DEVICE}-$(date +%s)"
RELEASE_NAME="Ocean Tools Port ${TARGET_DEVICE} to ${STOCK_DEVICE}"
echo "Uploading to GoFile..."
GOFILE_LINK=$(sudo bash upload.sh "$ZIP_PATH")
echo "🌎 File uploaded here: $GOFILE_LINK"
# File info
FILE_SIZE=$(du -h "$ZIP_PATH" | cut -f1)
MD5_SUM=$(md5sum "$ZIP_PATH" | awk '{print $1}')
# Release body
RELEASE_BODY="#### 📦 Download:
$GOFILE_LINK
#### 📊 File Info:
• Size: $FILE_SIZE
• MD5: $MD5_SUM
• Build Time: $BUILD_TIME
#### 📱 Rom Device Info:
• STOCK_DEVICE: $STOCK_DEVICE
• TARGET_DEVICE: $TARGET_DEVICE
#### ⚙️ Build Options:
• Filesystem: $OUTPUT_FILESYSTEM
• Compressed IMG: $COMPRESS_IMG_TO_XZ
"
# Convert to JSON-safe string
JSON_BODY=$(printf '%s' "$RELEASE_BODY" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))')
# Create release
if [ -n "$GIT_TOKEN" ]; then
echo "Creating GitHub release..."
curl -X POST "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases" \
-H "Authorization: token $GIT_TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"tag_name\": \"$TAG_NAME\",
\"name\": \"$RELEASE_NAME\",
\"body\": $JSON_BODY,
\"draft\": false,
\"prerelease\": false
}"
else
echo "GIT_TOKEN not found. Skipping release."
fi