From 998b82c0a68397602b685e52f920a7f3710d0d5a Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Wed, 27 Apr 2022 13:51:58 +0600 Subject: [PATCH] CI for winget, aur & flathub publish support added CI liux & macos release build support --- .github/workflows/release-build.yml | 173 +++++++++++++++++- aur-struct/PKGBUILD | 6 +- linux/com.github.KRTirtho.Spotube.appdata.xml | 1 + scripts/update_flathub_version.py | 30 +++ 4 files changed, 202 insertions(+), 8 deletions(-) create mode 100644 scripts/update_flathub_version.py diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 89b9bfdd..596ab7c1 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -64,23 +64,186 @@ jobs: name: Spotube-Windows-Bundle path: dist/${{ steps.tag.outputs.tag }} - update_release: - needs: publish_chocolatey + publish_macos: + runs-on: macos-11 + steps: + - uses: actions/checkout@v3 + - uses: actions/checkout@v3 + with: + repository: KRTirtho/flutter_distributor + ref: deb-implementation + path: build/flutter_distributor + - name: Get latest tag + id: tag + uses: dawidd6/action-get-tag@v1 + with: + strip_v: true + - uses: subosito/flutter-action@v2 + with: + cache: true + - run: | + flutter config --enable-macos-desktop + flutter pub get + dart bin/create-secrets.dart '${{ secrets.LYRICS_SECRET }}' '${{ secrets.SPOTIFY_SECRET }}' + npm install -g appdmg + dart pub global activate --source path build/flutter_distributor/packages/flutter_distributor + flutter_distributor package --platform=macos --targets=dmg --skip-clean + - run: mv dist/${{ steps.tag.outputs.tag }}/spotube-${{ steps.tag.outputs.tag }}-macos.dmg dist/${{ steps.tag.outputs.tag }}/Spotube-macos-x86_64.dmg + - uses: actions/upload-artifact@v2 + with: + name: Spotube-Macos-Bundle + path: dist/${{ steps.tag.outputs.tag }}/Spotube-macos-x86_64.dmg + + publish_linux: runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/checkout@v3 + with: + repository: KRTirtho/flutter_distributor + ref: deb-implementation + path: build/flutter_distributor + - name: Get latest tag + id: tag + uses: dawidd6/action-get-tag@v1 + with: + strip_v: true + - uses: subosito/flutter-action@v2 + with: + cache: true + - name: Get current date + id: date + run: echo "::set-output name=date::$(date +'%Y-%m-%d')" + - run: | + sudo apt-get update -y + sudo apt-get install -y tar clang cmake ninja-build pkg-config libgtk-3-dev make libwebkit2gtk-4.0-dev keybinder-3.0 python3-pip python3-setuptools patchelf desktop-file-utils libgdk-pixbuf2.0-dev fakeroot strace fuse + - run: | + wget -O appimage-builder-x86_64.AppImage https://github.com/AppImageCrafters/appimage-builder/releases/download/v1.0.0-beta.1/appimage-builder-1.0.0-677acbd-x86_64.AppImage + chmod +x appimage-builder-x86_64.AppImage + mv appimage-builder-x86_64.AppImage /usr/local/bin/appimage-builder + # replacing & adding new release version with older version + - run: | + sed -i 's|%{{APPDATA_RELEASE}}%||' linux/com.github.KRTirtho.Spotube.appdata.xml + + - run: | + flutter config --enable-linux-desktop + flutter pub get + dart bin/create-secrets.dart '${{ secrets.LYRICS_SECRET }}' '${{ secrets.SPOTIFY_SECRET }}' + dart pub global activate --source path build/flutter_distributor/packages/flutter_distributor + flutter_distributor package --platform=linux --targets=deb,appimage --skip-clean + make tar + - run: | + mv build/Spotube-linux-x86_64.tar.xz dist/${{ steps.tag.outputs.tag }} + mv dist/${{ steps.tag.outputs.tag }}/spotube-${{ steps.tag.outputs.tag }}+${{ steps.tag.outputs.tag }}-linux.deb dist/${{ steps.tag.outputs.tag }}/Spotube-linux-x86_64.deb + mv dist/${{ steps.tag.outputs.tag }}/spotube-${{ steps.tag.outputs.tag }}-linux.AppImage dist/${{ steps.tag.outputs.tag }}/Spotube-linux-x86_64.AppImage + - uses: actions/upload-artifact@v2 + with: + name: Spotube-Linux-Bundle + path: dist/${{ steps.tag.outputs.tag }} + + update_release: + needs: + - publish_chocolatey + - publish_macos + - publish_linux + runs-on: ubuntu-latest + permissions: + contents: write steps: - uses: actions/download-artifact@v3 with: name: Spotube-Windows-Bundle + path: ./Spotube-Windows-Bundle + - uses: actions/download-artifact@v3 + with: + name: Spotube-Macos-Bundle + path: ./Spotube-Macos-Bundle + - uses: actions/download-artifact@v3 + with: + name: Spotube-Linux-Bundle + path: ./Spotube-Linux-Bundle - name: Get latest tag id: tag uses: dawidd6/action-get-tag@v1 + with: + strip_v: true + # generating checksums for all the binary + - run: | + md5sum ./**/*.{AppImage,deb,zip,dmg,exe,nupkg,apk} > RELEASE.md5sum + sha256sum build/**/*.{AppImage,deb,zip,dmg,exe,nupkg,apk} > RELEASE.sha256sum + sed -i 's|Spotube-.*-Bundle/||' RELEASE.sha256sum RELEASE.md5sum # Upload release binary - uses: ncipollo/release-action@v1 with: token: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ steps.tag.outputs.tag }} + tag: v${{ steps.tag.outputs.tag }} omitBodyDuringUpdate: true omitNameDuringUpdate: true + omitPrereleaseDuringUpdate: true allowUpdates: true - artifacts: > - Spotube-Windows-Bundle/ + artifacts: Spotube-Windows-Bundle/dist/${{ steps.tag.outputs.tag }/*,Spotube-Macos-Bundle/dist/${{ steps.tag.outputs.tag }/*,Spotube-Linux-Bundle/dist/${{ steps.tag.outputs.tag }/*,RELEASE.sha256sum,RELEASE.md5sum + + # publish_winget: + # needs: update_release + # runs-on: windows-latest + # steps: + # - name: Get latest tag + # id: tag + # uses: dawidd6/action-get-tag@v1 + # with: + # strip_v: true + # - run: | + # winget install wingetcreate --silent + # choco install tree -y + # wingetcreate update KRTirtho.Spotube --urls https://github.com/KRTirtho/spotube/releases/download/v${{ steps.tag.outputs.tag }}/Spotube-windows-x86_64-setup.exe https://github.com/KRTirtho/spotube/releases/download/v${{ steps.tag.outputs.tag }}/Spotube-windows-x86_64-setup.exe --version ${{ steps.tag.outputs.tag }} --token ${{ secrets.GITHUB_TOKEN }} --submit + + publish_flathub: + needs: update_release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + path: spotube + - uses: actions/checkout@v3 + with: + repository: flathub/com.github.KRTirtho.Spotube + token: ${{ secrets.FLATHUB_TOKEN }} + - name: Get latest tag + id: tag + uses: dawidd6/action-get-tag@v1 + with: + strip_v: true + - run: | + python3 spotube/scripts/update_flathub_version.py ${{ steps.tag.outputs.tag }} + - uses: EndBug/add-and-commit@v9 + with: + message: v${{ steps.tag.outputs.tag }} Update + # push: origin master + push: false + + publish_aur: + needs: update_release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Get latest tag + id: tag + uses: dawidd6/action-get-tag@v1 + with: + strip_v: true + - uses: actions/download-artifact@v3 + with: + name: Spotube-Linux-Bundle + path: ./Spotube-Linux-Bundle + - run: | + sed -i "s/%{{SPOTUBE_VERSION}}%/${{ steps.tag.outputs.tag }}/" aur-struct/PKGBUILD + sed -i "s/%{{PKGREL}}%/1/" aur-struct/PKGBUILD + sed -i "s/%{{LINUX_MD5}}%/`md5sum Spotube-Linux-Bundle/Spotube-linux-x86_64.tar.xz | awk '{print $1}'`/" aur-struct/PKGBUILD + # - uses: KSXGitHub/github-actions-deploy-aur@v2.2.5 + # with: + # pkgname: spotube-bin + # pkgbuild: aur-struct/PKGBUILD + # commit_username: ${{ secrets.AUR_USERNAME }} + # commit_email: ${{ secrets.AUR_EMAIL }} + # ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} + # commit_message: Updated to v${{steps.tag.outputs.tag}} diff --git a/aur-struct/PKGBUILD b/aur-struct/PKGBUILD index 1a7e4774..699f6992 100644 --- a/aur-struct/PKGBUILD +++ b/aur-struct/PKGBUILD @@ -1,7 +1,7 @@ # Maintainer: Kingkor Roy Tirtho pkgname=spotube-bin -pkgver=2.0.0 -pkgrel=3 +pkgver=%{{SPOTUBE_VERSION}}% +pkgrel=%{{PKGREL}}$ epoch= pkgdesc="A lightweight free Spotify crossplatform-client which handles playback manually, streams music using Youtube & no Spotify premium account is needed" arch=(x86_64) @@ -21,7 +21,7 @@ install= changelog= source=("https://github.com/KRTirtho/spotube/releases/download/v${pkgver}/Spotube-linux-x86_64.tar.xz") noextract=() -md5sums=(55955fb42d7e3f960392d68d45e2030a) +md5sums=(%{{LINUX_MD5}}%) validpgpkeys=() package(){ diff --git a/linux/com.github.KRTirtho.Spotube.appdata.xml b/linux/com.github.KRTirtho.Spotube.appdata.xml index f88223c9..42c67dcd 100644 --- a/linux/com.github.KRTirtho.Spotube.appdata.xml +++ b/linux/com.github.KRTirtho.Spotube.appdata.xml @@ -36,6 +36,7 @@ com.github.KRTirtho.Spotube.desktop + %{{APPDATA_RELEASE}}% diff --git a/scripts/update_flathub_version.py b/scripts/update_flathub_version.py new file mode 100644 index 00000000..76b91945 --- /dev/null +++ b/scripts/update_flathub_version.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +import hashlib +import sys +import requests +import yaml + +REPO = "KRTirtho/spotube" +YAML_FILENAME = "com.github.KRTirtho.Spotube.yml" + +config = None +with open(YAML_FILENAME, mode="r", encoding="utf-8") as input: + config = yaml.safe_load(input) + +# Requires the 2nd VERSION argument to be passed +version = sys.argv[1:][1:] + +tar_url = f"https://github.com/{REPO}/releases/download/v{version}/Spotube-linux-x86_64.tar.xz" +tar_sha256 = hashlib.sha256() +tar = requests.get(tar_url) +for chunk in tar.iter_content(): + if chunk: + tar_sha256.update(chunk) + +tar_source = config["modules"][1]["sources"][0] +tar_source["url"] = tar_url +tar_source["sha256"] = tar_sha256.hexdigest() + +with open(YAML_FILENAME, mode="w", encoding="utf-8") as output: + yaml.safe_dump(config, output, sort_keys=False) \ No newline at end of file