Use yt-dlp to get a stream for Mixcloud instead of an online API service #42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- '**' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
lfs: true | |
- name: Set version number (release build) | |
if: contains(github.ref, 'refs/tags/') | |
run: | | |
echo "VERSION=`echo ${GITHUB_REF##*/}`" >> $GITHUB_ENV | |
echo "RELEASE_CHANNEL=release" >> $GITHUB_ENV | |
echo "FOLDER=." >> $GITHUB_ENV | |
- name: Set version number (development build) | |
if: "!contains(github.ref, 'refs/tags/')" | |
run: | | |
echo "VERSION=`git describe --tags --abbrev=0`.`git rev-list $(git describe --tags --abbrev=0)..HEAD --count`" >> $GITHUB_ENV | |
echo "RELEASE_CHANNEL=dev" >> $GITHUB_ENV | |
echo "FOLDER=dev-builds" >> $GITHUB_ENV | |
- name: Set yt-dlp version | |
run: | | |
echo "YT_VERSION=`cat yt-dlp.version`" >> $GITHUB_ENV | |
- name: Test if release number matches x.y | |
if: env.RELEASE_CHANNEL == 'release' | |
run: | | |
! [[ ${{ env.VERSION }} =~ ^[0-9]+.[0-9]+$ ]] && echo "Release tag must be in the form of x.y." && exit 1 || echo "Release tag format is correct" | |
- name: Create install XML file | |
uses: cuchi/[email protected] | |
with: | |
template: install.template.xml | |
output_file: install.xml | |
strict: true | |
- name: Download yt-dlp binaries for Linux | |
run: | | |
wget https://github.com/yt-dlp/yt-dlp/releases/download/${{ env.YT_VERSION }}/yt-dlp -P Bin && chmod +x Bin/yt-dlp | |
- name: Test yt-dlp operation with Mixcloud | |
run: | | |
./Bin/yt-dlp --skip-download --dump-json https://www.mixcloud.com/johndigweed/transitions-with-john-digweed-and-nickon-faith/ 1> /dev/null | |
- name: Download yt-dlp binaries for Windows and MacOS | |
#if: env.RELEASE_CHANNEL == 'release' | |
run: | | |
wget https://github.com/yt-dlp/yt-dlp/releases/download/${{ env.YT_VERSION }}/yt-dlp.exe -P Bin | |
wget https://github.com/yt-dlp/yt-dlp/releases/download/${{ env.YT_VERSION }}/yt-dlp_macos -P Bin && chmod +x Bin/yt-dlp_macos | |
- name: Build package for Linux | |
run: | | |
zip -r lms_mixcloud-${{ env.VERSION }}-linux.zip . -x \*.zip \*.sh \*.git\* \*README\* \*sublime-\* \*.DS_Store\* \*.template.xml Bin\.gitkeep Bin/yt-dlp\.exe Bin/yt-dlp_macos | |
- name: Build packages for Windows and MacOS | |
#if: env.RELEASE_CHANNEL == 'release' | |
run: | | |
zip -r lms_mixcloud-${{ env.VERSION }}-windows.zip . -x \*.zip \*.sh \*.git\* \*README\* \*sublime-\* \*.DS_Store\* \*.template.xml Bin\.gitkeep Bin/yt-dlp Bin/yt-dlp_macos | |
rm Bin/yt-dlp && mv Bin/yt-dlp_macos Bin/yt-dlp | |
zip -r lms_mixcloud-${{ env.VERSION }}-macos.zip . -x \*.zip \*.sh \*.git\* \*README\* \*sublime-\* \*.DS_Store\* \*.template.xml Bin\.gitkeep Bin/yt-dlp.exe | |
- name: Calculate SHA for Linux | |
run: | | |
echo "SHA_LINUX=$(shasum lms_mixcloud-${{ env.VERSION }}-linux.zip | awk '{print $1;}')" >> $GITHUB_ENV | |
- name: Calculate SHA for Windows and MacOS | |
#if: env.RELEASE_CHANNEL == 'release' | |
run: | | |
echo "SHA_WINDOWS=$(shasum lms_mixcloud-${{ env.VERSION }}-windows.zip | awk '{print $1;}')" >> $GITHUB_ENV | |
echo "SHA_MACOS=$(shasum lms_mixcloud-${{ env.VERSION }}-macos.zip | awk '{print $1;}')" >> $GITHUB_ENV | |
- name: Create dev channel public XML file | |
uses: cuchi/[email protected] | |
with: | |
template: public.template.xml | |
output_file: public-dev.xml | |
strict: true | |
variables: | | |
all_platforms=true | |
- name: Create release public XML file | |
if: env.RELEASE_CHANNEL == 'release' | |
uses: cuchi/[email protected] | |
with: | |
template: public.template.xml | |
output_file: public.xml | |
strict: true | |
variables: | | |
all_platforms=true | |
- name: Switch branch, setup git for push | |
run: | | |
mv public*.xml /tmp | |
mv lms_mixcloud-${{ env.VERSION }}*.zip /tmp | |
git checkout gh-pages | |
cp /tmp/public*.xml . | |
cp /tmp/lms_mixcloud-${{ env.VERSION }}*.zip ${{ env.FOLDER }}/ | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Actions" | |
if [ "${{ env.RELEASE_CHANNEL }}" == "dev" ]; then | |
git add ${{ env.FOLDER }}/lms_mixcloud-${{ env.VERSION }}*.zip | |
COMMIT_MESSAGE_TYPE="development build" | |
else | |
COMMIT_MESSAGE_TYPE="release" | |
fi | |
git commit -m "Github Actions ${COMMIT_MESSAGE_TYPE} ${{ env.VERSION }}" -a | |
- name: Push changes to gh-pages | |
uses: ad-m/github-push-action@master | |
with: | |
branch: gh-pages | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create release | |
if: env.RELEASE_CHANNEL == 'release' | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
name: Release ${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
files: | | |
lms_mixcloud-${{ env.VERSION }}-linux.zip | |
lms_mixcloud-${{ env.VERSION }}-windows.zip | |
lms_mixcloud-${{ env.VERSION }}-macos.zip |