name: Build YouTube Music on: - push env: NODE_VERSION: "16.x" jobs: build: name: Build YouTube Music runs-on: ${{ matrix.os }} strategy: fail-fast: true matrix: os: [macos-latest, ubuntu-latest, windows-latest] steps: - uses: actions/checkout@v3 - name: Setup NodeJS uses: actions/setup-node@v3 with: node-version: ${{ env.NODE_VERSION }} - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" - uses: actions/cache@v3 id: yarn-cache with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} restore-keys: | ${{ runner.os }}-yarn- - name: Install dependencies run: yarn --frozen-lockfile ###################### # Patch SnoreToast to fix App ID - see https://github.com/th-ch/youtube-music/issues/479#issuecomment-965473559 - name: SnoreToast - parameters id: snoretoast-params if: startsWith(matrix.os, 'windows') shell: bash run: | echo "::set-output name=version::v0.8.0" echo "::set-output name=path::./vendor/snoretoast" - name: SnoreToast - cache id: snoretoast-cache uses: actions/cache@v2 if: startsWith(matrix.os, 'windows') with: path: ${{ steps.snoretoast-params.outputs.path }} key: snoretoast-${{ steps.snoretoast-params.outputs.version }} - name: SnoreToast - compile if: | startsWith(matrix.os, 'windows') && steps.snoretoast-cache.outputs.cache-hit != 'true' shell: bash run: | SNORETOAST_TAG="${{ steps.snoretoast-params.outputs.version }}" echo "Compiling SnoreToast $SNORETOAST_TAG" git config --global user.email "th-ch@users.noreply.github.com" git config --global user.name "YouTube Music" git clone -c advice.detachedHead=false --branch $SNORETOAST_TAG --depth 1 https://github.com/KDE/snoretoast.git ${{ steps.snoretoast-params.outputs.path }} cd ${{ steps.snoretoast-params.outputs.path }} # Apply https://github.com/KDE/snoretoast/pull/15/commits/c5faeceaf36f4b9fb27e5269990b716a25ecbe43 # Patch generated with `git format-patch -1 c5faeceaf36f4b9fb27e5269990b716a25ecbe43` git am < ../snoretoast-patch/0001-Fix-activation-not-writing-to-pipe.patch # Compile for win32 cmake -A Win32 -B build32 cmake --build build32 --config Release # Compile for x64 cmake -A x64 -B build64 cmake --build build64 --config Release - name: SnoreToast - overwrite with custom build if: startsWith(matrix.os, 'windows') shell: bash run: | # Override SnoreToast with the patched versions cp ${{ steps.snoretoast-params.outputs.path }}/build32/bin/Release/snoretoast.exe ./node_modules/node-notifier/vendor/snoreToast/snoretoast-x86.exe cp ${{ steps.snoretoast-params.outputs.path }}/build64/bin/Release/snoretoast.exe ./node_modules/node-notifier/vendor/snoreToast/snoretoast-x64.exe # End of SnoreToast patch ###################### - name: Test uses: GabrielBB/xvfb-action@v1 env: PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 with: run: yarn test - name: Build on Mac if: startsWith(matrix.os, 'macOS') env: GH_TOKEN: ${{ secrets.GH_TOKEN }} run: | yarn run release:mac - name: Build on Linux if: startsWith(matrix.os, 'ubuntu') env: GH_TOKEN: ${{ secrets.GH_TOKEN }} run: | yarn run release:linux - name: Build on Windows if: startsWith(matrix.os, 'windows') env: GH_TOKEN: ${{ secrets.GH_TOKEN }} run: | yarn run release:win release: runs-on: ubuntu-latest name: Release YouTube Music if: github.ref == 'refs/heads/master' needs: build steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Setup NodeJS uses: actions/setup-node@v3 with: node-version: ${{ env.NODE_VERSION }} - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" - uses: actions/cache@v3 id: yarn-cache with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} restore-keys: | ${{ runner.os }}-yarn- - name: Install dependencies run: yarn --frozen-lockfile - name: Get version run: | echo "VERSION_TAG=v$(node -pe "require('./package.json').version")" >> $GITHUB_ENV - name: Check if version already exists in tags run: | echo "VERSION_HASH=$(git rev-parse -q --verify 'refs/tags/${{ env.VERSION_TAG }}')" >> $GITHUB_ENV echo "CHANGELOG_ANCHOR=$(echo $VERSION_TAG | sed -e 's/\.//g')" >> $GITHUB_ENV - name: Fetch draft release if: ${{ env.VERSION_HASH == '' }} uses: cardinalby/git-get-release-action@v1 id: get_draft_release env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} with: latest: true draft: true searchLimit: 1 - name: Publish Release (if it does not exist) if: ${{ env.VERSION_HASH == '' }} uses: irongut/EditRelease@v1.2.0 with: token: ${{ secrets.GH_TOKEN }} id: ${{ steps.get_draft_release.outputs.id }} draft: false prerelease: false replacename: true name: ${{ env.VERSION_TAG }} replacebody: true body: | See [changelog](https://github.com/th-ch/youtube-music/blob/master/changelog.md#${{ env.CHANGELOG_ANCHOR }}) for the list of updates and the full diff. Thanks to all contributors! 🏅 - name: Update changelog if: ${{ env.VERSION_HASH == '' }} run: | yarn changelog - name: Commit changelog if: ${{ env.VERSION_HASH == '' }} uses: stefanzweifel/git-auto-commit-action@v4 with: commit_message: Update changelog for ${{ env.VERSION_TAG }} file_pattern: "changelog.md" commit_user_name: CI commit_user_email: th-ch@users.noreply.github.com