First draft of release #6
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: Create release | |
on: [push] | |
jobs: | |
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" | |
- name: Install Hatch | |
run: pipx install hatch | |
- name: Set variables | |
id: set_variables | |
run: | | |
echo "::group::Variables" | |
cat << EOF | tee -a "$GITHUB_OUTPUT" | |
tag=$(git describe --tags --abbrev=0) | |
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)" | |
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 | |
package_name="$(tr '[:upper:]' '[:lower:]' <<<"${name}" | sed 's/-/_/g')" | |
cp -r "${path}/${package_name}" bundle/ | |
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" |