Repository navigation
203 lines (181 loc) · 9 KB
/
Copy pathmakefile.yml
File metadata and controls
203 lines (181 loc) · 9 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
name: ScribbleOS Automatic Release
on:
push:
branches:
- master
workflow_dispatch:
jobs:
auto-release:
name: Build and Auto-Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Build Dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential nasm gcc-multilib binutils \
xorriso mtools grub-common grub-pc-bin cloc jq
- name: Build Kernel and ISO
id: build_step
run: |
cd x86_64-computers
make clean
make
- name: Create or Update Release
uses: softprops/action-gh-release@v2
with:
tag_name: latest
name: "ScribbleOS Continuous Build"
body: |
Automated build of ScribbleOS for the notebook hardware.
**Commit:** ${{ github.sha }}
files: |
x86_64-computers/scribbleos4.iso
x86_64-computers/scribbleos4.bin
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Statistics
id: stats
if: success()
run: |
BEFORE_SHA="HEAD~1"
CURRENT_SHA="HEAD"
echo '{"files": []}' > stats.json
FILES=$(git diff --name-only $BEFORE_SHA $CURRENT_SHA -- '*.c' '*.h' '*.asm' '*.s' 'Makefile' '*.md' '*.cfg' '*.yml' || echo "")
if [ ! -z "$FILES" ]; then
for filename in $FILES; do
if [ -f "$filename" ]; then
STATS=$(git diff --numstat $BEFORE_SHA $CURRENT_SHA -- "$filename")
RAW_ADDED=$(echo "$STATS" | awk '{print $1}' | grep -E '^[0-9]+$' || echo 0)
RAW_REMOVED=$(echo "$STATS" | awk '{print $2}' | grep -E '^[0-9]+$' || echo 0)
if [ "$RAW_ADDED" -lt "$RAW_REMOVED" ]; then CHANGED=$RAW_ADDED; else CHANGED=$RAW_REMOVED; fi
PURE_ADDED=$((RAW_ADDED - CHANGED))
PURE_REMOVED=$((RAW_REMOVED - CHANGED))
jq --arg f "$filename" --arg a "$PURE_ADDED" --arg r "$PURE_REMOVED" --arg c "$CHANGED" '.files += [{"name": $f, "added": $a, "removed": $r, "changed": $c}]' stats.json > tmp.json && mv tmp.json stats.json
fi
done
fi
- name: Update README with Commit Count
if: always()
shell: python
run: |
import os
# 1. Calculate count
import os
cmd = r"git log --oneline --perl-regexp --author='^((?!github-actions\[bot\]).*)$' | wc -l"
current_count = int(os.popen(cmd).read().strip())
total_count = current_count + 467
# 2. Update the README file
with open('README.md', 'r') as f:
content = f.read()
prefix = "<!--COMMIT_COUNT-->"
suffix = "<!--/COMMIT_COUNT-->"
if prefix in content and suffix in content:
parts = content.split(prefix)
main_body = parts[1].split(suffix)
new_content = parts[0] + prefix + str(total_count) + suffix + main_body[1]
with open('README.md', 'w') as f:
f.write(new_content)
# 3. Handle Git commands from within Python to ensure they run
status = os.popen('git status -s').read()
if "README.md" in status:
os.system('git config user.name "github-actions[bot]"')
os.system('git config user.email "github-actions[bot]@users.noreply.github.com"')
os.system('git add README.md')
os.system(f'git commit -m "docs: auto-update commit count to {total_count} [skip ci]"')
os.system('git push')
else:
print("No changes to README detected.")
- name: Post Discord Report
if: always()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
DISCORD_WEBHOOK_2: ${{ secrets.DISCORD_WEBHOOK_2 }}
BUILD_STATUS: ${{ steps.build_step.outcome }}
run: |
LATEST_MSG=$(git log -1 HEAD~1 --pretty=%B)
export COMMIT_MSG="$LATEST_MSG"
python3 << 'EOF'
import json
import os
import requests
import random
from datetime import datetime
from zoneinfo import ZoneInfo, available_timezones
webhook_url = os.getenv('DISCORD_WEBHOOK')
webhook_url_2 = os.getenv('DISCORD_WEBHOOK_2')
commit_msg = os.getenv('COMMIT_MSG', 'Manual Sync/Update')
build_status = os.getenv('BUILD_STATUS', 'failure')
# Birthday logic: check all available timezones
all_zones = sorted(list(available_timezones()))
birthday_zones = []
for tz_name in all_zones:
try:
now_in_tz = datetime.now(ZoneInfo(tz_name))
if now_in_tz.month == 2 and now_in_tz.day == 13:
birthday_zones.append(tz_name)
except: continue
if birthday_zones:
footer_text = f"HAPPY BIRTHDAY TO ScribbleOS! Active in: {', '.join(birthday_zones)}"
else:
now_utc = datetime.now(ZoneInfo("UTC"))
next_birthday = datetime(now_utc.year, 2, 13, tzinfo=ZoneInfo("UTC"))
if now_utc > next_birthday: next_birthday = datetime(now_utc.year + 1, 2, 13, tzinfo=ZoneInfo("UTC"))
days_left = (next_birthday - now_utc).days
footer_text = f"Days until OSes birthday: {days_left}"
plane_images = [
"https://upload.wikimedia.org/wikipedia/commons/6/64/RSAF_Typhoon_at_Malta_-_Gordon_Zammit.jpg",
"https://upload.wikimedia.org/wikipedia/commons/7/72/RSF484_departing_East_Midlands_Airport_%28altered%29.jpg",
"https://upload.wikimedia.org/wikipedia/commons/8/86/Saudi_Hawks_at_airpower_%28cropped%29.jpg",
"https://upload.wikimedia.org/wikipedia/commons/5/53/RSAF_KC-707_%28cropped%29.jpg",
"https://upload.wikimedia.org/wikipedia/commons/c/c6/HZ-AR29_Boeing_787-10_Saudia_Arabian_Airlines_LHR_3.1.25.jpg",
"https://upload.wikimedia.org/wikipedia/commons/d/d5/Saudia%2C_HZ-AS62%2C_Airbus_A320-214_%2847585097882%29.jpg",
"https://upload.wikimedia.org/wikipedia/commons/5/5d/Saudia_%28Saudi_National_Day_Livery%29%2C_HZ-AQE%2C_Airbus_A330-343_%2844574961504%29.jpg",
"https://upload.wikimedia.org/wikipedia/commons/d/d8/Saudia_%28Ad-Diriyah_E-Prix_Livery%29%2C_HZ-AK43%2C_Boeing_777-368_ER_%2849596796563%29.jpg",
"https://upload.wikimedia.org/wikipedia/commons/1/1b/Saudi_Arabian_Airlines_Convair_340_Quackenbush.jpg",
"https://upload.wikimedia.org/wikipedia/commons/c/cb/Saudi_Arabian_Airlines_L-1011-200_HZ-AHE_LHR_1985-5-17.png",
"https://upload.wikimedia.org/wikipedia/commons/9/96/HZ-APF_%288016935735%29.jpg",
"https://upload.wikimedia.org/wikipedia/commons/d/d7/Saudi_Arabian_Airlines_TF-AAD_%287857764738%29.jpg",
"https://upload.wikimedia.org/wikipedia/commons/8/8a/Saudi_Arabian_Government_Boeing_747-468_HZ-HM1_at_JFK_Airport.jpg"
]
if build_status == 'success':
title = "ScribbleOS Build Successful! HELL YEA-🦅"
color = 2326507
description = f"**Commit Details:**\n{commit_msg}\n\n"
if os.path.exists('stats.json'):
try:
with open('stats.json', 'r') as f:
data = json.load(f)
if data.get('files'):
for file in data['files']:
stats = []
if int(file['added']) > 0: stats.append(f"+{file['added']}")
if int(file['removed']) > 0: stats.append(f"-{file['removed']}")
if int(file['changed']) > 0: stats.append(f"~{file['changed']}")
stat_line = " | ".join(stats) if stats else "No changes"
description += f"**`{file['name']}`**\n`{stat_line}`\n"
except: description += "_Stats generation failed._"
else:
title = "Build Failed! ☹️☹️☹️ Ali is Suffering Right now"
color = 15158332
description = f"**Failed Commit:**\n{commit_msg}\n\nCheck the GitHub Actions tab to inspect the GCC/NASM compiler logs."
payload = {
"content": "<@&1503391410785882225>",
"embeds": [{
"title": title,
"description": description,
"color": color,
"footer": {"text": footer_text},
"image": {"url": random.choice(plane_images)}
}]
}
requests.post(webhook_url, json=payload)
requests.post(webhook_url_2, json=payload)
EOF