version: v5.25.0 #197
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: yt_clipper | |
on: | |
push: | |
branches: | |
- release | |
- release/* | |
- test-ci | |
# Workflow env variables not yet available at job level | |
# See https://github.community/t/how-to-set-and-access-a-workflow-variable/17335/14 | |
# Can work around to some degree using set-env | |
env: | |
NAME: yt_clipper | |
VERSION: '5.25.0' | |
jobs: | |
build: | |
defaults: | |
run: | |
shell: bash | |
runs-on: ${{ matrix.os }} | |
strategy: | |
max-parallel: 4 | |
matrix: | |
python-version: ['3.12.x'] | |
node-version: ['20.16.x'] | |
poetry-version: ['1.8.3'] | |
os: [windows-latest, macos-13] | |
include: | |
- os: windows-latest | |
shortos: win | |
ffmpeg_dl_name: ffmpeg-7.1-full_build-shared | |
ffmpeg_dl_prefix: 'https://github.com/GyanD/codexffmpeg/releases/download/7.1' | |
- os: macos-13 | |
shortos: macos | |
ffmpeg_dl_url: 'https://evermeet.cx/ffmpeg/ffmpeg-7.1.7z' | |
ffprobe_dl_url: 'https://evermeet.cx/ffmpeg/ffprobe-7.1.7z' | |
ffplay_dl_url: 'https://evermeet.cx/ffmpeg/ffplay-7.1.7z' | |
ffmpeg_info_url: 'https://evermeet.cx/ffmpeg/info/7.1' | |
steps: | |
- name: Set env | |
shell: bash | |
run: | | |
echo "FULL_NAME=${{env.NAME}}_${{matrix.shortos}}_${{env.VERSION}}" >> $GITHUB_ENV | |
echo "NOPLAT_NAME=${{env.NAME}}_${{env.VERSION}}" >> $GITHUB_ENV | |
- uses: actions/checkout@v3 | |
- name: Set up dirs | |
shell: bash | |
run: | | |
mkdir -p ./artifact/py/${{env.FULL_NAME}}/{webms,bin,temp}/ | |
mkdir -p ./bindeps | |
- name: Download ffmpeg dependency (windows) | |
if: matrix.os == 'windows-latest' | |
shell: bash | |
run: | | |
cd ./bindeps | |
curl -o ./ffmpeg.zip -L ${{ format('{0}/{1}.7z', matrix.ffmpeg_dl_prefix, matrix.ffmpeg_dl_name) }} | |
7z x ./ffmpeg.zip | |
mv ./${{matrix.ffmpeg_dl_name}} ffmpeg | |
./ffmpeg/bin/ffmpeg -version > version.txt | |
mv version.txt ffmpeg | |
ls -laR | |
- name: Download ffmpeg dependency (macos) | |
if: matrix.shortos == 'macos' | |
shell: bash | |
run: | | |
cd ./bindeps | |
mkdir temp | |
cd temp | |
curl -o ./ffmpeg.7z -L ${{matrix.ffmpeg_dl_url}} | |
curl -o ./ffprobe.7z -L ${{matrix.ffprobe_dl_url}} | |
curl -o ./ffplay.7z -L ${{matrix.ffplay_dl_url}} | |
curl -o version.txt -L ${{matrix.ffmpeg_info_url}} | |
7z x ./ffmpeg.7z | |
7z x ./ffprobe.7z | |
7z x ./ffplay.7z | |
cd .. | |
mkdir -p ffmpeg/bin | |
mv temp/ffmpeg temp/ffprobe temp/ffplay ffmpeg/bin | |
chmod -v +x ffmpeg/bin/* | |
mv temp/version.txt ffmpeg | |
ls -laR | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'yarn' | |
architecture: 'x64' | |
- name: Load cached node_modules | |
id: cached-node_modules | |
uses: actions/cache@v3 | |
with: | |
path: node_modules | |
key: yarn-${{ matrix.os }}-${{ hashFiles('**/yarn.lock') }} | |
- run: yarn install --frozen-lockfile | |
- run: yarn run bundle:prod | |
- name: Install poetry | |
run: pipx install poetry | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'poetry' | |
- name: Install clipper python dependencies | |
run: | | |
poetry install --no-interaction --no-root | |
- name: Lint with ruff | |
run: | | |
npm run lint:py | |
- name: Run clipper tests | |
run: | | |
npm run test:py | |
- name: Generate executable | |
run: npm run build:py | |
- name: Copy artifacts | |
shell: bash | |
run: | | |
mv ./bindeps/ffmpeg/bin/* ./artifact/py/${{env.FULL_NAME}}/bin/ | |
mv ./bindeps/ffmpeg/*.txt ./artifact/py/${{env.FULL_NAME}}/bin/ | |
cp ./src/clipper/include/* ./artifact/py/${{env.FULL_NAME}}/ | |
cp ./src/clipper/${{matrix.shortos}}_helpers/* ./artifact/py/${{env.FULL_NAME}}/ | |
mkdir -p ./artifact/py/${{env.FULL_NAME}}/yt-dlp-plugins/ytc | |
cp -R ./src/clipper/yt-dlp-plugins/ytc/ ./artifact/py/${{env.FULL_NAME}}/yt-dlp-plugins/ | |
cp ./dist/py/yt_clipper* ./artifact/py/${{env.FULL_NAME}}/ | |
- name: Print clipper install version (windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
./dist/py/yt_clipper.exe --version | |
- name: Print clipper install version (non-windows) | |
if: matrix.os != 'windows-latest' | |
run: | | |
./dist/py/yt_clipper --version | |
- name: Copy artifacts (markup) | |
if: matrix.shortos == 'macos' | |
shell: bash | |
run: | | |
mkdir -p ./artifact/js/ | |
cp ./dist/js/yt_clipper.js ./artifact/js/${{env.NOPLAT_NAME}}.js | |
- name: Zip artifacts on windows | |
if: matrix.os == 'windows-latest' | |
shell: powershell | |
run: | | |
Compress-Archive ./artifact/py/${{env.FULL_NAME}}/ ./artifact/py/${{env.FULL_NAME}}.zip | |
- name: Zip artifacts on non-windows systems | |
if: matrix.os != 'windows-latest' | |
run: | | |
cd ./artifact/py | |
zip -r ${{env.FULL_NAME}}.zip ./${{env.FULL_NAME}}/ | |
- name: Upload clipper script installation artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{env.FULL_NAME}}.zip | |
path: ./artifact/py/${{env.FULL_NAME}}.zip | |
- name: Upload markup script installation artifact | |
if: matrix.shortos == 'macos' | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{env.NOPLAT_NAME}}.js | |
path: ./artifact/js/${{env.NOPLAT_NAME}}.js | |
release: | |
needs: build | |
runs-on: macos-13 | |
steps: | |
- name: Set env | |
run: | | |
echo "DATE=$(date +'%Y.%m.%d')" >> $GITHUB_ENV | |
echo "FULL_NAME=${{env.NAME}}_${{env.VERSION}}" >> $GITHUB_ENV | |
echo "FULL_NAME_WIN=${{env.NAME}}_win_${{env.VERSION}}" >> $GITHUB_ENV | |
echo "FULL_NAME_MAC=${{env.NAME}}_macos_${{env.VERSION}}" >> $GITHUB_ENV | |
- uses: actions/download-artifact@v2 | |
with: | |
name: ${{env.FULL_NAME_WIN}}.zip | |
- uses: actions/download-artifact@v2 | |
with: | |
name: ${{env.FULL_NAME_MAC}}.zip | |
- uses: actions/download-artifact@v2 | |
with: | |
name: ${{env.FULL_NAME}}.js | |
- name: Create release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
with: | |
tag_name: v${{env.VERSION}} | |
release_name: ${{env.NAME}} v${{env.VERSION}} [${{env.DATE}}] | |
draft: true | |
prerelease: false | |
- name: Upload release asset (win) | |
id: upload-release-asset-win | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
with: | |
upload_url: ${{steps.create_release.outputs.upload_url}} | |
asset_path: ${{env.FULL_NAME_WIN}}.zip | |
asset_name: ${{env.FULL_NAME_WIN}}.zip | |
asset_content_type: application/zip | |
- name: Upload release asset (mac) | |
id: upload-release-asset-mac | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
with: | |
upload_url: ${{steps.create_release.outputs.upload_url}} | |
asset_path: ${{env.FULL_NAME_MAC}}.zip | |
asset_name: ${{env.FULL_NAME_MAC}}.zip | |
asset_content_type: application/zip | |
- name: Upload release asset (markup) | |
id: upload-release-asset-markup | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
with: | |
upload_url: ${{steps.create_release.outputs.upload_url}} | |
asset_path: ${{env.FULL_NAME}}.js | |
asset_name: ${{env.FULL_NAME}}.js | |
asset_content_type: text/javascript |