From a90dcea956d1ce1ff77f17d1445e447d7bf76ad4 Mon Sep 17 00:00:00 2001 From: neoarz Date: Mon, 14 Apr 2025 21:17:04 -0400 Subject: [PATCH 01/14] repo updater --- .github/workflows/updatesource.yml | 78 ++++++++++++++++ update_json.py | 143 +++++++++++++++++++++++++++++ 2 files changed, 221 insertions(+) create mode 100644 .github/workflows/updatesource.yml create mode 100644 update_json.py diff --git a/.github/workflows/updatesource.yml b/.github/workflows/updatesource.yml new file mode 100644 index 0000000..6a424fc --- /dev/null +++ b/.github/workflows/updatesource.yml @@ -0,0 +1,78 @@ +name: Update StikJIT Source + +on: + release: + types: [published] + workflow_dispatch: + +# Add permissions block to ensure the workflow can push changes +permissions: + contents: write + +jobs: + update-source: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install requests + + - name: Record job start time + id: job_start_time + run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT + + - name: Update StikJIT source + id: update_source + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + python update_json.py + git config --global user.name 'GitHub Action' + git config --global user.email 'action@github.com' + git add repo.json + if git diff --staged --quiet; then + echo "changes=false" >> $GITHUB_OUTPUT + else + git commit -m "Updated source with latest StikJIT release" + git push + echo "changes=true" >> $GITHUB_OUTPUT + fi + + - name: Calculate job duration + id: duration + if: always() + run: | + end_time=$(date +%s) + duration=$((end_time - ${{ steps.job_start_time.outputs.start_time }})) + echo "duration=$duration seconds" >> $GITHUB_OUTPUT + + - name: Create job summary + run: | + if [[ "${{ steps.update_source.outputs.changes }}" == "true" ]]; then + echo "## Update StikJIT Source Summary 🚀" >> $GITHUB_STEP_SUMMARY + echo "✅ Changes Detected and Applied" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "The repo.json file has been updated with the latest release information." >> $GITHUB_STEP_SUMMARY + else + echo "## Update StikJIT Source Summary 🚀" >> $GITHUB_STEP_SUMMARY + echo "🔍 No Changes Detected" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "The repo.json file is up to date. No changes were necessary." >> $GITHUB_STEP_SUMMARY + fi + echo "" >> $GITHUB_STEP_SUMMARY + echo "🕐 Execution Time" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "This job took ${{ steps.duration.outputs.duration }} to complete." >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "📆 Next Scheduled Run" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "The next scheduled run will be triggered when a new release is published." >> $GITHUB_STEP_SUMMARY \ No newline at end of file diff --git a/update_json.py b/update_json.py new file mode 100644 index 0000000..e9a0638 --- /dev/null +++ b/update_json.py @@ -0,0 +1,143 @@ +import json +import re +import requests +import os +from datetime import datetime + +def prepare_description(text): + text = re.sub('<[^<]+?>', '', text) # Remove HTML tags + text = re.sub(r'#{1,6}\s?', '', text) # Remove markdown header tags + text = re.sub(r'\*{2}', '', text) # Remove all occurrences of two consecutive asterisks + text = re.sub(r'(?<=\r|\n)-', '•', text) # Only replace - with • if it is preceded by \r or \n + text = re.sub(r'`', '"', text) # Replace ` with " + text = re.sub(r'\r\n\r\n', '\r \n', text) # Replace \r\n\r\n with \r \n (avoid incorrect display of the description regarding paragraphs) + return text + +def fetch_latest_release(repo_url): + api_url = f"https://api.github.com/repos/{repo_url}/releases" + headers = { + "Accept": "application/vnd.github+json", + } + try: + response = requests.get(api_url, headers=headers) + response.raise_for_status() + release = response.json() + return release + except requests.RequestException as e: + print(f"Error fetching releases: {e}") + raise + +def get_file_size(url): + try: + response = requests.head(url) + response.raise_for_status() + return int(response.headers.get('Content-Length', 0)) + except requests.RequestException as e: + print(f"Error getting file size: {e}") + return 0 + +def update_json_file(json_file, latest_release): + if isinstance(latest_release, list) and latest_release: + latest_release = latest_release[0] + else: + print("Error getting latest release") + return + + try: + with open(json_file, "r") as file: + data = json.load(file) + except json.JSONDecodeError as e: + print(f"Error reading JSON file: {e}") + data = {"apps": []} + raise + + app = data["apps"][0] + + full_version = latest_release["tag_name"] + tag = latest_release["tag_name"] + version = re.search(r"(\d+\.\d+\.\d+)", full_version).group(1) + version_date = latest_release["published_at"] + date_obj = datetime.strptime(version_date, "%Y-%m-%dT%H:%M:%SZ") + version_date = date_obj.strftime("%Y-%m-%d") + + description = latest_release["body"] + description = prepare_description(description) + + assets = latest_release.get("assets", []) + download_url = None + size = None + for asset in assets: + if asset["name"].endswith(".ipa"): + download_url = asset["browser_download_url"] + size = asset["size"] + break + + if download_url is None or size is None: + print("Error: IPA file not found in release assets.") + return + + version_entry = { + "version": version, + "date": version_date, + "localizedDescription": description, + "downloadURL": download_url, + "size": size, + "minOSVersion": "17.4" # Adding minOSVersion for StikJIT + } + + duplicate_entries = [item for item in app["versions"] if item["version"] == version] + if duplicate_entries: + app["versions"].remove(duplicate_entries[0]) + + app["versions"].insert(0, version_entry) + + app.update({ + "version": version, + "versionDate": version_date, + "versionDescription": description, + "downloadURL": download_url, + "size": size + }) + + if "news" not in data: + data["news"] = [] + + news_identifier = f"release-{full_version}" + date_string = date_obj.strftime("%d/%m/%y") + news_entry = { + "appID": "com.stik.sj", + "caption": f"Update of StikJIT just got released!", + "date": latest_release["published_at"], + "identifier": news_identifier, + "imageURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", + "notify": True, + "tintColor": "#293B45", + "title": f"{full_version} - StikJIT {date_string}", + "url": f"https://github.com/0-Blu/StikJIT/releases/tag/{tag}" + } + + news_entry_exists = any(item["identifier"] == news_identifier for item in data["news"]) + if not news_entry_exists: + data["news"].append(news_entry) + + try: + with open(json_file, "w") as file: + json.dump(data, file, indent=2) + print("JSON file updated successfully.") + except IOError as e: + print(f"Error writing to JSON file: {e}") + raise + +def main(): + repo_url = "0-Blu/StikJIT" + json_file = "repo.json" + + try: + fetched_data_latest = fetch_latest_release(repo_url) + update_json_file(json_file, fetched_data_latest) + except Exception as e: + print(f"An error occurred: {e}") + raise + +if __name__ == "__main__": + main() \ No newline at end of file From 8d2696433d8909d79bf3341dd6c6cc55b8b52ce2 Mon Sep 17 00:00:00 2001 From: neoarz Date: Mon, 14 Apr 2025 21:20:27 -0400 Subject: [PATCH 02/14] json --- .github/workflows/updatesource.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/updatesource.yml b/.github/workflows/updatesource.yml index 6a424fc..c115175 100644 --- a/.github/workflows/updatesource.yml +++ b/.github/workflows/updatesource.yml @@ -15,6 +15,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 + with: + ref: main # Explicitly checkout the main branch - name: Set up Python uses: actions/setup-python@v4 @@ -43,7 +45,7 @@ jobs: echo "changes=false" >> $GITHUB_OUTPUT else git commit -m "Updated source with latest StikJIT release" - git push + git push origin main echo "changes=true" >> $GITHUB_OUTPUT fi From bdd95a4b77e6213dfb2b39a7a90f8884df224c54 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 15 Apr 2025 01:21:38 +0000 Subject: [PATCH 03/14] Updated source with latest StikJIT release --- repo.json | 156 +++++++++++++++++++++++++++++------------------------- 1 file changed, 85 insertions(+), 71 deletions(-) diff --git a/repo.json b/repo.json index f54d321..1de9c07 100644 --- a/repo.json +++ b/repo.json @@ -1,73 +1,87 @@ { - "name": "StikJIT Repository", - "identifier": "com.stik.sj", - "subtitle": "AltStore/SideStore compatible source repository for StikJIT.", - "iconURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", - "headerURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", - "tintColor": "#293B45", - "featuredApps": [ - "com.stik.sj" - ], - "apps": [ - { - "name": "StikJIT", - "bundleIdentifier": "com.stik.sj", - "developerName": "Stephen", - "subtitle": "An on-device JIT enabler for iOS versions 17.4+ (excluding iOS 18.4 beta 1), powered by idevice.", - "localizedDescription": "Enable JIT capabilities for your sideloaded apps.", - "iconURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", - "tintColor": "#293B45", - "screenshots": [ - "https://github.com/0-Blu/StikJIT/blob/main/assets/views/dark/HomeScreen.PNG?raw=true", - "https://github.com/0-Blu/StikJIT/blob/main/assets/views/dark/AppsList.PNG?raw=true", - "https://github.com/0-Blu/StikJIT/blob/main/assets/views/dark/Settings.PNG?raw=true" - ], - "versions": [ - { - "version": "1.3.1", - "date": "2025-04-14T12:00:00-05:00", - "size": 6211010, - "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.3.1/StikJIT_1.3.1.ipa", - "localizedDescription": "Bug fixes - no wifi error, make -9 error more clear, fix -17 error", - "minOSVersion": "17.4" - }, - { - "version": "1.3", - "date": "2025-04-12", - "size": 6210215, - "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.3/StikJIT.ipa", - "localizedDescription": "Enhanced & Advanced: Improved performance: Fixes disk image unbounting in the background, DNS Blocker Check, UI tweaks: custom accent color picker, more logs." - }, - { - "version": "1.2", - "date": "2025-04-07", - "localizedDescription": "Smooth Sailing: Improved performance: Prevented UI stutter in App List. UI tweaks: Light theme for notifications, better aligned UI elements, expanded theming support, fixed user feedback when get-task-allow is missing.", - "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.2/StikJit_1.2.ipa", - "size": 5922690 - }, - { - "version": "1.1", - "date": "2025-04-01", - "localizedDescription": "Bug fixes and UI improvements. Enhanced system log viewer and better error handling.", - "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.1/StikJit_1.1.ipa", - "size": 5800000 - }, - { - "version": "1.0", - "date": "2025-03-26", - "localizedDescription": "Initial release of StikJIT", - "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.0/StikJit_1.0.ipa", - "size": 5000000 - } - ], - "appPermissions": { - "entitlements": [ - ], - "privacy": { - } + "name": "StikJIT Repository", + "identifier": "com.stik.sj", + "subtitle": "AltStore/SideStore compatible source repository for StikJIT.", + "iconURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", + "headerURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", + "tintColor": "#293B45", + "featuredApps": [ + "com.stik.sj" + ], + "apps": [ + { + "name": "StikJIT", + "bundleIdentifier": "com.stik.sj", + "developerName": "Stephen", + "subtitle": "An on-device JIT enabler for iOS versions 17.4+ (excluding iOS 18.4 beta 1), powered by idevice.", + "localizedDescription": "Enable JIT capabilities for your sideloaded apps.", + "iconURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", + "tintColor": "#293B45", + "screenshots": [ + "https://github.com/0-Blu/StikJIT/blob/main/assets/views/dark/HomeScreen.PNG?raw=true", + "https://github.com/0-Blu/StikJIT/blob/main/assets/views/dark/AppsList.PNG?raw=true", + "https://github.com/0-Blu/StikJIT/blob/main/assets/views/dark/Settings.PNG?raw=true" + ], + "versions": [ + { + "version": "1.3.1", + "date": "2025-04-14", + "localizedDescription": "What's Changed\r\n* Fix the no wifi error by @neoarz in https://github.com/0-Blu/StikJIT/pull/122\r\n* Make the -9 error more clear by @neoarz in https://github.com/0-Blu/StikJIT/pull/123\r\n* Fixes the -17 error (hopefully)\r\nFull Changelog: https://github.com/0-Blu/StikJIT/compare/1.3...1.3.1", + "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.3.1/StikJIT_1.3.1.ipa", + "size": 6211010, + "minOSVersion": "17.4" + }, + { + "version": "1.3", + "date": "2025-04-12", + "size": 6210215, + "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.3/StikJIT.ipa", + "localizedDescription": "Enhanced & Advanced: Improved performance: Fixes disk image unbounting in the background, DNS Blocker Check, UI tweaks: custom accent color picker, more logs." + }, + { + "version": "1.2", + "date": "2025-04-07", + "localizedDescription": "Smooth Sailing: Improved performance: Prevented UI stutter in App List. UI tweaks: Light theme for notifications, better aligned UI elements, expanded theming support, fixed user feedback when get-task-allow is missing.", + "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.2/StikJit_1.2.ipa", + "size": 5922690 + }, + { + "version": "1.1", + "date": "2025-04-01", + "localizedDescription": "Bug fixes and UI improvements. Enhanced system log viewer and better error handling.", + "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.1/StikJit_1.1.ipa", + "size": 5800000 + }, + { + "version": "1.0", + "date": "2025-03-26", + "localizedDescription": "Initial release of StikJIT", + "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.0/StikJit_1.0.ipa", + "size": 5000000 } - } - ], - "news": [ - ] -} + ], + "appPermissions": { + "entitlements": [], + "privacy": {} + }, + "version": "1.3.1", + "versionDate": "2025-04-14", + "versionDescription": "What's Changed\r\n* Fix the no wifi error by @neoarz in https://github.com/0-Blu/StikJIT/pull/122\r\n* Make the -9 error more clear by @neoarz in https://github.com/0-Blu/StikJIT/pull/123\r\n* Fixes the -17 error (hopefully)\r\nFull Changelog: https://github.com/0-Blu/StikJIT/compare/1.3...1.3.1", + "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.3.1/StikJIT_1.3.1.ipa", + "size": 6211010 + } + ], + "news": [ + { + "appID": "com.stik.sj", + "caption": "Update of StikJIT just got released!", + "date": "2025-04-14T12:20:23Z", + "identifier": "release-1.3.1", + "imageURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", + "notify": true, + "tintColor": "#293B45", + "title": "1.3.1 - StikJIT 14/04/25", + "url": "https://github.com/0-Blu/StikJIT/releases/tag/1.3.1" + } + ] +} \ No newline at end of file From 1f9588f242bc3a9ff81e7b5f5d5689c60caad5fc Mon Sep 17 00:00:00 2001 From: neoarz Date: Mon, 14 Apr 2025 21:24:48 -0400 Subject: [PATCH 04/14] pr instead of release --- .github/workflows/updatesource.yml | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/.github/workflows/updatesource.yml b/.github/workflows/updatesource.yml index c115175..6ad593e 100644 --- a/.github/workflows/updatesource.yml +++ b/.github/workflows/updatesource.yml @@ -8,6 +8,7 @@ on: # Add permissions block to ensure the workflow can push changes permissions: contents: write + pull-requests: write jobs: update-source: @@ -17,6 +18,7 @@ jobs: uses: actions/checkout@v3 with: ref: main # Explicitly checkout the main branch + fetch-depth: 0 # Fetch all history for proper branching - name: Set up Python uses: actions/setup-python@v4 @@ -44,11 +46,33 @@ jobs: if git diff --staged --quiet; then echo "changes=false" >> $GITHUB_OUTPUT else + # Create a new branch for the changes + BRANCH_NAME="update-source-$(date +%Y%m%d-%H%M%S)" + git checkout -b $BRANCH_NAME git commit -m "Updated source with latest StikJIT release" - git push origin main + git push origin $BRANCH_NAME + echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT echo "changes=true" >> $GITHUB_OUTPUT fi + - name: Create Pull Request + if: steps.update_source.outputs.changes == 'true' + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ steps.update_source.outputs.branch }} + base: main + title: "Update StikJIT source with latest release" + body: | + This PR updates the repo.json file with the latest StikJIT release information. + + Changes include: + - Updated version information + - Added new release to versions list + - Updated news section + + Please review and merge if everything looks good. + - name: Calculate job duration id: duration if: always() @@ -61,9 +85,9 @@ jobs: run: | if [[ "${{ steps.update_source.outputs.changes }}" == "true" ]]; then echo "## Update StikJIT Source Summary 🚀" >> $GITHUB_STEP_SUMMARY - echo "✅ Changes Detected and Applied" >> $GITHUB_STEP_SUMMARY + echo "✅ Changes Detected and Pull Request Created" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "The repo.json file has been updated with the latest release information." >> $GITHUB_STEP_SUMMARY + echo "A pull request has been created to update the repo.json file with the latest release information." >> $GITHUB_STEP_SUMMARY else echo "## Update StikJIT Source Summary 🚀" >> $GITHUB_STEP_SUMMARY echo "🔍 No Changes Detected" >> $GITHUB_STEP_SUMMARY From 54f95d143a8f52cde3ff5bfc29b44271446a1f07 Mon Sep 17 00:00:00 2001 From: neoarz Date: Mon, 14 Apr 2025 21:24:56 -0400 Subject: [PATCH 05/14] neo instead of blu --- update_json.py | 49 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/update_json.py b/update_json.py index e9a0638..050b7b6 100644 --- a/update_json.py +++ b/update_json.py @@ -2,6 +2,7 @@ import json import re import requests import os +import sys from datetime import datetime def prepare_description(text): @@ -21,11 +22,14 @@ def fetch_latest_release(repo_url): try: response = requests.get(api_url, headers=headers) response.raise_for_status() - release = response.json() - return release + releases = response.json() + if not releases: + print("No releases found in the repository") + return None + return releases except requests.RequestException as e: print(f"Error fetching releases: {e}") - raise + return None def get_file_size(url): try: @@ -41,26 +45,33 @@ def update_json_file(json_file, latest_release): latest_release = latest_release[0] else: print("Error getting latest release") - return + return False try: with open(json_file, "r") as file: data = json.load(file) except json.JSONDecodeError as e: print(f"Error reading JSON file: {e}") - data = {"apps": []} - raise + return False + except FileNotFoundError: + print(f"File {json_file} not found") + return False app = data["apps"][0] full_version = latest_release["tag_name"] tag = latest_release["tag_name"] - version = re.search(r"(\d+\.\d+\.\d+)", full_version).group(1) + version_match = re.search(r"(\d+\.\d+\.\d+)", full_version) + if not version_match: + print(f"Could not extract version from tag: {full_version}") + return False + + version = version_match.group(1) version_date = latest_release["published_at"] date_obj = datetime.strptime(version_date, "%Y-%m-%dT%H:%M:%SZ") version_date = date_obj.strftime("%Y-%m-%d") - description = latest_release["body"] + description = latest_release["body"] or "No description provided" description = prepare_description(description) assets = latest_release.get("assets", []) @@ -74,7 +85,7 @@ def update_json_file(json_file, latest_release): if download_url is None or size is None: print("Error: IPA file not found in release assets.") - return + return False version_entry = { "version": version, @@ -124,20 +135,32 @@ def update_json_file(json_file, latest_release): with open(json_file, "w") as file: json.dump(data, file, indent=2) print("JSON file updated successfully.") + return True except IOError as e: print(f"Error writing to JSON file: {e}") - raise + return False def main(): - repo_url = "0-Blu/StikJIT" + # Get repository from environment variable or use default + repo_url = os.environ.get("GITHUB_REPOSITORY", "neoarz/StikJIT") json_file = "repo.json" + print(f"Using repository: {repo_url}") + print(f"Updating file: {json_file}") + try: fetched_data_latest = fetch_latest_release(repo_url) - update_json_file(json_file, fetched_data_latest) + if fetched_data_latest: + success = update_json_file(json_file, fetched_data_latest) + if not success: + print("Failed to update JSON file") + sys.exit(1) + else: + print("No releases found to update") + sys.exit(1) except Exception as e: print(f"An error occurred: {e}") - raise + sys.exit(1) if __name__ == "__main__": main() \ No newline at end of file From df88e8b6250cbabcc9bd27bb1a902c75443bc3d1 Mon Sep 17 00:00:00 2001 From: neoarz Date: Mon, 14 Apr 2025 21:28:41 -0400 Subject: [PATCH 06/14] works? --- .github/workflows/updatesource.yml | 21 ++++++++++++++++++ update_json.py | 35 ++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/.github/workflows/updatesource.yml b/.github/workflows/updatesource.yml index 6ad593e..4c64353 100644 --- a/.github/workflows/updatesource.yml +++ b/.github/workflows/updatesource.yml @@ -34,6 +34,19 @@ jobs: id: job_start_time run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT + - name: Debug repository information + run: | + echo "Repository: $GITHUB_REPOSITORY" + echo "Event name: $GITHUB_EVENT_NAME" + echo "Event path: $GITHUB_EVENT_PATH" + if [ -f "$GITHUB_EVENT_PATH" ]; then + echo "Event payload:" + cat $GITHUB_EVENT_PATH + fi + echo "Current directory: $(pwd)" + echo "Repository contents:" + ls -la + - name: Update StikJIT source id: update_source env: @@ -45,7 +58,10 @@ jobs: git add repo.json if git diff --staged --quiet; then echo "changes=false" >> $GITHUB_OUTPUT + echo "No changes detected in repo.json" else + echo "Changes detected in repo.json:" + git diff --staged # Create a new branch for the changes BRANCH_NAME="update-source-$(date +%Y%m%d-%H%M%S)" git checkout -b $BRANCH_NAME @@ -93,6 +109,11 @@ jobs: echo "🔍 No Changes Detected" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "The repo.json file is up to date. No changes were necessary." >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "This could be because:" >> $GITHUB_STEP_SUMMARY + echo "- The release version is already in the repo.json file" >> $GITHUB_STEP_SUMMARY + echo "- The release doesn't contain an IPA file" >> $GITHUB_STEP_SUMMARY + echo "- The release tag doesn't match the expected version format" >> $GITHUB_STEP_SUMMARY fi echo "" >> $GITHUB_STEP_SUMMARY echo "🕐 Execution Time" >> $GITHUB_STEP_SUMMARY diff --git a/update_json.py b/update_json.py index 050b7b6..707dc2c 100644 --- a/update_json.py +++ b/update_json.py @@ -20,12 +20,15 @@ def fetch_latest_release(repo_url): "Accept": "application/vnd.github+json", } try: + print(f"Fetching releases from: {api_url}") response = requests.get(api_url, headers=headers) response.raise_for_status() releases = response.json() if not releases: print("No releases found in the repository") return None + print(f"Found {len(releases)} releases") + print(f"Latest release: {releases[0]['tag_name']}") return releases except requests.RequestException as e: print(f"Error fetching releases: {e}") @@ -48,6 +51,7 @@ def update_json_file(json_file, latest_release): return False try: + print(f"Reading JSON file: {json_file}") with open(json_file, "r") as file: data = json.load(file) except json.JSONDecodeError as e: @@ -58,6 +62,8 @@ def update_json_file(json_file, latest_release): return False app = data["apps"][0] + current_version = app.get("version", "unknown") + print(f"Current version in repo.json: {current_version}") full_version = latest_release["tag_name"] tag = latest_release["tag_name"] @@ -67,6 +73,19 @@ def update_json_file(json_file, latest_release): return False version = version_match.group(1) + print(f"Latest release version: {version}") + + # Check if the version is already in the versions list + existing_versions = [v["version"] for v in app["versions"]] + print(f"Existing versions: {existing_versions}") + + if version in existing_versions: + print(f"Version {version} already exists in the versions list") + # Check if the latest version is already the current version + if version == current_version: + print("The latest version is already the current version, no changes needed") + return False + version_date = latest_release["published_at"] date_obj = datetime.strptime(version_date, "%Y-%m-%dT%H:%M:%SZ") version_date = date_obj.strftime("%Y-%m-%d") @@ -75,12 +94,17 @@ def update_json_file(json_file, latest_release): description = prepare_description(description) assets = latest_release.get("assets", []) + print(f"Found {len(assets)} assets in the release") + for asset in assets: + print(f"Asset: {asset['name']}") + download_url = None size = None for asset in assets: if asset["name"].endswith(".ipa"): download_url = asset["browser_download_url"] size = asset["size"] + print(f"Found IPA file: {asset['name']}, size: {size}") break if download_url is None or size is None: @@ -98,10 +122,13 @@ def update_json_file(json_file, latest_release): duplicate_entries = [item for item in app["versions"] if item["version"] == version] if duplicate_entries: + print(f"Removing duplicate entry for version {version}") app["versions"].remove(duplicate_entries[0]) + print(f"Adding new version entry: {version}") app["versions"].insert(0, version_entry) + print(f"Updating app with version {version}") app.update({ "version": version, "versionDate": version_date, @@ -129,9 +156,13 @@ def update_json_file(json_file, latest_release): news_entry_exists = any(item["identifier"] == news_identifier for item in data["news"]) if not news_entry_exists: + print(f"Adding news entry for version {full_version}") data["news"].append(news_entry) + else: + print(f"News entry for version {full_version} already exists") try: + print(f"Writing updated JSON to {json_file}") with open(json_file, "w") as file: json.dump(data, file, indent=2) print("JSON file updated successfully.") @@ -153,8 +184,8 @@ def main(): if fetched_data_latest: success = update_json_file(json_file, fetched_data_latest) if not success: - print("Failed to update JSON file") - sys.exit(1) + print("Failed to update JSON file or no changes were needed") + sys.exit(0) # Exit with success code since no changes needed is not an error else: print("No releases found to update") sys.exit(1) From 6d7b2d38a5b652589e27fa97280a2b551725cf45 Mon Sep 17 00:00:00 2001 From: neoarz Date: Mon, 14 Apr 2025 21:32:02 -0400 Subject: [PATCH 07/14] final --- .github/workflows/updatesource.yml | 45 +++++++----------------------- update_json.py | 15 +++------- 2 files changed, 14 insertions(+), 46 deletions(-) diff --git a/.github/workflows/updatesource.yml b/.github/workflows/updatesource.yml index 4c64353..7dc4932 100644 --- a/.github/workflows/updatesource.yml +++ b/.github/workflows/updatesource.yml @@ -8,7 +8,6 @@ on: # Add permissions block to ensure the workflow can push changes permissions: contents: write - pull-requests: write jobs: update-source: @@ -16,9 +15,6 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 - with: - ref: main # Explicitly checkout the main branch - fetch-depth: 0 # Fetch all history for proper branching - name: Set up Python uses: actions/setup-python@v4 @@ -38,11 +34,6 @@ jobs: run: | echo "Repository: $GITHUB_REPOSITORY" echo "Event name: $GITHUB_EVENT_NAME" - echo "Event path: $GITHUB_EVENT_PATH" - if [ -f "$GITHUB_EVENT_PATH" ]; then - echo "Event payload:" - cat $GITHUB_EVENT_PATH - fi echo "Current directory: $(pwd)" echo "Repository contents:" ls -la @@ -52,9 +43,14 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - python update_json.py + # Configure git git config --global user.name 'GitHub Action' git config --global user.email 'action@github.com' + + # Run the update script + python update_json.py + + # Check for changes and commit if needed git add repo.json if git diff --staged --quiet; then echo "changes=false" >> $GITHUB_OUTPUT @@ -62,33 +58,12 @@ jobs: else echo "Changes detected in repo.json:" git diff --staged - # Create a new branch for the changes - BRANCH_NAME="update-source-$(date +%Y%m%d-%H%M%S)" - git checkout -b $BRANCH_NAME git commit -m "Updated source with latest StikJIT release" - git push origin $BRANCH_NAME - echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT + # Force push to main + git push -f origin HEAD:main echo "changes=true" >> $GITHUB_OUTPUT fi - - name: Create Pull Request - if: steps.update_source.outputs.changes == 'true' - uses: peter-evans/create-pull-request@v5 - with: - token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ steps.update_source.outputs.branch }} - base: main - title: "Update StikJIT source with latest release" - body: | - This PR updates the repo.json file with the latest StikJIT release information. - - Changes include: - - Updated version information - - Added new release to versions list - - Updated news section - - Please review and merge if everything looks good. - - name: Calculate job duration id: duration if: always() @@ -101,9 +76,9 @@ jobs: run: | if [[ "${{ steps.update_source.outputs.changes }}" == "true" ]]; then echo "## Update StikJIT Source Summary 🚀" >> $GITHUB_STEP_SUMMARY - echo "✅ Changes Detected and Pull Request Created" >> $GITHUB_STEP_SUMMARY + echo "✅ Changes Detected and Pushed" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "A pull request has been created to update the repo.json file with the latest release information." >> $GITHUB_STEP_SUMMARY + echo "The repo.json file has been updated with the latest release information." >> $GITHUB_STEP_SUMMARY else echo "## Update StikJIT Source Summary 🚀" >> $GITHUB_STEP_SUMMARY echo "🔍 No Changes Detected" >> $GITHUB_STEP_SUMMARY diff --git a/update_json.py b/update_json.py index 707dc2c..5e82508 100644 --- a/update_json.py +++ b/update_json.py @@ -79,12 +79,9 @@ def update_json_file(json_file, latest_release): existing_versions = [v["version"] for v in app["versions"]] print(f"Existing versions: {existing_versions}") - if version in existing_versions: - print(f"Version {version} already exists in the versions list") - # Check if the latest version is already the current version - if version == current_version: - print("The latest version is already the current version, no changes needed") - return False + if version in existing_versions and version == current_version: + print(f"Version {version} already exists and is current, no update needed") + return False version_date = latest_release["published_at"] date_obj = datetime.strptime(version_date, "%Y-%m-%dT%H:%M:%SZ") @@ -120,11 +117,7 @@ def update_json_file(json_file, latest_release): "minOSVersion": "17.4" # Adding minOSVersion for StikJIT } - duplicate_entries = [item for item in app["versions"] if item["version"] == version] - if duplicate_entries: - print(f"Removing duplicate entry for version {version}") - app["versions"].remove(duplicate_entries[0]) - + # Always update with the latest version print(f"Adding new version entry: {version}") app["versions"].insert(0, version_entry) From b0293c415ebb94ac134fd7aa25582da16395f4c0 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 15 Apr 2025 01:32:26 +0000 Subject: [PATCH 08/14] Updated source with latest StikJIT release --- repo.json | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/repo.json b/repo.json index 1de9c07..670ae4b 100644 --- a/repo.json +++ b/repo.json @@ -23,6 +23,14 @@ "https://github.com/0-Blu/StikJIT/blob/main/assets/views/dark/Settings.PNG?raw=true" ], "versions": [ + { + "version": "1.3.2", + "date": "2025-04-15", + "localizedDescription": "testing release", + "downloadURL": "https://github.com/neoarz/StikJIT/releases/download/1.3.2/StikJIT_1.3.2.ipa", + "size": 6211010, + "minOSVersion": "17.4" + }, { "version": "1.3.1", "date": "2025-04-14", @@ -64,10 +72,10 @@ "entitlements": [], "privacy": {} }, - "version": "1.3.1", - "versionDate": "2025-04-14", - "versionDescription": "What's Changed\r\n* Fix the no wifi error by @neoarz in https://github.com/0-Blu/StikJIT/pull/122\r\n* Make the -9 error more clear by @neoarz in https://github.com/0-Blu/StikJIT/pull/123\r\n* Fixes the -17 error (hopefully)\r\nFull Changelog: https://github.com/0-Blu/StikJIT/compare/1.3...1.3.1", - "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.3.1/StikJIT_1.3.1.ipa", + "version": "1.3.2", + "versionDate": "2025-04-15", + "versionDescription": "testing release", + "downloadURL": "https://github.com/neoarz/StikJIT/releases/download/1.3.2/StikJIT_1.3.2.ipa", "size": 6211010 } ], @@ -82,6 +90,17 @@ "tintColor": "#293B45", "title": "1.3.1 - StikJIT 14/04/25", "url": "https://github.com/0-Blu/StikJIT/releases/tag/1.3.1" + }, + { + "appID": "com.stik.sj", + "caption": "Update of StikJIT just got released!", + "date": "2025-04-15T01:18:49Z", + "identifier": "release-1.3.2", + "imageURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", + "notify": true, + "tintColor": "#293B45", + "title": "1.3.2 - StikJIT 15/04/25", + "url": "https://github.com/0-Blu/StikJIT/releases/tag/1.3.2" } ] } \ No newline at end of file From 5519ece7adfda1ad357a1ac3955c744c8f0f63bf Mon Sep 17 00:00:00 2001 From: neoarz Date: Mon, 14 Apr 2025 21:53:26 -0400 Subject: [PATCH 09/14] final --- .github/workflows/updatesource.yml | 10 +++++++--- update_json.py | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/updatesource.yml b/.github/workflows/updatesource.yml index 7dc4932..eb11ca4 100644 --- a/.github/workflows/updatesource.yml +++ b/.github/workflows/updatesource.yml @@ -15,6 +15,10 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + repository: 0-Blu/StikJIT + ref: main - name: Set up Python uses: actions/setup-python@v4 @@ -32,7 +36,7 @@ jobs: - name: Debug repository information run: | - echo "Repository: $GITHUB_REPOSITORY" + echo "Repository: 0-Blu/StikJIT" echo "Event name: $GITHUB_EVENT_NAME" echo "Current directory: $(pwd)" echo "Repository contents:" @@ -59,8 +63,8 @@ jobs: echo "Changes detected in repo.json:" git diff --staged git commit -m "Updated source with latest StikJIT release" - # Force push to main - git push -f origin HEAD:main + # Push to main branch of original repository + git push origin main echo "changes=true" >> $GITHUB_OUTPUT fi diff --git a/update_json.py b/update_json.py index 5e82508..463a8b8 100644 --- a/update_json.py +++ b/update_json.py @@ -165,8 +165,8 @@ def update_json_file(json_file, latest_release): return False def main(): - # Get repository from environment variable or use default - repo_url = os.environ.get("GITHUB_REPOSITORY", "neoarz/StikJIT") + # Use the original repository instead of fork + repo_url = "0-Blu/StikJIT" json_file = "repo.json" print(f"Using repository: {repo_url}") From 06f16e39dd5d16950df0e49935300b616e937a4b Mon Sep 17 00:00:00 2001 From: neoarz Date: Mon, 14 Apr 2025 21:55:11 -0400 Subject: [PATCH 10/14] fix --- .github/workflows/updatesource.yml | 104 ---------------- repo.json | 57 ++------- update_json.py | 190 ----------------------------- 3 files changed, 12 insertions(+), 339 deletions(-) delete mode 100644 .github/workflows/updatesource.yml delete mode 100644 update_json.py diff --git a/.github/workflows/updatesource.yml b/.github/workflows/updatesource.yml deleted file mode 100644 index eb11ca4..0000000 --- a/.github/workflows/updatesource.yml +++ /dev/null @@ -1,104 +0,0 @@ -name: Update StikJIT Source - -on: - release: - types: [published] - workflow_dispatch: - -# Add permissions block to ensure the workflow can push changes -permissions: - contents: write - -jobs: - update-source: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - repository: 0-Blu/StikJIT - ref: main - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install requests - - - name: Record job start time - id: job_start_time - run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT - - - name: Debug repository information - run: | - echo "Repository: 0-Blu/StikJIT" - echo "Event name: $GITHUB_EVENT_NAME" - echo "Current directory: $(pwd)" - echo "Repository contents:" - ls -la - - - name: Update StikJIT source - id: update_source - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - # Configure git - git config --global user.name 'GitHub Action' - git config --global user.email 'action@github.com' - - # Run the update script - python update_json.py - - # Check for changes and commit if needed - git add repo.json - if git diff --staged --quiet; then - echo "changes=false" >> $GITHUB_OUTPUT - echo "No changes detected in repo.json" - else - echo "Changes detected in repo.json:" - git diff --staged - git commit -m "Updated source with latest StikJIT release" - # Push to main branch of original repository - git push origin main - echo "changes=true" >> $GITHUB_OUTPUT - fi - - - name: Calculate job duration - id: duration - if: always() - run: | - end_time=$(date +%s) - duration=$((end_time - ${{ steps.job_start_time.outputs.start_time }})) - echo "duration=$duration seconds" >> $GITHUB_OUTPUT - - - name: Create job summary - run: | - if [[ "${{ steps.update_source.outputs.changes }}" == "true" ]]; then - echo "## Update StikJIT Source Summary 🚀" >> $GITHUB_STEP_SUMMARY - echo "✅ Changes Detected and Pushed" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "The repo.json file has been updated with the latest release information." >> $GITHUB_STEP_SUMMARY - else - echo "## Update StikJIT Source Summary 🚀" >> $GITHUB_STEP_SUMMARY - echo "🔍 No Changes Detected" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "The repo.json file is up to date. No changes were necessary." >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "This could be because:" >> $GITHUB_STEP_SUMMARY - echo "- The release version is already in the repo.json file" >> $GITHUB_STEP_SUMMARY - echo "- The release doesn't contain an IPA file" >> $GITHUB_STEP_SUMMARY - echo "- The release tag doesn't match the expected version format" >> $GITHUB_STEP_SUMMARY - fi - echo "" >> $GITHUB_STEP_SUMMARY - echo "🕐 Execution Time" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "This job took ${{ steps.duration.outputs.duration }} to complete." >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "📆 Next Scheduled Run" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "The next scheduled run will be triggered when a new release is published." >> $GITHUB_STEP_SUMMARY \ No newline at end of file diff --git a/repo.json b/repo.json index 670ae4b..d1c605f 100644 --- a/repo.json +++ b/repo.json @@ -6,7 +6,7 @@ "headerURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", "tintColor": "#293B45", "featuredApps": [ - "com.stik.sj" + "com.stik.sj" ], "apps": [ { @@ -23,23 +23,15 @@ "https://github.com/0-Blu/StikJIT/blob/main/assets/views/dark/Settings.PNG?raw=true" ], "versions": [ - { - "version": "1.3.2", - "date": "2025-04-15", - "localizedDescription": "testing release", - "downloadURL": "https://github.com/neoarz/StikJIT/releases/download/1.3.2/StikJIT_1.3.2.ipa", - "size": 6211010, - "minOSVersion": "17.4" - }, - { + { "version": "1.3.1", - "date": "2025-04-14", - "localizedDescription": "What's Changed\r\n* Fix the no wifi error by @neoarz in https://github.com/0-Blu/StikJIT/pull/122\r\n* Make the -9 error more clear by @neoarz in https://github.com/0-Blu/StikJIT/pull/123\r\n* Fixes the -17 error (hopefully)\r\nFull Changelog: https://github.com/0-Blu/StikJIT/compare/1.3...1.3.1", - "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.3.1/StikJIT_1.3.1.ipa", + "date": "2025-04-14T12:00:00-05:00", "size": 6211010, + "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.3.1/StikJIT_1.3.1.ipa", + "localizedDescription": "Bug fixes - no wifi error, make -9 error more clear, fix -17 error", "minOSVersion": "17.4" - }, - { + }, + { "version": "1.3", "date": "2025-04-12", "size": 6210215, @@ -69,38 +61,13 @@ } ], "appPermissions": { - "entitlements": [], - "privacy": {} - }, - "version": "1.3.2", - "versionDate": "2025-04-15", - "versionDescription": "testing release", - "downloadURL": "https://github.com/neoarz/StikJIT/releases/download/1.3.2/StikJIT_1.3.2.ipa", - "size": 6211010 + "entitlements": [ + ], + "privacy": { + } + } } ], "news": [ - { - "appID": "com.stik.sj", - "caption": "Update of StikJIT just got released!", - "date": "2025-04-14T12:20:23Z", - "identifier": "release-1.3.1", - "imageURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", - "notify": true, - "tintColor": "#293B45", - "title": "1.3.1 - StikJIT 14/04/25", - "url": "https://github.com/0-Blu/StikJIT/releases/tag/1.3.1" - }, - { - "appID": "com.stik.sj", - "caption": "Update of StikJIT just got released!", - "date": "2025-04-15T01:18:49Z", - "identifier": "release-1.3.2", - "imageURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", - "notify": true, - "tintColor": "#293B45", - "title": "1.3.2 - StikJIT 15/04/25", - "url": "https://github.com/0-Blu/StikJIT/releases/tag/1.3.2" - } ] } \ No newline at end of file diff --git a/update_json.py b/update_json.py deleted file mode 100644 index 463a8b8..0000000 --- a/update_json.py +++ /dev/null @@ -1,190 +0,0 @@ -import json -import re -import requests -import os -import sys -from datetime import datetime - -def prepare_description(text): - text = re.sub('<[^<]+?>', '', text) # Remove HTML tags - text = re.sub(r'#{1,6}\s?', '', text) # Remove markdown header tags - text = re.sub(r'\*{2}', '', text) # Remove all occurrences of two consecutive asterisks - text = re.sub(r'(?<=\r|\n)-', '•', text) # Only replace - with • if it is preceded by \r or \n - text = re.sub(r'`', '"', text) # Replace ` with " - text = re.sub(r'\r\n\r\n', '\r \n', text) # Replace \r\n\r\n with \r \n (avoid incorrect display of the description regarding paragraphs) - return text - -def fetch_latest_release(repo_url): - api_url = f"https://api.github.com/repos/{repo_url}/releases" - headers = { - "Accept": "application/vnd.github+json", - } - try: - print(f"Fetching releases from: {api_url}") - response = requests.get(api_url, headers=headers) - response.raise_for_status() - releases = response.json() - if not releases: - print("No releases found in the repository") - return None - print(f"Found {len(releases)} releases") - print(f"Latest release: {releases[0]['tag_name']}") - return releases - except requests.RequestException as e: - print(f"Error fetching releases: {e}") - return None - -def get_file_size(url): - try: - response = requests.head(url) - response.raise_for_status() - return int(response.headers.get('Content-Length', 0)) - except requests.RequestException as e: - print(f"Error getting file size: {e}") - return 0 - -def update_json_file(json_file, latest_release): - if isinstance(latest_release, list) and latest_release: - latest_release = latest_release[0] - else: - print("Error getting latest release") - return False - - try: - print(f"Reading JSON file: {json_file}") - with open(json_file, "r") as file: - data = json.load(file) - except json.JSONDecodeError as e: - print(f"Error reading JSON file: {e}") - return False - except FileNotFoundError: - print(f"File {json_file} not found") - return False - - app = data["apps"][0] - current_version = app.get("version", "unknown") - print(f"Current version in repo.json: {current_version}") - - full_version = latest_release["tag_name"] - tag = latest_release["tag_name"] - version_match = re.search(r"(\d+\.\d+\.\d+)", full_version) - if not version_match: - print(f"Could not extract version from tag: {full_version}") - return False - - version = version_match.group(1) - print(f"Latest release version: {version}") - - # Check if the version is already in the versions list - existing_versions = [v["version"] for v in app["versions"]] - print(f"Existing versions: {existing_versions}") - - if version in existing_versions and version == current_version: - print(f"Version {version} already exists and is current, no update needed") - return False - - version_date = latest_release["published_at"] - date_obj = datetime.strptime(version_date, "%Y-%m-%dT%H:%M:%SZ") - version_date = date_obj.strftime("%Y-%m-%d") - - description = latest_release["body"] or "No description provided" - description = prepare_description(description) - - assets = latest_release.get("assets", []) - print(f"Found {len(assets)} assets in the release") - for asset in assets: - print(f"Asset: {asset['name']}") - - download_url = None - size = None - for asset in assets: - if asset["name"].endswith(".ipa"): - download_url = asset["browser_download_url"] - size = asset["size"] - print(f"Found IPA file: {asset['name']}, size: {size}") - break - - if download_url is None or size is None: - print("Error: IPA file not found in release assets.") - return False - - version_entry = { - "version": version, - "date": version_date, - "localizedDescription": description, - "downloadURL": download_url, - "size": size, - "minOSVersion": "17.4" # Adding minOSVersion for StikJIT - } - - # Always update with the latest version - print(f"Adding new version entry: {version}") - app["versions"].insert(0, version_entry) - - print(f"Updating app with version {version}") - app.update({ - "version": version, - "versionDate": version_date, - "versionDescription": description, - "downloadURL": download_url, - "size": size - }) - - if "news" not in data: - data["news"] = [] - - news_identifier = f"release-{full_version}" - date_string = date_obj.strftime("%d/%m/%y") - news_entry = { - "appID": "com.stik.sj", - "caption": f"Update of StikJIT just got released!", - "date": latest_release["published_at"], - "identifier": news_identifier, - "imageURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", - "notify": True, - "tintColor": "#293B45", - "title": f"{full_version} - StikJIT {date_string}", - "url": f"https://github.com/0-Blu/StikJIT/releases/tag/{tag}" - } - - news_entry_exists = any(item["identifier"] == news_identifier for item in data["news"]) - if not news_entry_exists: - print(f"Adding news entry for version {full_version}") - data["news"].append(news_entry) - else: - print(f"News entry for version {full_version} already exists") - - try: - print(f"Writing updated JSON to {json_file}") - with open(json_file, "w") as file: - json.dump(data, file, indent=2) - print("JSON file updated successfully.") - return True - except IOError as e: - print(f"Error writing to JSON file: {e}") - return False - -def main(): - # Use the original repository instead of fork - repo_url = "0-Blu/StikJIT" - json_file = "repo.json" - - print(f"Using repository: {repo_url}") - print(f"Updating file: {json_file}") - - try: - fetched_data_latest = fetch_latest_release(repo_url) - if fetched_data_latest: - success = update_json_file(json_file, fetched_data_latest) - if not success: - print("Failed to update JSON file or no changes were needed") - sys.exit(0) # Exit with success code since no changes needed is not an error - else: - print("No releases found to update") - sys.exit(1) - except Exception as e: - print(f"An error occurred: {e}") - sys.exit(1) - -if __name__ == "__main__": - main() \ No newline at end of file From 3336bbf1a41eabd8f53c197578f3b31ca3d94f4d Mon Sep 17 00:00:00 2001 From: neoarz Date: Mon, 14 Apr 2025 21:57:30 -0400 Subject: [PATCH 11/14] formatting --- repo.json | 136 +++++++++++++++++++++++++++--------------------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/repo.json b/repo.json index d1c605f..f54d321 100644 --- a/repo.json +++ b/repo.json @@ -1,73 +1,73 @@ { - "name": "StikJIT Repository", - "identifier": "com.stik.sj", - "subtitle": "AltStore/SideStore compatible source repository for StikJIT.", - "iconURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", - "headerURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", - "tintColor": "#293B45", - "featuredApps": [ - "com.stik.sj" - ], - "apps": [ - { - "name": "StikJIT", - "bundleIdentifier": "com.stik.sj", - "developerName": "Stephen", - "subtitle": "An on-device JIT enabler for iOS versions 17.4+ (excluding iOS 18.4 beta 1), powered by idevice.", - "localizedDescription": "Enable JIT capabilities for your sideloaded apps.", - "iconURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", - "tintColor": "#293B45", - "screenshots": [ - "https://github.com/0-Blu/StikJIT/blob/main/assets/views/dark/HomeScreen.PNG?raw=true", - "https://github.com/0-Blu/StikJIT/blob/main/assets/views/dark/AppsList.PNG?raw=true", - "https://github.com/0-Blu/StikJIT/blob/main/assets/views/dark/Settings.PNG?raw=true" - ], - "versions": [ - { - "version": "1.3.1", - "date": "2025-04-14T12:00:00-05:00", - "size": 6211010, - "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.3.1/StikJIT_1.3.1.ipa", - "localizedDescription": "Bug fixes - no wifi error, make -9 error more clear, fix -17 error", - "minOSVersion": "17.4" + "name": "StikJIT Repository", + "identifier": "com.stik.sj", + "subtitle": "AltStore/SideStore compatible source repository for StikJIT.", + "iconURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", + "headerURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", + "tintColor": "#293B45", + "featuredApps": [ + "com.stik.sj" + ], + "apps": [ + { + "name": "StikJIT", + "bundleIdentifier": "com.stik.sj", + "developerName": "Stephen", + "subtitle": "An on-device JIT enabler for iOS versions 17.4+ (excluding iOS 18.4 beta 1), powered by idevice.", + "localizedDescription": "Enable JIT capabilities for your sideloaded apps.", + "iconURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", + "tintColor": "#293B45", + "screenshots": [ + "https://github.com/0-Blu/StikJIT/blob/main/assets/views/dark/HomeScreen.PNG?raw=true", + "https://github.com/0-Blu/StikJIT/blob/main/assets/views/dark/AppsList.PNG?raw=true", + "https://github.com/0-Blu/StikJIT/blob/main/assets/views/dark/Settings.PNG?raw=true" + ], + "versions": [ + { + "version": "1.3.1", + "date": "2025-04-14T12:00:00-05:00", + "size": 6211010, + "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.3.1/StikJIT_1.3.1.ipa", + "localizedDescription": "Bug fixes - no wifi error, make -9 error more clear, fix -17 error", + "minOSVersion": "17.4" + }, + { + "version": "1.3", + "date": "2025-04-12", + "size": 6210215, + "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.3/StikJIT.ipa", + "localizedDescription": "Enhanced & Advanced: Improved performance: Fixes disk image unbounting in the background, DNS Blocker Check, UI tweaks: custom accent color picker, more logs." }, { - "version": "1.3", - "date": "2025-04-12", - "size": 6210215, - "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.3/StikJIT.ipa", - "localizedDescription": "Enhanced & Advanced: Improved performance: Fixes disk image unbounting in the background, DNS Blocker Check, UI tweaks: custom accent color picker, more logs." - }, - { - "version": "1.2", - "date": "2025-04-07", - "localizedDescription": "Smooth Sailing: Improved performance: Prevented UI stutter in App List. UI tweaks: Light theme for notifications, better aligned UI elements, expanded theming support, fixed user feedback when get-task-allow is missing.", - "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.2/StikJit_1.2.ipa", - "size": 5922690 - }, - { - "version": "1.1", - "date": "2025-04-01", - "localizedDescription": "Bug fixes and UI improvements. Enhanced system log viewer and better error handling.", - "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.1/StikJit_1.1.ipa", - "size": 5800000 - }, - { - "version": "1.0", - "date": "2025-03-26", - "localizedDescription": "Initial release of StikJIT", - "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.0/StikJit_1.0.ipa", - "size": 5000000 - } - ], - "appPermissions": { - "entitlements": [ - ], - "privacy": { + "version": "1.2", + "date": "2025-04-07", + "localizedDescription": "Smooth Sailing: Improved performance: Prevented UI stutter in App List. UI tweaks: Light theme for notifications, better aligned UI elements, expanded theming support, fixed user feedback when get-task-allow is missing.", + "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.2/StikJit_1.2.ipa", + "size": 5922690 + }, + { + "version": "1.1", + "date": "2025-04-01", + "localizedDescription": "Bug fixes and UI improvements. Enhanced system log viewer and better error handling.", + "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.1/StikJit_1.1.ipa", + "size": 5800000 + }, + { + "version": "1.0", + "date": "2025-03-26", + "localizedDescription": "Initial release of StikJIT", + "downloadURL": "https://github.com/0-Blu/StikJIT/releases/download/1.0/StikJit_1.0.ipa", + "size": 5000000 } + ], + "appPermissions": { + "entitlements": [ + ], + "privacy": { + } + } } - } - ], - "news": [ - ] -} \ No newline at end of file + ], + "news": [ + ] +} From 702a10795b84a8a29156ee28dc41db9cb8a35b0c Mon Sep 17 00:00:00 2001 From: neoarz Date: Mon, 14 Apr 2025 22:49:17 -0400 Subject: [PATCH 12/14] start --- .github/workflows/updatesource.yml | 22 ++++++++++++++++++++++ update_json.py | 18 ++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 .github/workflows/updatesource.yml create mode 100644 update_json.py diff --git a/.github/workflows/updatesource.yml b/.github/workflows/updatesource.yml new file mode 100644 index 0000000..4ad6ed6 --- /dev/null +++ b/.github/workflows/updatesource.yml @@ -0,0 +1,22 @@ +name: Update StikJIT Source + +on: + release: + types: [published] + workflow_dispatch: + +# Add permissions block to ensure the workflow can push changes +permissions: + contents: write + +jobs: + update-source: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + repository: 0-Blu/StikJIT + ref: main + \ No newline at end of file diff --git a/update_json.py b/update_json.py new file mode 100644 index 0000000..b118a81 --- /dev/null +++ b/update_json.py @@ -0,0 +1,18 @@ +import json +import re +import requests +import os +import sys +from datetime import datetime + +def prepare_description(text): + text = re.sub('<[^<]+?>', '', text) # Remove HTML tags + text = re.sub(r'#{1,6}\s?', '', text) # Remove markdown header tags + text = re.sub(r'\*{2}', '', text) # Remove all occurrences of two consecutive asterisks + text = re.sub(r'(?<=\r|\n)-', '•', text) # Only replace - with • if it is preceded by \r or \n + text = re.sub(r'`', '"', text) # Replace ` with " + text = re.sub(r'\r\n\r\n', '\r \n', text) # Replace \r\n\r\n with \r \n (avoid incorrect display of the description regarding paragraphs) + return text + + + From f7998d3e514903c3f9f2f37c74bf676dc1cc02ad Mon Sep 17 00:00:00 2001 From: neo <164915254+neoarz@users.noreply.github.com> Date: Tue, 15 Apr 2025 11:16:04 -0400 Subject: [PATCH 13/14] Update update_json.py --- update_json.py | 172 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) diff --git a/update_json.py b/update_json.py index b118a81..0087e23 100644 --- a/update_json.py +++ b/update_json.py @@ -14,5 +14,177 @@ def prepare_description(text): text = re.sub(r'\r\n\r\n', '\r \n', text) # Replace \r\n\r\n with \r \n (avoid incorrect display of the description regarding paragraphs) return text +def fetch_latest_release(repo_url): + api_url = f"https://api.github.com/repos/{repo_url}/releases" + headers = { + "Accept": "application/vnd.github+json", + } + try: + print(f"Fetching releases from: {api_url}") + response = requests.get(api_url, headers=headers) + response.raise_for_status() + releases = response.json() + if not releases: + print("No releases found in the repository") + return None + print(f"Found {len(releases)} releases") + print(f"Latest release: {releases[0]['tag_name']}") + return releases + except requests.RequestException as e: + print(f"Error fetching releases: {e}") + return None +def get_file_size(url): + try: + response = requests.head(url) + response.raise_for_status() + return int(response.headers.get('Content-Length', 0)) + except requests.RequestException as e: + print(f"Error getting file size: {e}") + return 0 +def update_json_file(json_file, latest_release): + if isinstance(latest_release, list) and latest_release: + latest_release = latest_release[0] + else: + print("Error getting latest release") + return False + + try: + print(f"Reading JSON file: {json_file}") + with open(json_file, "r") as file: + data = json.load(file) + except json.JSONDecodeError as e: + print(f"Error reading JSON file: {e}") + return False + except FileNotFoundError: + print(f"File {json_file} not found") + return False + + app = data["apps"][0] + current_version = app.get("version", "unknown") + print(f"Current version in repo.json: {current_version}") + + full_version = latest_release["tag_name"] + tag = latest_release["tag_name"] + version_match = re.search(r"(\d+\.\d+\.\d+)", full_version) + if not version_match: + print(f"Could not extract version from tag: {full_version}") + return False + + version = version_match.group(1) + print(f"Latest release version: {version}") + + # Check if the version is already in the versions list + existing_versions = [v["version"] for v in app["versions"]] + print(f"Existing versions: {existing_versions}") + + if version in existing_versions and version == current_version: + print(f"Version {version} already exists and is current, no update needed") + return False + + version_date = latest_release["published_at"] + date_obj = datetime.strptime(version_date, "%Y-%m-%dT%H:%M:%SZ") + version_date = date_obj.strftime("%Y-%m-%d") + + description = latest_release["body"] or "No description provided" + description = prepare_description(description) + + assets = latest_release.get("assets", []) + print(f"Found {len(assets)} assets in the release") + for asset in assets: + print(f"Asset: {asset['name']}") + + download_url = None + size = None + for asset in assets: + if asset["name"].endswith(".ipa"): + download_url = asset["browser_download_url"] + size = asset["size"] + print(f"Found IPA file: {asset['name']}, size: {size}") + break + + if download_url is None or size is None: + print("Error: IPA file not found in release assets.") + return False + + version_entry = { + "version": version, + "date": version_date, + "localizedDescription": description, + "downloadURL": download_url, + "size": size, + "minOSVersion": "17.4" # Adding minOSVersion for StikJIT + } + + # Always update with the latest version + print(f"Adding new version entry: {version}") + app["versions"].insert(0, version_entry) + + print(f"Updating app with version {version}") + app.update({ + "version": version, + "versionDate": version_date, + "versionDescription": description, + "downloadURL": download_url, + "size": size + }) + + if "news" not in data: + data["news"] = [] + + news_identifier = f"release-{full_version}" + date_string = date_obj.strftime("%d/%m/%y") + news_entry = { + "appID": "com.stik.sj", + "caption": f"Update of StikJIT just got released!", + "date": latest_release["published_at"], + "identifier": news_identifier, + "imageURL": "https://github.com/0-Blu/StikJIT/blob/main/assets/StikJIT.png?raw=true", + "notify": True, + "tintColor": "#293B45", + "title": f"{full_version} - StikJIT {date_string}", + "url": f"https://github.com/0-Blu/StikJIT/releases/tag/{tag}" + } + + news_entry_exists = any(item["identifier"] == news_identifier for item in data["news"]) + if not news_entry_exists: + print(f"Adding news entry for version {full_version}") + data["news"].append(news_entry) + else: + print(f"News entry for version {full_version} already exists") + + try: + print(f"Writing updated JSON to {json_file}") + with open(json_file, "w") as file: + json.dump(data, file, indent=2) + print("JSON file updated successfully.") + return True + except IOError as e: + print(f"Error writing to JSON file: {e}") + return False + +def main(): + # Use the original repository instead of fork + repo_url = "0-Blu/StikJIT" + json_file = "repo.json" + + print(f"Using repository: {repo_url}") + print(f"Updating file: {json_file}") + + try: + fetched_data_latest = fetch_latest_release(repo_url) + if fetched_data_latest: + success = update_json_file(json_file, fetched_data_latest) + if not success: + print("Failed to update JSON file or no changes were needed") + sys.exit(0) # Exit with success code since no changes needed is not an error + else: + print("No releases found to update") + sys.exit(1) + except Exception as e: + print(f"An error occurred: {e}") + sys.exit(1) + +if __name__ == "__main__": + main() From 8e5029a2671e578051101606f2e69379e178b92c Mon Sep 17 00:00:00 2001 From: neo <164915254+neoarz@users.noreply.github.com> Date: Tue, 15 Apr 2025 11:16:30 -0400 Subject: [PATCH 14/14] Update updatesource.yml --- .github/workflows/updatesource.yml | 84 +++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/.github/workflows/updatesource.yml b/.github/workflows/updatesource.yml index 4ad6ed6..123aaa3 100644 --- a/.github/workflows/updatesource.yml +++ b/.github/workflows/updatesource.yml @@ -19,4 +19,86 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} repository: 0-Blu/StikJIT ref: main - \ No newline at end of file + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install requests + + - name: Record job start time + id: job_start_time + run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT + + - name: Debug repository information + run: | + echo "Repository: 0-Blu/StikJIT" + echo "Event name: $GITHUB_EVENT_NAME" + echo "Current directory: $(pwd)" + echo "Repository contents:" + ls -la + + - name: Update StikJIT source + id: update_source + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Configure git + git config --global user.name 'GitHub Action' + git config --global user.email 'action@github.com' + + # Run the update script + python update_json.py + + # Check for changes and commit if needed + git add repo.json + if git diff --staged --quiet; then + echo "changes=false" >> $GITHUB_OUTPUT + echo "No changes detected in repo.json" + else + echo "Changes detected in repo.json:" + git diff --staged + git commit -m "Updated source with latest StikJIT release" + # Push to main branch of original repository + git push origin main + echo "changes=true" >> $GITHUB_OUTPUT + fi + + - name: Calculate job duration + id: duration + if: always() + run: | + end_time=$(date +%s) + duration=$((end_time - ${{ steps.job_start_time.outputs.start_time }})) + echo "duration=$duration seconds" >> $GITHUB_OUTPUT + + - name: Create job summary + run: | + if [[ "${{ steps.update_source.outputs.changes }}" == "true" ]]; then + echo "## Update StikJIT Source Summary 🚀" >> $GITHUB_STEP_SUMMARY + echo "✅ Changes Detected and Pushed" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "The repo.json file has been updated with the latest release information." >> $GITHUB_STEP_SUMMARY + else + echo "## Update StikJIT Source Summary 🚀" >> $GITHUB_STEP_SUMMARY + echo "🔍 No Changes Detected" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "The repo.json file is up to date. No changes were necessary." >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "This could be because:" >> $GITHUB_STEP_SUMMARY + echo "- The release version is already in the repo.json file" >> $GITHUB_STEP_SUMMARY + echo "- The release doesn't contain an IPA file" >> $GITHUB_STEP_SUMMARY + echo "- The release tag doesn't match the expected version format" >> $GITHUB_STEP_SUMMARY + fi + echo "" >> $GITHUB_STEP_SUMMARY + echo "🕐 Execution Time" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "This job took ${{ steps.duration.outputs.duration }} to complete." >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "📆 Next Scheduled Run" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "The next scheduled run will be triggered when a new release is published." >> $GITHUB_STEP_SUMMARY