[CI]: updated nightly workflow to match apps-v2

This commit is contained in:
Magesh K
2024-12-30 03:24:31 +05:30
parent a547d2bc8a
commit 7ae10c6022
2 changed files with 75 additions and 43 deletions

View File

@@ -21,7 +21,9 @@ jobs:
steps: steps:
- name: Set current build as BETA - name: Set current build as BETA
run: echo "IS_BETA=1" >> $GITHUB_ENV run: |
echo "IS_BETA=1" >> $GITHUB_ENV
echo "RELEASE_CHANNEL=beta" >> $GITHUB_ENV
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -242,7 +244,6 @@ jobs:
run: | run: |
echo "VERSION_IPA=$VERSION_IPA" >> $GITHUB_ENV echo "VERSION_IPA=$VERSION_IPA" >> $GITHUB_ENV
echo "VERSION_DATE=$FORMATTED_DATE" >> $GITHUB_ENV echo "VERSION_DATE=$FORMATTED_DATE" >> $GITHUB_ENV
echo "BETA=true" >> $GITHUB_ENV
echo "COMMIT_ID=$SHORT_COMMIT" >> $GITHUB_ENV echo "COMMIT_ID=$SHORT_COMMIT" >> $GITHUB_ENV
echo "SIZE=$IPA_SIZE" >> $GITHUB_ENV echo "SIZE=$IPA_SIZE" >> $GITHUB_ENV
echo "SHA256=$SHA256_HASH" >> $GITHUB_ENV echo "SHA256=$SHA256_HASH" >> $GITHUB_ENV
@@ -269,8 +270,8 @@ jobs:
pushd SideStore/apps-v2.json/ pushd SideStore/apps-v2.json/
# Configure Git user (committer details) # Configure Git user (committer details)
# git config user.name "GitHub Actions" git config user.name "GitHub Actions"
# git config user.email "github-actions@github.com" git config user.email "github-actions@github.com"
# update the source.json # update the source.json
python3 ../../update_apps.py "./_includes/source.json" python3 ../../update_apps.py "./_includes/source.json"

View File

