From 1f0975300f908d42a36bbad0a4f985faa89d95a0 Mon Sep 17 00:00:00 2001 From: Andrey Onishchenko Date: Fri, 9 Feb 2024 17:35:17 +0300 Subject: [PATCH] Release notes --- .github/workflows/build.sh | 3 +- .github/workflows/build.yml | 5 +++ .github/workflows/retrieve_version.sh | 2 +- .github/workflows/update-build-release.yml | 12 ++++-- nix/default.nix | 2 + repack.sh | 2 + templates/PKGBUILD | 2 +- utility/extract_release_notes.py | 50 ++++++++++++++++++++++ 8 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 utility/extract_release_notes.py diff --git a/.github/workflows/build.sh b/.github/workflows/build.sh index 87c96c4..146cd20 100755 --- a/.github/workflows/build.sh +++ b/.github/workflows/build.sh @@ -16,7 +16,7 @@ case $OS in "Arch Linux") echo "Arch Linux" pacman -Syy --noconfirm - pacman -S --noconfirm git sudo base-devel p7zip nodejs jq asar electron libpulse dpkg unzip xdg-utils + pacman -S --noconfirm git sudo base-devel p7zip nodejs jq asar electron libpulse dpkg unzip xdg-utils python # fix makepkg from non-root mkdir /home/build chgrp nobody /home/build @@ -30,6 +30,7 @@ case $OS in mv *.pkg.tar.zst dist mv ./src/app/yandexmusic.asar dist/yandexmusic.asar + mv ./src/app/release_notes.json dist/release_notes.json sh ./build_deb.sh -a all mv deb/*.deb dist diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ae4aebd..e42bd3d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,6 +44,11 @@ jobs: path: ./dist/*.asar name: asar-packages + - name: Upload Release Notes + uses: actions/upload-artifact@v4 + with: + path: ./dist/release_notes.json + nix-build: runs-on: ubuntu-latest env: diff --git a/.github/workflows/retrieve_version.sh b/.github/workflows/retrieve_version.sh index 99dc854..bec049c 100644 --- a/.github/workflows/retrieve_version.sh +++ b/.github/workflows/retrieve_version.sh @@ -10,4 +10,4 @@ tag_name="v$VERSION" #write variables to github env echo "VERSION=$VERSION" >> $GITHUB_ENV echo "release_name=$release_name" >> $GITHUB_ENV -echo "tag_name=$tag_name" >> $GITHUB_ENV +echo "tag_name=$tag_name" >> $GITHUB_ENV \ No newline at end of file diff --git a/.github/workflows/update-build-release.yml b/.github/workflows/update-build-release.yml index 5c25ae4..83d9dfd 100644 --- a/.github/workflows/update-build-release.yml +++ b/.github/workflows/update-build-release.yml @@ -55,11 +55,11 @@ jobs: commit_long_sha: ${{ steps.commit.outputs.commit_long_sha }} build: - if: ${{ (github.event_name == 'push') || (github.event_name == 'workflow_dispatch') || (needs.update_packages.new_version) }} + if: ${{ (github.event_name == 'push') || (github.event_name == 'workflow_dispatch') || (needs.update_packages.outputs.new_version) }} needs: update_packages uses: ./.github/workflows/build.yml with: - ref: ${{ (needs.update_packages.commit_long_sha || '') }} + ref: ${{ (needs.update_packages.outputs.commit_long_sha || '') }} upload-release: needs: build @@ -68,7 +68,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 with: - ref: ${{ (needs.build.needs.update_packages.commit_long_sha || '') }} + ref: ${{ (needs.build.needs.update_packages.outputs.commit_long_sha || '') }} - name: Download artifact uses: actions/download-artifact@v4 @@ -81,6 +81,11 @@ jobs: sudo apt-get update sudo apt-get install jq sh ./.github/workflows/retrieve_version.sh + + - name: Get Release HTML + run: echo "release_html=$(jq -r '."desktop-release-notes.$VERSION"' ./dist/release_notes.json)" >> $GITHUB_ENV + + - run: rm -rf dist/release_notes.json - name: Tag Repo uses: richardsimko/update-tag@v1 @@ -98,4 +103,5 @@ jobs: name: ${{ env.release_name }} replacesArtifacts: true tag: ${{ env.tag_name }} + body: ${{ env.release_html }} diff --git a/nix/default.nix b/nix/default.nix index 51a0f3f..953e4cc 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -6,6 +6,7 @@ , p7zip , asar , jq +, python3 , electron , ymExe ? null @@ -23,6 +24,7 @@ stdenvNoCC.mkDerivation p7zip asar jq + python3 makeWrapper ]; diff --git a/repack.sh b/repack.sh index 16dd3b3..b73fc7d 100755 --- a/repack.sh +++ b/repack.sh @@ -14,6 +14,7 @@ usage() { exe_location= dst="$PWD/app" +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) fix_quit=1 while getopts :xo:qh name; do case $name in @@ -115,5 +116,6 @@ asar pack "$TEMPDIR/app" "$dst/yandexmusic.asar" for ext in png svg; do mv "$TEMPDIR/app/build/next-desktop/favicon.$ext" "$dst" done +python "$SCRIPT_DIR/utility/extract_release_notes.py" "$TEMPDIR/app/build/next-desktop/album.txt" "$dst/release_notes.json" echo "Done" diff --git a/templates/PKGBUILD b/templates/PKGBUILD index 980e657..a767815 100644 --- a/templates/PKGBUILD +++ b/templates/PKGBUILD @@ -8,7 +8,7 @@ arch=("any") url="https://github.com/cucumber-sp/yandex-music-linux" license=("custom") depends=("electron" "libpulse" "xdg-utils") -makedepends=("p7zip" "nodejs" "asar" "jq") +makedepends=("p7zip" "nodejs" "asar" "jq" "python") source=("%exe_link%" "git+https://github.com/cucumber-sp/yandex-music-linux") sha256sums=("%exe_sha256%" "SKIP") diff --git a/utility/extract_release_notes.py b/utility/extract_release_notes.py new file mode 100644 index 0000000..b755499 --- /dev/null +++ b/utility/extract_release_notes.py @@ -0,0 +1,50 @@ +import sys +import json + +if len(sys.argv) < 3: + print("Usage: python extract_release_notes.py ") + sys.exit(1) + +file_name = sys.argv[1] +save_file_name = sys.argv[2] + +def build_html(data, first_launch=False): + html = "" + for i, element in enumerate(data): + if element['type'] == 0: + if first_launch and i == 0: + html += f"

{element['value']}

".replace('\n', '
') + continue + if element['value'] == '\n': + html += "
" + else: + html += f"{element['value']}".replace('\n', '
') + elif element['type'] == 8: + html += f"<{element['value']}>{build_html(element['children'])}" + return html + +with open(file_name, "r", encoding='utf-8') as file: + full_text = file.read() + +notes = {} +position = full_text.find("desktop-release-notes.") +while position != -1: + start_position = position + while full_text[position] != '"': + position += 1 + name = full_text[start_position:position] + position += 2 + start_position = position + braces_count = 1 + while braces_count > 0: + position += 1 + if full_text[position] == '{' or full_text[position] == '[': + braces_count += 1 + elif full_text[position] == '}' or full_text[position] == ']': + braces_count -= 1 + data = full_text[start_position:position + 1] + notes[name] = build_html(json.loads(data), True) + position = full_text.find("desktop-release-notes.", position) + +with open(save_file_name, "w", encoding='utf-8') as file: + file.write(json.dumps(notes, ensure_ascii=False, indent=4)) \ No newline at end of file