From e632c150da352e3531d48c842826ee9b7b8ef4b2 Mon Sep 17 00:00:00 2001 From: Joachim Schmitz Date: Thu, 22 Aug 2024 11:29:12 +0200 Subject: [PATCH] More CI updates 'stolen' from master --- .github/workflows/deploy.yml | 1 - .github/workflows/update_release_info.yml | 80 ++++++++++++++ build/ci/linux/tools/make_appimage.sh | 0 build/ci/lupdate/publish_to_tx.sh | 0 build/ci/lupdate/run_lupdate.sh | 0 build/ci/lupdate/setup.sh | 0 build/ci/macos/build.sh | 0 build/ci/macos/checkcodestyle.sh | 0 build/ci/macos/notarize.sh | 0 build/ci/macos/package.sh | 0 build/ci/macos/setup.sh | 0 .../append_release_to_previous_releases.py | 62 +++++++++++ build/ci/release/collate_release_binaries.sh | 0 build/ci/release/correct_release_info.py | 102 ++++++++++++++++++ build/ci/release/get_file_from_s3.sh | 64 +++++++++++ .../release/make_empty_release_info_file.sh | 26 +++++ .../release/make_previous_releases_notes.sh | 57 ++++++++++ build/ci/release/make_release_info_file.sh | 56 ++++++++++ build/ci/release/make_tag_name.sh | 0 build/ci/release/push_file_to_s3.sh | 64 +++++++++++ build/ci/tools/checksum.sh | 0 build/ci/tools/make_artifact_name_env.sh | 0 build/ci/tools/make_branch_env.sh | 0 build/ci/tools/make_build_mode_env.sh | 0 build/ci/tools/make_datetime_env.sh | 0 build/ci/tools/make_release_channel_env.sh | 0 build/ci/tools/make_revision_env.sh | 0 build/ci/tools/make_version_env.sh | 0 build/ci/tools/osuosl/publish.sh | 0 build/ci/tools/sparkle_appcast_gen.sh | 0 build/packaging/FileAssociation.nsh | 0 build/travis/job1_Tests/environment.sh | 0 thirdparty/freetype/builds/unix/ltmain.sh | 0 33 files changed, 511 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/update_release_info.yml mode change 100644 => 100755 build/ci/linux/tools/make_appimage.sh mode change 100644 => 100755 build/ci/lupdate/publish_to_tx.sh mode change 100644 => 100755 build/ci/lupdate/run_lupdate.sh mode change 100644 => 100755 build/ci/lupdate/setup.sh mode change 100644 => 100755 build/ci/macos/build.sh mode change 100644 => 100755 build/ci/macos/checkcodestyle.sh mode change 100644 => 100755 build/ci/macos/notarize.sh mode change 100644 => 100755 build/ci/macos/package.sh mode change 100644 => 100755 build/ci/macos/setup.sh create mode 100755 build/ci/release/append_release_to_previous_releases.py mode change 100644 => 100755 build/ci/release/collate_release_binaries.sh create mode 100755 build/ci/release/correct_release_info.py create mode 100755 build/ci/release/get_file_from_s3.sh create mode 100755 build/ci/release/make_empty_release_info_file.sh create mode 100755 build/ci/release/make_previous_releases_notes.sh create mode 100755 build/ci/release/make_release_info_file.sh mode change 100644 => 100755 build/ci/release/make_tag_name.sh create mode 100755 build/ci/release/push_file_to_s3.sh mode change 100644 => 100755 build/ci/tools/checksum.sh mode change 100644 => 100755 build/ci/tools/make_artifact_name_env.sh mode change 100644 => 100755 build/ci/tools/make_branch_env.sh mode change 100644 => 100755 build/ci/tools/make_build_mode_env.sh mode change 100644 => 100755 build/ci/tools/make_datetime_env.sh mode change 100644 => 100755 build/ci/tools/make_release_channel_env.sh mode change 100644 => 100755 build/ci/tools/make_revision_env.sh mode change 100644 => 100755 build/ci/tools/make_version_env.sh mode change 100644 => 100755 build/ci/tools/osuosl/publish.sh mode change 100644 => 100755 build/ci/tools/sparkle_appcast_gen.sh mode change 100644 => 100755 build/packaging/FileAssociation.nsh mode change 100644 => 100755 build/travis/job1_Tests/environment.sh mode change 100644 => 100755 thirdparty/freetype/builds/unix/ltmain.sh diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6849cd1fede84..59c8ce66d9061 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -64,7 +64,6 @@ jobs: name: 'Create release: ${{ needs.get_tag_info.outputs.tag_name }}' needs: - get_tag_info # to access outputs - - update_learn_playlists if: ${{ ! failure() && ! cancelled() && inputs.create_tag }} # run even if prior jobs were skipped runs-on: ubuntu-latest environment: diff --git a/.github/workflows/update_release_info.yml b/.github/workflows/update_release_info.yml new file mode 100644 index 0000000000000..b96aa3bbbb87b --- /dev/null +++ b/.github/workflows/update_release_info.yml @@ -0,0 +1,80 @@ +name: 'Update: Release Info' + +on: + workflow_dispatch: + inputs: + mode: + description: 'Mode: stable, testing (alpha, beta, rc)' + default: 'testing' + required: true + tag: + description: 'Release tag (latest stable by default)' + required: false + workflow_call: + inputs: + mode: + description: 'Mode: stable, testing (alpha, beta, rc)' + default: 'testing' + type: string + required: true + tag: + description: 'Release tag (latest stable by default)' + type: string + required: false + environment: + description: "Environment: use 'production' to prompt for approval" + default: '' + type: string + required: false + +defaults: + run: + shell: bash + +jobs: + update-release-info: + runs-on: ubuntu-20.04 + environment: + name: ${{ inputs.environment }} # can be empty/blank (if so, URL will not be shown) + url: ${{ github.server_url }}/${{ github.repository }}/releases/${{ inputs.tag && format('tag/{0}', inputs.tag) || 'latest' }} # show on run page + steps: + - name: Clone repository + uses: actions/checkout@v4 + + - name: Update info about the release in musescore-updates + if: ${{ false }} + run: | + S3_URL="s3://musescore-updates/feed/latest.xml" + S3_ALL_URL="s3://musescore-updates/feed/all.xml" + + if [ ${{ inputs.mode }} == "testing" ]; then + S3_URL="s3://musescore-updates/feed/latest.test.xml" + S3_ALL_URL="s3://musescore-updates/feed/all.test.xml" + fi + + sudo bash ./build/ci/release/make_release_info_file.sh \ + --token ${{ secrets.GITHUB_TOKEN }} \ + --repo ${{ github.repository }} \ + --release_tag ${{ inputs.tag }} + + sudo bash ./build/ci/release/push_file_to_s3.sh \ + --s3_key ${{ secrets.S3_KEY_UPDATE }} \ + --s3_secret ${{ secrets.S3_SECRET_UPDATE }} \ + --s3_url ${S3_URL} \ + --s3_bucket ${{ secrets.S3_BUCKET_UPDATE }} \ + --file_name "release_info.json" + + sudo bash ./build/ci/release/make_previous_releases_notes.sh \ + --s3_key ${{ secrets.S3_KEY_UPDATE }} \ + --s3_secret ${{ secrets.S3_SECRET_UPDATE }} \ + --s3_url ${S3_ALL_URL} \ + --s3_bucket ${{ secrets.S3_BUCKET_UPDATE }} \ + --current_file_name "release_info.json" \ + --previous_file_name "previous_releases_notes.json" + + sudo bash ./build/ci/release/push_file_to_s3.sh \ + --s3_key ${{ secrets.S3_KEY_UPDATE }} \ + --s3_secret ${{ secrets.S3_SECRET_UPDATE }} \ + --s3_url ${S3_ALL_URL} \ + --s3_bucket ${{ secrets.S3_BUCKET_UPDATE }} \ + --file_name "previous_releases_notes.json" diff --git a/build/ci/linux/tools/make_appimage.sh b/build/ci/linux/tools/make_appimage.sh old mode 100644 new mode 100755 diff --git a/build/ci/lupdate/publish_to_tx.sh b/build/ci/lupdate/publish_to_tx.sh old mode 100644 new mode 100755 diff --git a/build/ci/lupdate/run_lupdate.sh b/build/ci/lupdate/run_lupdate.sh old mode 100644 new mode 100755 diff --git a/build/ci/lupdate/setup.sh b/build/ci/lupdate/setup.sh old mode 100644 new mode 100755 diff --git a/build/ci/macos/build.sh b/build/ci/macos/build.sh old mode 100644 new mode 100755 diff --git a/build/ci/macos/checkcodestyle.sh b/build/ci/macos/checkcodestyle.sh old mode 100644 new mode 100755 diff --git a/build/ci/macos/notarize.sh b/build/ci/macos/notarize.sh old mode 100644 new mode 100755 diff --git a/build/ci/macos/package.sh b/build/ci/macos/package.sh old mode 100644 new mode 100755 diff --git a/build/ci/macos/setup.sh b/build/ci/macos/setup.sh old mode 100644 new mode 100755 diff --git a/build/ci/release/append_release_to_previous_releases.py b/build/ci/release/append_release_to_previous_releases.py new file mode 100755 index 0000000000000..19eb98b06c1e2 --- /dev/null +++ b/build/ci/release/append_release_to_previous_releases.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-3.0-only +# MuseScore-Studio-CLA-applies +# +# MuseScore Studio +# Music Composition & Notation +# +# Copyright (C) 2024 MuseScore Limited +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import sys +import json + +CURRENT_RELEASE_INFO_FILE = sys.argv[1] +PREVIOUS_RELEASE_INFO_FILE = sys.argv[2] + +print("=== Load jsons ===") + +json_file = open(CURRENT_RELEASE_INFO_FILE, "r+") +current_release_info_json = json.load(json_file) +json_file.close() + +json_file = open(PREVIOUS_RELEASE_INFO_FILE, "r+") +previous_release_info_json = json.load(json_file) +json_file.close() + +print("=== Append current release notes to previous releases notes ===") + +tag_name = current_release_info_json["tag_name"] +version = tag_name[1:] +new_release = {"version": version, "notes": current_release_info_json["bodyMarkdown"]} + +if "releases" not in previous_release_info_json: + previous_release_info_json["releases"] = [] + +is_release_already_in_previous_releases = False +for release in previous_release_info_json["releases"]: + if release["version"] in version: + release["notes"] = new_release["notes"] + is_release_already_in_previous_releases = True + +if not is_release_already_in_previous_releases: + previous_release_info_json["releases"].append(new_release) + +previous_release_info_json_updated = json.dumps(previous_release_info_json) + +print("=== Write json ===") + +json_file = open(PREVIOUS_RELEASE_INFO_FILE, "w") +json_file.write(previous_release_info_json_updated) +json_file.close() diff --git a/build/ci/release/collate_release_binaries.sh b/build/ci/release/collate_release_binaries.sh old mode 100644 new mode 100755 diff --git a/build/ci/release/correct_release_info.py b/build/ci/release/correct_release_info.py new file mode 100755 index 0000000000000..3cc6efc70b8d5 --- /dev/null +++ b/build/ci/release/correct_release_info.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-3.0-only +# MuseScore-Studio-CLA-applies +# +# MuseScore Studio +# Music Composition & Notation +# +# Copyright (C) 2021 MuseScore Limited +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import sys +def eprint(*args, **kwargs): + print(*args, **kwargs, file=sys.stderr) + +if __name__ == '__main__' and sys.prefix == sys.base_prefix: + # Not running inside a virtual environment. Let's try to load one. + import os + old_dir = os.path.realpath(__file__) + new_dir, script_name = os.path.split(old_dir) + rel_pyi = r'.venv\Scripts\python.exe' if sys.platform == 'win32' else '.venv/bin/python' + while new_dir != old_dir: + abs_pyi = os.path.join(new_dir, rel_pyi) + if os.access(abs_pyi, os.X_OK): + eprint(f'{script_name}: Loading virtual environment:\n {abs_pyi}') + if sys.platform == 'win32': + import subprocess + raise SystemExit(subprocess.run([abs_pyi, *sys.argv]).returncode) + os.execl(abs_pyi, abs_pyi, *sys.argv) + old_dir = new_dir + new_dir = os.path.dirname(new_dir) + eprint(f'{script_name}: Not running inside a virtual environment.') + del old_dir, new_dir, rel_pyi, abs_pyi, script_name + +import sys +import json +import markdown + +RELEASE_INFO_FILE = sys.argv[1] + +eprint("=== Load json ===") + +json_file = open(RELEASE_INFO_FILE, "r+") +release_info_json = json.load(json_file) +json_file.close() + +eprint("=== Make html version of body ===") + +release_body_markdown = release_info_json["body"] + +release_body_html = markdown.markdown(release_body_markdown) + +# Correct result of Markdown parser +# Escape single quotes +release_body_html = release_body_html.replace("'", "`") + +# Correct new lines next to
    and
