Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci] Implement release workflow #32876

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 170 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
name: Build Artifacts

on:
workflow_call:
inputs:
version:
required: true
type: string
unix:
default: true
type: boolean
windows32:
default: true
type: boolean

workflow_dispatch:
inputs:
version:
description: |
VERSION: yyyy.mm.dd[.rev] or rev
required: true
type: string
unix:
description: youtube-dl, youtube-dl.tar.gz
default: true
type: boolean
windows32:
description: youtube-dl.exe
default: true
type: boolean

permissions:
contents: read

jobs:
unix:
if: inputs.unix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for changelog

- uses: actions/setup-python@v5
with:
python-version: "3.9"

- name: Install Requirements
run: |
sudo apt -y install zip pandoc man sed

- name: Prepare
run: |
python devscripts/update_version.py "${{ inputs.version }}"
python devscripts/changelog.py --update
python devscripts/make_lazy_extractors.py youtube_dl/extractor/lazy_extractors.py

- name: Build Unix platform-independent binary
run: |
make all tar

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: build-bin-${{ github.job }}
path: |
youtube-dl
youtube-dl.tar.gz
compression-level: 0

windows32:
if: inputs.windows32
runs-on: windows-2022
env:
PYCRYPTO: pycrypto-2.6.1-cp34-none-win32
# Temporary workaround for Python 3.4/5 failures - May 2024
Grub4K marked this conversation as resolved.
Show resolved Hide resolved
PIP_TRUSTED_HOST: "pypi.python.org pypi.org files.pythonhosted.org"
Grub4K marked this conversation as resolved.
Show resolved Hide resolved

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.4
uses: actions/setup-python@v5
with:
python-version: "3.4"
Grub4K marked this conversation as resolved.
Show resolved Hide resolved
architecture: x86

- name: Install packages
# https://pip.pypa.io/en/stable/news/#v19-2
# https://setuptools.pypa.io/en/latest/history.html#v44-0-0
# https://wheel.readthedocs.io/en/stable/news.html
# https://pypi.org/project/py2exe/0.9.2.2
shell: bash
run: |
python -m pip install --upgrade \
"pip<19.2" \
"setuptools<44" \
"wheel<0.34.0" \
"py2exe==0.9.2.2" \
;

- name: PyCrypto cache
id: cache_pycrypto
uses: actions/cache@v4
with:
key: ${{ env.PYCRYPTO }}
path: ./${{ env.PYCRYPTO }}

- name: PyCrypto download
if: |
steps.cache_pycrypto.outputs.cache-hit != 'true'
shell: bash
run: |
mkdir -p "${PYCRYPTO}"
cd "${PYCRYPTO}"
curl -L -O "https://web.archive.org/web/20200627032153/http://www.voidspace.org.uk/python/pycrypto-2.6.1/${PYCRYPTO}.whl"

- name: PyCrypto install
shell: bash
run: |
python -m pip install "./${PYCRYPTO}/${PYCRYPTO}.whl"

- name: Prepare
run: |
python devscripts/update_version.py "${{ inputs.version }}"
python devscripts/make_lazy_extractors.py youtube_dl/extractor/lazy_extractors.py

- name: Build binary
run: python setup.py py2exe

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: build-bin-${{ github.job }}
path: |
youtube-dl.exe
compression-level: 0

meta_files:
if: always() && !cancelled()
needs:
- unix
- windows32
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: artifact
pattern: build-bin-*
merge-multiple: true

- name: Make SHA2-SUMS files
run: |
cd ./artifact/
# make sure SHA sums are also printed to stdout
sha256sum -- * | tee ../SHA2-256SUMS
sha512sum -- * | tee ../SHA2-512SUMS
# also print as permanent annotations to the summary page
while read -r shasum; do
echo "::notice title=${shasum##* }::sha256: ${shasum% *}"
done < ../SHA2-256SUMS

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: build-${{ github.job }}
path: |
SHA*SUMS*
compression-level: 0
overwrite: true
147 changes: 147 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
description: |
VERSION: yyyy.mm.dd[.rev] or rev
(default: auto-generated)
required: false
default: ""
type: string
prerelease:
description: Pre-release
default: false
type: boolean

jobs:
prepare:
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
version: ${{ steps.setup_variables.outputs.version }}
head_sha: ${{ steps.get_target.outputs.head_sha }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Setup variables
id: setup_variables
run: |
revision="${{ (inputs.prerelease || !vars.PUSH_VERSION_COMMIT) && '$(date -u +"%H%M%S")' || '' }}"
version="$(
python devscripts/update_version.py \
${{ inputs.version || '"${revision}"' }} )"
echo "::group::Output variables"
cat << EOF | tee -a "$GITHUB_OUTPUT"
version=${version}
EOF
echo "::endgroup::"

- name: Update documentation
env:
version: ${{ steps.setup_variables.outputs.version }}
target_repo: ${{ steps.setup_variables.outputs.target_repo }}
if: |
!inputs.prerelease
run: |
python devscripts/changelog.py --update
make README.md
make issuetemplates
make supportedsites

- name: Push to release
id: push_release
env:
version: ${{ steps.setup_variables.outputs.version }}
creator: ${{ github.event.sender.login }}
if: |
!inputs.prerelease
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -u
git commit -m "Release ${version}" \
-m "Created by: ${creator}" \
-m ":ci skip all"
git push origin --force master:release

- name: Get target commitish
id: get_target
run: |
echo "head_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"

- name: Update master
env:
target_repo: ${{ steps.setup_variables.outputs.target_repo }}
if: |
vars.PUSH_VERSION_COMMIT != '' && !inputs.prerelease
run: |
git push origin ${{ github.event.ref }}

build:
needs: prepare
uses: ./.github/workflows/build.yml
with:
version: ${{ needs.prepare.outputs.version }}
permissions:
contents: read

publish:
needs: [prepare, build]
permissions:
contents: write
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/download-artifact@v4
with:
path: artifact
pattern: build-*
merge-multiple: true

- uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Generate release notes
run: |
cat >> ./RELEASE_NOTES << EOF
<details><summary><h3>Changelog</h3></summary>

$(python devscripts/changelog.py)

</details>
EOF
cat > ./PRERELEASE_NOTES << EOF
**This is a pre-release build**
---

$(cat ./RELEASE_NOTES)
EOF

- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
version: ${{ needs.prepare.outputs.version }}
head_sha: ${{ needs.prepare.outputs.head_sha }}
run: |
gh release create \
--notes-file ${{ inputs.prerelease && 'PRERELEASE_NOTES' || 'RELEASE_NOTES' }} \
--target ${{ env.head_sha }} \
--title "youtube-dl ${version}" \
${{ inputs.prerelease && '--prerelease' || '' }} \
"${version}" \
artifact/*
Loading
Loading