@@ -5,9 +5,19 @@ import json
import sys import sys
# Set environment variables with default values # Set environment variables with default values
# VERSION_IPA = os.getenv("VERSION_IPA")
# VERSION_DATE = os.getenv("VERSION_DATE")
# RELEASE_CHANNEL = os.getenv("RELEASE_CHANNEL")
# COMMIT_ID = os.getenv("COMMIT_ID")
# SIZE = os.getenv("SIZE")
# SHA256 = os.getenv("SHA256")
# LOCALIZED_DESCRIPTION = os.getenv("LOCALIZED_DESCRIPTION")
# DOWNLOAD_URL = os.getenv("DOWNLOAD_URL")
# BUNDLE_IDENTIFIER = os.getenv("BUNDLE_IDENTIFIER")
VERSION_IPA = os.getenv("VERSION_IPA", "0.0.0") VERSION_IPA = os.getenv("VERSION_IPA", "0.0.0")
VERSION_DATE = os.getenv("VERSION_DATE", "2000-12-18T00:00:00Z") VERSION_DATE = os.getenv("VERSION_DATE", "2000-12-18T00:00:00Z")
BETA = os.getenv("BETA", "true").lower() == "true" # Convert to boolean RELEASE_CHANNEL = os.getenv("RELEASE_CHANNEL", "alpha")
COMMIT_ID = os.getenv("COMMIT_ID", "1234567") COMMIT_ID = os.getenv("COMMIT_ID", "1234567")
SIZE = int(os.getenv("SIZE", "0")) # Convert to integer SIZE = int(os.getenv("SIZE", "0")) # Convert to integer
SHA256 = os.getenv("SHA256", "") SHA256 = os.getenv("SHA256", "")
@@ -24,9 +34,10 @@ input_file = sys.argv[1]
print(f"Input File: {input_file}") print(f"Input File: {input_file}")
# Debugging the environment variables # Debugging the environment variables
print(" ====> Required parameter list <====")
print("Version:", VERSION_IPA) print("Version:", VERSION_IPA)
print("Version Date:", VERSION_DATE) print("Version Date:", VERSION_DATE)
print("Beta:", BETA) print("ReleaseChannel:", RELEASE_CHANNEL)
print("Commit ID:", COMMIT_ID) print("Commit ID:", COMMIT_ID)
print("Size:", SIZE) print("Size:", SIZE)
print("Sha256:", SHA256) print("Sha256:", SHA256)
@@ -41,50 +52,70 @@ except Exception as e:
print(f"Error reading the input file: {e}") print(f"Error reading the input file: {e}")
sys.exit(1) sys.exit(1)
if (VERSION_IPA == None or \
VERSION_DATE == None or \
RELEASE_CHANNEL == None or \
SIZE == None or \
SHA256 == None or \
LOCALIZED_DESCRIPTION == None or \
DOWNLOAD_URL == None):
print("One or more required parameter(s) were not defined as environment variable(s)")
sys.exit(1)
# make it lowecase
RELEASE_CHANNEL = RELEASE_CHANNEL.lower()
# Convert to integer
SIZE = int(SIZE)
if RELEASE_CHANNEL != 'stable' and COMMIT_ID is None:
print("Commit ID cannot be empty when ReleaseChannel is not 'stable' ")
sys.exit(1)
version = data.get("version")
if int(version) < 2:
print("Only v2 and above are supported for direct updates to sources.json on push")
sys.exit(1)
# Process the JSON data # Process the JSON data
updated = False updated = False
for app in data.get("apps", []): for app in data.get("apps", []):
if app.get("bundleIdentifier") == BUNDLE_IDENTIFIER: if app.get("bundleIdentifier") == BUNDLE_IDENTIFIER:
# Update app-level metadata if RELEASE_CHANNEL == "stable" :
app.update({ # Update app-level metadata for store front page
"version": VERSION_IPA, app.update({
"versionDate": VERSION_DATE, "version": VERSION_IPA,
"beta": BETA, "versionDate": VERSION_DATE,
"commitID": COMMIT_ID, "size": SIZE,
"size": SIZE, "sha256": SHA256,
"sha256": SHA256, "localizedDescription": LOCALIZED_DESCRIPTION,
"localizedDescription": LOCALIZED_DESCRIPTION, "downloadURL": DOWNLOAD_URL,
"downloadURL": DOWNLOAD_URL, })
})
# Process the versions array # Process the versions array
versions = app.get("versions", []) channels = app.get("releaseChannels", {})
if not versions or not (versions[0].get("version") == VERSION_IPA and versions[0].get("beta") == BETA): if not channels:
# Prepend a new version if no matching version exists app["releaseChannels"] = channels
new_version = {
"version": VERSION_IPA, # create an entry and keep ready
"date": VERSION_DATE, new_version = {
"localizedDescription": LOCALIZED_DESCRIPTION, "version": VERSION_IPA,
"downloadURL": DOWNLOAD_URL, "date": VERSION_DATE,
"beta": BETA, "localizedDescription": LOCALIZED_DESCRIPTION,
"commitID": COMMIT_ID, "downloadURL": DOWNLOAD_URL,
"size": SIZE, "size": SIZE,
"sha256": SHA256, "sha256": SHA256,
} }
versions.insert(0, new_version) # add commit ID if release is not stable
if RELEASE_CHANNEL != 'stable':
new_version["commitID"] = COMMIT_ID
if not channels.get(RELEASE_CHANNEL):
# there was no entries in this release channel so create one
channels[RELEASE_CHANNEL] = [new_version]
else: else:
# Update the existing version object # Update the existing TOP version object entry
versions[0].update({ channels[RELEASE_CHANNEL][0] = new_version
"version": VERSION_IPA,
"date": VERSION_DATE,
"localizedDescription": LOCALIZED_DESCRIPTION,
"downloadURL": DOWNLOAD_URL,
"beta": BETA,
"commitID": COMMIT_ID,
"size": SIZE,
"sha256": SHA256,
})
app["versions"] = versions
updated = True updated = True
break break