+release_body_html = release_body_html.replace("\n
    \n", "
      ") +release_body_html = release_body_html.replace("\n
    \n", "
") + +release_info_json["body"] = "'" + release_body_html + "'" +release_info_json["bodyMarkdown"] = release_body_markdown + +eprint("=== Split release assets ===") + +# For backward compatibility, we must adhere to the rule: +# for each platform, there should be one file with the corresponding extension. +# Let's place the new files into a new field with separate handling in MuseScore. + +release_assets = release_info_json["assets"] +release_new_assets = [] + +i = 0 +while i < len(release_assets): + asset = release_assets[i] + name = asset.get("name") + if ".AppImage" in name and ("aarch64" in name or "armv7l" in name): + release_new_assets.append(asset) + del release_assets[i] + else: + i += 1 + +release_info_json["assets"] = release_assets +release_info_json["assetsNew"] = release_new_assets + +release_info_json_updated = json.dumps(release_info_json) + +eprint("=== Write json ===") + +json_file = open(RELEASE_INFO_FILE, "w") +json_file.write(release_info_json_updated) +json_file.close() diff --git a/build/ci/release/get_file_from_s3.sh b/build/ci/release/get_file_from_s3.sh new file mode 100755 index 0000000000000..1de9d486426ef --- /dev/null +++ b/build/ci/release/get_file_from_s3.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-only +# MuseScore-Studio-CLA-applies +# +# MuseScore Studio +# Music Composition & Notation +# +# Copyright (C) 2024 MuseScore Limited +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +ARTIFACTS_DIR=build.artifacts + +S3_KEY="" +S3_SECRET="" +S3_URL="" +S3_BUCKET="" + +LOCAL_FILE_NAME="" + +while [[ "$#" -gt 0 ]]; do + case $1 in + --s3_key) S3_KEY="$2"; shift ;; + --s3_secret) S3_SECRET="$2"; shift ;; + --s3_url) S3_URL="$2"; shift ;; + --s3_bucket) S3_BUCKET="$2"; shift ;; + --local_file_name) LOCAL_FILE_NAME="$2"; shift ;; + *) echo "Unknown parameter passed: $1"; exit 1 ;; + esac + shift +done + +command -v s3cmd >/dev/null 2>&1 +if [[ $? -ne 0 ]]; then + echo "=== Install tools ===" + + apt install python3-setuptools + + echo "Install s3cmd" + pip3 install s3cmd +fi + +cat >~/.s3cfg <. + +ARTIFACTS_DIR=build.artifacts + +mkdir -p $ARTIFACTS_DIR +echo "" > $ARTIFACTS_DIR/release_info.json +cat $ARTIFACTS_DIR/release_info.json diff --git a/build/ci/release/make_previous_releases_notes.sh b/build/ci/release/make_previous_releases_notes.sh new file mode 100755 index 0000000000000..e819c7a22ffa2 --- /dev/null +++ b/build/ci/release/make_previous_releases_notes.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-only +# MuseScore-Studio-CLA-applies +# +# MuseScore Studio +# Music Composition & Notation +# +# Copyright (C) 2024 MuseScore Limited +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +ARTIFACTS_DIR=build.artifacts + +S3_KEY="" +S3_SECRET="" +S3_URL="" +S3_BUCKET="" + +CURRENT_FILE_NAME="" +PREVIOUS_FILE_NAME="" + +while [[ "$#" -gt 0 ]]; do + case $1 in + --s3_key) S3_KEY="$2"; shift ;; + --s3_secret) S3_SECRET="$2"; shift ;; + --s3_url) S3_URL="$2"; shift ;; + --s3_bucket) S3_BUCKET="$2"; shift ;; + --current_file_name) CURRENT_FILE_NAME="$2"; shift ;; + --previous_file_name) PREVIOUS_FILE_NAME="$2"; shift ;; + *) echo "Unknown parameter passed: $1"; exit 1 ;; + esac + shift +done + +echo "=== Get release info ===" + +sudo bash ./buildscripts/ci/release/get_file_from_s3.sh \ + --s3_key "${S3_KEY}" \ + --s3_secret "${S3_SECRET}" \ + --s3_url "${S3_URL}" \ + --s3_bucket "${S3_BUCKET}" \ + --local_file_name "${PREVIOUS_FILE_NAME}" + +echo "=== Append release info to previous releases ===" + +HERE="$(cd "$(dirname "$0")" && pwd)" +python3 "$HERE"/append_release_to_previous_releases.py ${ARTIFACTS_DIR}/"${CURRENT_FILE_NAME}" ${ARTIFACTS_DIR}/"${PREVIOUS_FILE_NAME}" \ No newline at end of file diff --git a/build/ci/release/make_release_info_file.sh b/build/ci/release/make_release_info_file.sh new file mode 100755 index 0000000000000..a19e3e2fb448d --- /dev/null +++ b/build/ci/release/make_release_info_file.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-only +# MuseScore-Studio-CLA-applies +# +# MuseScore Studio +# Music Composition & Notation +# +# Copyright (C) 2021 MuseScore Limited +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +ARTIFACTS_DIR=build.artifacts + +GITHUB_TOKEN="" +GITHUB_REPOSITORY="" + +RELEASE_TAG="" + +while [[ "$#" -gt 0 ]]; do + case $1 in + --token) GITHUB_TOKEN="$2"; shift ;; + --repo) GITHUB_REPOSITORY="$2"; shift ;; + --release_tag) RELEASE_TAG="$2"; shift ;; + *) echo "Unknown parameter passed: $1"; exit 1 ;; + esac + shift +done + +echo "=== Get release info ===" + +RELEASE_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/latest" +if [ ! -z "$RELEASE_TAG" ]; then RELEASE_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${RELEASE_TAG}"; fi + +RELEASE_INFO=$(curl \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + $RELEASE_URL) + +mkdir -p $ARTIFACTS_DIR +echo $RELEASE_INFO > $ARTIFACTS_DIR/release_info.json +cat $ARTIFACTS_DIR/release_info.json + +pip install markdown + +HERE="$(cd "$(dirname "$0")" && pwd)" +python3 $HERE/correct_release_info.py ${ARTIFACTS_DIR}/release_info.json diff --git a/build/ci/release/make_tag_name.sh b/build/ci/release/make_tag_name.sh old mode 100644 new mode 100755 diff --git a/build/ci/release/push_file_to_s3.sh b/build/ci/release/push_file_to_s3.sh new file mode 100755 index 0000000000000..37dd616f995d1 --- /dev/null +++ b/build/ci/release/push_file_to_s3.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-only +# MuseScore-Studio-CLA-applies +# +# MuseScore Studio +# Music Composition & Notation +# +# Copyright (C) 2021 MuseScore Limited +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +ARTIFACTS_DIR=build.artifacts + +S3_KEY="" +S3_SECRET="" +S3_URL="" +S3_BUCKET="" + +FILE_NAME="" + +while [[ "$#" -gt 0 ]]; do + case $1 in + --s3_key) S3_KEY="$2"; shift ;; + --s3_secret) S3_SECRET="$2"; shift ;; + --s3_url) S3_URL="$2"; shift ;; + --s3_bucket) S3_BUCKET="$2"; shift ;; + --file_name) FILE_NAME="$2"; shift ;; + *) echo "Unknown parameter passed: $1"; exit 1 ;; + esac + shift +done + +command -v s3cmd >/dev/null 2>&1 +if [[ $? -ne 0 ]]; then + echo "=== Install tools ===" + + apt install python3-setuptools + + echo "Install s3cmd" + pip3 install s3cmd +fi + +cat >~/.s3cfg <