-
Notifications
You must be signed in to change notification settings - Fork 15
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
base: master
Are you sure you want to change the base?
Changes from all commits
34806b5
464aed8
9f59816
0fc5ee9
5894379
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,65 @@ | ||||||
name: Create release | ||||||
on: [push] | ||||||
|
||||||
jobs: | ||||||
coletdjnz marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
release: | ||||||
permissions: | ||||||
contents: write | ||||||
runs-on: ubuntu-latest | ||||||
steps: | ||||||
- uses: actions/checkout@v4 | ||||||
with: | ||||||
fetch-depth: 0 | ||||||
|
||||||
- uses: actions/setup-python@v5 | ||||||
with: | ||||||
python-version: "3.8" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be 3.9(yt-dlp/yt-dlp#11321) |
||||||
|
||||||
- name: Install Hatch | ||||||
run: pipx install hatch | ||||||
|
||||||
- name: Set variables | ||||||
id: set_variables | ||||||
run: | | ||||||
tag="$(git describe --tags --abbrev=0)" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to assume a git tag already exists There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right I forgot I tested with a failed tag existing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This gives an empty string when no tags are present. It works without problem creating the first release of the repo. |
||||||
echo "::group::Variables" | ||||||
cat << EOF | tee -a "$GITHUB_OUTPUT" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe |
||||||
tag=${tag} | ||||||
version=v$(hatch project metadata | jq -r .version) | ||||||
EOF | ||||||
echo "::endgroup::" | ||||||
|
||||||
- name: Bundle and create release | ||||||
env: | ||||||
GH_TOKEN: ${{ github.token }} | ||||||
tag: ${{ steps.set_variables.outputs.tag }} | ||||||
version: ${{ steps.set_variables.outputs.version }} | ||||||
if: | | ||||||
env.tag != env.version | ||||||
run: | | ||||||
project_name="$(hatch project metadata | jq -r .name)" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we move this to the |
||||||
sources="$(\ | ||||||
hatch run default:pip list --verbose --format json \ | ||||||
| jq -r '.[] | select(.editable_project_location == null) | "\(.name);\(.location)"' \ | ||||||
)" | ||||||
|
||||||
echo "::group::Dependencies" | ||||||
printf '%s\n' "${sources}" | ||||||
echo "::endgroup::" | ||||||
|
||||||
mkdir bundle/ | ||||||
cp -r yt_dlp_plugins bundle/ | ||||||
|
||||||
while IFS=';' read -r name path; do | ||||||
if [[ ! "${name}" =~ ^(pip|setuptools|wheel)$ ]]; then | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably also exclude yt-dlp? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: yt-dlp/yt-dlp#11255 has been merged |
||||||
package_name="$(tr '[:upper:]' '[:lower:]' <<<"${name}" | sed 's/-/_/g')" | ||||||
cp -r "${path}/${package_name}" bundle/ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 example log from shell
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||
fi | ||||||
done <<<"${sources}" | ||||||
|
||||||
cd bundle/ | ||||||
find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete | ||||||
zip -9 --recurse-paths "${project_name}" * | ||||||
gh release create "${version}" --latest \ | ||||||
--title "${project_name} ${version}" \ | ||||||
"${project_name}.zip" | ||||||
coletdjnz marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,22 @@ | ||
[build-system] | ||
requires = ["setuptools"] | ||
build-backend = "setuptools.build_meta" | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
[tool.distutils.bdist_wheel] | ||
universal = true | ||
[project] | ||
name = "yt-dlp-sample-plugins" | ||
version = "2023.01.02" | ||
readme = "README.md" | ||
requires-python = ">=3.8" | ||
license = {file = "LICENSE"} | ||
keywords = ["yt-dlp", "yt-dlp-plugin"] | ||
authors = [ | ||
{ name = "John Doe", email = "[email protected]" }, | ||
] | ||
dependencies = [] | ||
|
||
[tool.hatch.env.default] | ||
installer = "uv" | ||
path = ".venv" | ||
|
||
[tool.hatch.build.targets.wheel] | ||
packages = ["yt_dlp_plugins"] |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe?
There was a problem hiding this comment.
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...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use this at job level instead?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?