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

Add release workflow #3

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Grub4K
Copy link
Member

@Grub4K Grub4K commented Aug 17, 2024

Following changes:

  • Migrates plugin to hatch for easy access to metadata and consistency with main project
  • Support for automated release workflow
  • Support for automated™ plugin bundling
  • Readme adjustments to reflect changes
    • In the future, the import should be moved to plugin systems responsibility

Upon merge this will create a dummy release if actions are activated. The same goes for when creating a repository with this as template, and actions enabled. Is this a problem?

Demo release: https://github.com/Grub4K/yt-dlp-sample-plugins/releases/tag/v2023.1.2

Fixes #2

pyproject.toml Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
- name: Set variables
id: set_variables
run: |
tag="$(git describe --tags --abbrev=0)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to assume a git tag already exists

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right I forgot I tested with a failed tag existing

Copy link

@grqz grqz Sep 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tag="$(git describe --tags --abbrev=0)"
tag=$(git for-each-ref refs/tags --sort=-creatordate --format='%(refname:strip=2)' --count=1)

This gives an empty string when no tags are present. It works without problem creating the first release of the repo.
Refer to https://stackoverflow.com/a/5261470

.github/workflows/release.yml Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
while IFS=';' read -r name path; do
if [[ ! "${name}" =~ ^(pip|setuptools|wheel)$ ]]; then
package_name="$(tr '[:upper:]' '[:lower:]' <<<"${name}" | sed 's/-/_/g')"
cp -r "${path}/${package_name}" bundle/
Copy link

@grqz grqz Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some projects don't have it's code in this path. For example a normal yt-dlp plugin or yt-dlp itself. not sure if we can run pip install . and change installation path to bundle/ and remove .dist-info if necessary, probably like pip install -t bundle/ .?

example log from shell
$ pip install -t bundle/ .; ls -al bundle/
Processing /home/user/tmp
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting yt-dlp-get-pot>=0.0.2
  Using cached yt_dlp_get_pot-0.0.2-py3-none-any.whl (6.8 kB)
Building wheels for collected packages: definitely_not_bgutil-ytdlp-pot-provider_to_distinguish_from_it
  Building wheel for definitely_not_bgutil-ytdlp-pot-provider_to_distinguish_from_it (pyproject.toml) ... done
  Created wheel for definitely_not_bgutil-ytdlp-pot-provider_to_distinguish_from_it: filename=definitely_not_bgutil_ytdlp_pot_provider_to_distinguish_from_it-0.2.22-py3-none-any.whl size=1243 sha256=25788b6ccab2676493a4fdb39808dc3833a7699963d504e1137f2d2fde310794
  Stored in directory: /tmp/pip-ephem-wheel-cache-yh0ca0qt/wheels/c5/5b/dd/eba17e133d5a684b348375bea715fd011a6e07e4630222c11b
Successfully built definitely_not_bgutil-ytdlp-pot-provider_to_distinguish_from_it
Installing collected packages: yt-dlp-get-pot, definitely_not_bgutil-ytdlp-pot-provider_to_distinguish_from_it
Successfully installed definitely_not_bgutil-ytdlp-pot-provider_to_distinguish_from_it-0.2.22 yt-dlp-get-pot-0.0.2
total 20
drwxr-xr-x 5 user user 4096 Sep  2 19:42 .
drwxr-xr-x 5 user user 4096 Sep  2 19:42 ..
drwxr-xr-x 2 user user 4096 Sep  2 19:42 definitely_not_bgutil_ytdlp_pot_provider_to_distinguish_from_it-0.2.22.dist-info
drwxr-xr-x 3 user user 4096 Sep  2 19:42 yt_dlp_get_pot-0.0.2.dist-info
drwxr-xr-x 3 user user 4096 Sep  2 19:42 yt_dlp_plugins

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will look into it; it's def cleaner than copying.

Perhaps we could use something like hatch dep show requirements, or something with --no-deps? There's room to cook something here, I just can't see it quite yet

cp -r yt_dlp_plugins bundle/

while IFS=';' read -r name path; do
if [[ ! "${name}" =~ ^(pip|setuptools|wheel)$ ]]; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably also exclude yt-dlp?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggested this originally too, but found you'd need to specify all of yt-dlp's dependencies too (until yt-dlp switches to not requiring deps by default)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: yt-dlp/yt-dlp#11255 has been merged

@@ -0,0 +1,65 @@
name: Create release
on: [push]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
on: [push]
on:
push:
branches:
- 'master'
paths:
- 'pyproject.toml'

maybe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dislike having the branch hardcoded, as I tend to use main for my branches, but I guess if people use the template they will get this name...

Copy link

@grqz grqz Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    if: format('refs/heads/{0}', github.event.repository.default_branch) == github.ref

maybe use this at job level instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'll make it show up as a run but just be skipped. Your previous suggestion is the way to go I think

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use something like this?

    branches:
      - ${{ github.event.repository.default_branch }}

if: |
env.tag != env.version
run: |
project_name="$(hatch project metadata | jq -r .name)"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move this to the set_variables step?

run: |
tag="$(git describe --tags --abbrev=0)"
echo "::group::Variables"
cat << EOF | tee -a "$GITHUB_OUTPUT"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was referenced Nov 29, 2024
@coletdjnz
Copy link
Member

If there are issues with the default behaviour of bundling deps in the release zip, we could perhaps disable it by default? Developers can enable it if they would like?

README.md Outdated Show resolved Hide resolved
Co-authored-by: N/Ame <[email protected]>

- uses: actions/setup-python@v5
with:
python-version: "3.8"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be 3.9(yt-dlp/yt-dlp#11321)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Nice to have
Development

Successfully merging this pull request may close these issues.

Add a basic release GH action
3 participants