From 83945ff0a06144c7e2a7249024434a675603f7fc Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 16 Mar 2023 15:02:42 +0000 Subject: [PATCH 1/2] Do not update release channels if the new build has a lower version ID this prevents stuff like 5.0.0 beta versions getting overwritten by 4.x beta versions. --- .github/workflows/update-updater-api.yml | 39 ++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-updater-api.yml b/.github/workflows/update-updater-api.yml index 906278ef3..c8f73ea15 100644 --- a/.github/workflows/update-updater-api.yml +++ b/.github/workflows/update-updater-api.yml @@ -41,9 +41,42 @@ jobs: - name: Update channel info run: | - cp new_build_info.json "channels/${{ steps.channel.outputs.CHANNEL }}.json" - cp new_build_info.json "channels/${{ steps.channel.outputs.MAJOR }}.json" - cp new_build_info.json "channels/${{ steps.channel.outputs.MINOR }}.json" + function version_id() { + major=$(echo $1 | cut -d. -f1) + minor=$(echo $1 | cut -d. -f2) + patch=$(echo $1 | cut -d. -f3) + echo $(((major * 1000000) + (minor * 1000) + patch)) + } + + function update_channel() { + local target_file_name="$1" + local new_file_name="$2" + + local old_version_id + local new_version_id + + if [ ! -f "$target_file_name" ]; then + echo "Creating channel file: $target_file_name" + cp "$new_file_name" "$target_file_name" + else + old_version_id=$(version_id "$(jq -r '.base_version' "$target_file_name")") + new_version_id=$(version_id "$(jq -r '.base_version' "$new_file_name")") + + echo "Old version ID: $old_version_id" + echo "New version ID: $new_version_id" + + if [ $new_version_id -ge $old_version_id ]; then #suffixed versions will have the same version ID - assume they'll always be newer + echo "Updating channel file: $target_file_name ($old_version_id -> $new_version_id)" + cp "$new_file_name" "$target_file_name" + else + echo "Version $new_version_id is less than $old_version_id, not updating channel file: $target_file_name" + fi + fi + } + + update_channel "channels/${{ steps.channel.outputs.CHANNEL }}.json" "new_build_info.json" + update_channel "channels/${{ steps.channel.outputs.MAJOR }}.json" "new_build_info.json" + update_channel "channels/${{ steps.channel.outputs.MINOR }}.json" "new_build_info.json" rm new_build_info.json - name: Commit changes From 9caed104882cba0a26cacbc95f612251595c2264 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 16 Mar 2023 15:03:14 +0000 Subject: [PATCH 2/2] update-updater-api: use github.repository_owner to make fork testing of this workflow less obnoxious --- .github/workflows/update-updater-api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-updater-api.yml b/.github/workflows/update-updater-api.yml index c8f73ea15..d3a400136 100644 --- a/.github/workflows/update-updater-api.yml +++ b/.github/workflows/update-updater-api.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v3 with: - repository: pmmp/update.pmmp.io + repository: ${{ github.repository_owner }}/update.pmmp.io ssh-key: ${{ secrets.UPDATE_PMMP_IO_DEPLOY_KEY }} - name: Get actual tag name