Skip to content

Commit

Permalink
implement branch sync
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherHX committed Jul 11, 2023
1 parent 7ba890e commit 9b23ca1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
39 changes: 29 additions & 10 deletions .github/workflows/genminified.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,50 @@
name: Generate minified versions

on: push
on:
push:
workflow_dispatch:

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: write

strategy:
matrix:
config:
- branch: ${{ github.ref }},
# Sync branches
- branch: v0.10.x,
m: 1
codes:
armeabi-v7a: [0, 952002020],
x86: [0, 962002020],
arm64-v8a: [0, 972002020],
x86_64: [0, 982002020]
exclude:
# disable branch sync for non default branch
- config:
m: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) && 1 || -1 }}
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- uses: actions/checkout@v3
with:
ref: ${{ matrix.codes.branch }}
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.11
- name: Update files
env:
PYTHONPATH: ${{ github.workspace }}
shell: python
run: |
import versiondb
list = versiondb.VersionList('.')
list.save_minified('armeabi-v7a')
list.save_minified('x86')
list.save_minified('arm64-v8a')
list.save_minified('x86_64')
list.save_minified('armeabi-v7a', ${{ matrix.config.codes.armeabi-v7a[0] || 0 }}, ${{ matrix.config.codes.armeabi-v7a[1] || -1 }})
list.save_minified('x86', ${{ matrix.config.codes.x86[0] || 0 }}, ${{ matrix.config.codes.x86[1] || -1 }})
list.save_minified('arm64-v8a', ${{ matrix.config.codes.arm64-v8a[0] || 0 }}, ${{ matrix.config.codes.arm64-v8a[1] || -1 }})
list.save_minified('x86_64', ${{ matrix.config.codes.x86_64[0] || 0 }}, ${{ matrix.config.codes.x86_64[1] || -1 }})
- name: Update git
run: |
# from https://github.com/orgs/community/discussions/26560
Expand Down
14 changes: 8 additions & 6 deletions versiondb.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ def save(self):
with open(self.main_file, 'w') as f:
json.dump(self.versions, f, indent=4)

def save_minified(self, arch):
def save_minified(self, arch, cmin = 0, cmax = -1):
data = []
for v in self.versions:
if arch in v["codes"]:
dataObj = [v["codes"][arch], v["version_name"], 1 if ("beta" in v and v["beta"]) else 0]
# Rollforward feature of the mcpelauncher
if ("maxCodes" in v) and (arch in v["maxCodes"]):
dataObj.append(v["maxCodes"][arch])
data.append(dataObj)
code = v["codes"][arch]
if code >= cmin and (cmax == -1 or code <= cmax):
dataObj = [code, v["version_name"], 1 if ("beta" in v and v["beta"]) else 0]
# Rollforward feature of the mcpelauncher
if ("maxCodes" in v) and (arch in v["maxCodes"]):
dataObj.append(v["maxCodes"][arch])
data.append(dataObj)
with open(os.path.join(os.path.dirname(self.main_file), "versions." + arch + ".json.min"), 'w') as f:
json.dump(data, f, separators=(',',':'))

Expand Down

0 comments on commit 9b23ca1

Please sign in to comment.