[workflow] Link Rebase-on-upstream to Build

* make Build callable but not scheduled

* make Build receive commit SHA from caller

* make Rebase pass commit SHA to Build

* Don't set GH output from update-version.py

* No rebase is still success

* Allow scheduled Rebase to invoke Build
This commit is contained in:
dirkf 2023-07-14 03:44:45 +01:00
parent ebb61a70bd
commit 9235c3f7e8
3 changed files with 61 additions and 26 deletions

View File

@ -1,9 +1,17 @@
name: Build
on:
workflow_call:
inputs:
build-commit:
type: string
required: true
workflow_dispatch:
schedule:
- cron: "0 2 * * *"
inputs:
build-commit:
description: 'SHA of commit being built'
type: string
required: false
jobs:
build_unix:
@ -18,26 +26,28 @@ jobs:
sha512_tar: ${{ steps.sha512_tar.outputs.sha512_tar }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.9'
- name: Install packages
run: sudo apt-get -y install zip pandoc man
- name: Set version suffix
id: version_suffix
run: echo ::set-output name=version_suffix::$( printf '114514\n40298\n43044\n810\n1919\n19419\n334' | sort -R | head -n1 )
- name: Bump version
id: bump_version
run: |
python devscripts/update-version.py ${{ steps.version_suffix.outputs.version_suffix }}
ytdl_version=$(python devscripts/update-version.py)
echo "ytdl_version=$ytdl_version" >> "$GITHUB_OUTPUT"
sha=${{ inputs.build-commit }}
sed -i -rn -e '/^ *RELEASE_GIT_HEAD *=/z;$s/$/&'"\nRELEASE_GIT_HEAD = '${sha}'/;p" youtube_dl/version.py
x=${sha#?????????}; sha=${sha%$x}
echo "Version = $ytdl_version${sha+[ }${sha}${sha+]}"
make issuetemplates
- name: Push to release
id: push_release
run: echo ::set-output name=head_sha::$(git rev-parse HEAD)
run: echo "head_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- name: Get Changelog
id: get_changelog
run: |
@ -50,16 +60,16 @@ jobs:
run: make all tar
- name: Get SHA2-256SUMS for youtube-dl
id: sha256_bin
run: echo "::set-output name=sha256_bin::$(sha256sum youtube-dl | awk '{print $1}')"
run: echo "sha256_bin=$(sha256sum youtube-dl | awk '{print $1}')" >> "$GITHUB_OUTPUT"
- name: Get SHA2-256SUMS for youtube-dl.tar.gz
id: sha256_tar
run: echo "::set-output name=sha256_tar::$(sha256sum youtube-dl.tar.gz | awk '{print $1}')"
run: echo "sha256_tar=$(sha256sum youtube-dl.tar.gz | awk '{print $1}')" >> "$GITHUB_OUTPUT"
- name: Get SHA2-512SUMS for youtube-dl
id: sha512_bin
run: echo "::set-output name=sha512_bin::$(sha512sum youtube-dl | awk '{print $1}')"
run: echo "sha512_bin=$(sha512sum youtube-dl | awk '{print $1}')" >> "$GITHUB_OUTPUT"
- name: Get SHA2-512SUMS for youtube-dl.tar.gz
id: sha512_tar
run: echo "::set-output name=sha512_tar::$(sha512sum youtube-dl.tar.gz | awk '{print $1}')"
run: echo "sha512_tar=$(sha512sum youtube-dl.tar.gz | awk '{print $1}')" >> "$GITHUB_OUTPUT"
- name: Create Release
id: create_release
@ -101,10 +111,10 @@ jobs:
sha512_win: ${{ steps.sha512_win.outputs.sha512_win }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
# reason to choose 3.4: https://media.discordapp.net/attachments/807245652072857613/942409077701619742/unknown.png
- name: Set up Python 3.4
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.4'
architecture: 'x86'
@ -116,9 +126,13 @@ jobs:
run: python -m pip install --upgrade "pip<19.2" "setuptools<44" "wheel<0.34.0" py2exe==0.9.2.2
- name: Bump version
id: bump_version
env:
version_suffix: ${{ needs.build_unix.outputs.version_suffix }}
run: python devscripts/update-version.py ${{ env.version_suffix }}
shell: bash
run: |
ytdl_version=$(python devscripts/update-version.py)
sha=${{ inputs.build-commit }}
sed -i -rn -e '/^ *RELEASE_GIT_HEAD *=/z;$s/$/&'"\nRELEASE_GIT_HEAD = '${sha}'/;p" youtube_dl/version.py
x=${sha#?????????}; sha=${sha%$x}
echo "Version = $ytdl_version${sha+[ }${sha}${sha+]}"
# - name: Run PyInstaller Script
# run: python -m PyInstaller --onefile --console --distpath dist/ -n youtube-dl youtube_dl\__main__.py
- name: Build EXE file
@ -135,10 +149,10 @@ jobs:
asset_content_type: application/vnd.microsoft.portable-executable
- name: Get SHA2-256SUMS for youtube-dl.exe
id: sha256_win
run: echo "::set-output name=sha256_win::$((Get-FileHash youtube-dl.exe -Algorithm SHA256).Hash.ToLower())"
run: echo "sha256_win=$((Get-FileHash youtube-dl.exe -Algorithm SHA256).Hash.ToLower())" >> "$env:GITHUB_OUTPUT"
- name: Get SHA2-512SUMS for youtube-dl.exe
id: sha512_win
run: echo "::set-output name=sha512_win::$((Get-FileHash youtube-dl.exe -Algorithm SHA512).Hash.ToLower())"
run: echo "sha512_win=$((Get-FileHash youtube-dl.exe -Algorithm SHA512).Hash.ToLower())" >> "$env:GITHUB_OUTPUT"
finish:
runs-on: ubuntu-latest

View File

@ -2,18 +2,39 @@ name: Rebase on Upstream
on:
schedule:
- cron: "0 0 * * *"
- cron: '53 0 * * *'
workflow_dispatch:
jobs:
rebase:
runs-on: ubuntu-latest
outputs:
build-commit: ${{ steps.relocate.outputs.build-commit }}
steps:
- uses: actions/checkout@master
- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 0
token: ${{ secrets.GH_PAT }}
- uses: ytdl-org/ytdl-patched-rebase-upstream-action@master
- name: Locate
shell: bash
run: |
echo "HEAD_NOW=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
- name: Rebase
uses: ytdl-org/ytdl-patched-rebase-upstream-action@master
with:
token: ${{ secrets.GH_PAT }}
upstream: ytdl-org/youtube-dl
- name: Relocate
id: relocate
shell: bash
run: |
NEW_HEAD=$(git rev-parse HEAD)
[ "${{ env.HEAD_NOW }}" = "$NEW_HEAD" ] || echo "build-commit=$NEW_HEAD" >> "$GITHUB_OUTPUT"
build:
needs: rebase
if: ${{ needs.rebase.outputs.build-commit }}
uses: ./.github/workflows/build.yml
with:
build-commit: ${{ needs.rebase.outputs.build-commit }}

View File

@ -22,6 +22,7 @@ if not rev:
VERSION = '.'.join((ver, rev)) if rev else ver
VERSION_FILE = '''# Autogenerated by devscripts/update-version.py
from __future__ import unicode_literals
__version__ = {!r}
'''.format(VERSION)
@ -29,5 +30,4 @@ __version__ = {!r}
with open('youtube_dl/version.py', 'wt') as f:
f.write(VERSION_FILE)
print('::set-output name=ytdl_version::' + VERSION)
print('\nVersion = %s' % VERSION)
print(VERSION)