[RELEASE] Package ytdl-sub to PyPI (#457)
* post only if > 0 * since todays date * pypi workflow * test token * fix test * long description * simpler names * more simple * no test pypi in master * publish only on master
This commit is contained in:
parent
2231bd43c8
commit
c39393e69a
7 changed files with 61 additions and 15 deletions
8
.github/workflows/package.yaml
vendored
8
.github/workflows/package.yaml
vendored
|
|
@ -20,7 +20,7 @@ jobs:
|
||||||
# Push image to GitHub Packages.
|
# Push image to GitHub Packages.
|
||||||
# See also https://docs.docker.com/docker-hub/builds/
|
# See also https://docs.docker.com/docker-hub/builds/
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: [ "3.10" ]
|
python-version: [ "3.10" ]
|
||||||
|
|
@ -49,7 +49,7 @@ jobs:
|
||||||
|
|
||||||
# Build ARM64 container, only on master branch to save time testing
|
# Build ARM64 container, only on master branch to save time testing
|
||||||
package-arm64:
|
package-arm64:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
needs: [
|
needs: [
|
||||||
build
|
build
|
||||||
]
|
]
|
||||||
|
|
@ -93,7 +93,7 @@ jobs:
|
||||||
|
|
||||||
# Build AMD64 container
|
# Build AMD64 container
|
||||||
package-amd64:
|
package-amd64:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
needs: [
|
needs: [
|
||||||
build
|
build
|
||||||
]
|
]
|
||||||
|
|
@ -137,7 +137,7 @@ jobs:
|
||||||
# On master branch, build the docker manifest file from the cached
|
# On master branch, build the docker manifest file from the cached
|
||||||
# docker builds and push to the registry
|
# docker builds and push to the registry
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
needs: [
|
needs: [
|
||||||
build,
|
build,
|
||||||
package-arm64,
|
package-arm64,
|
||||||
|
|
|
||||||
32
.github/workflows/pypi.yaml
vendored
Normal file
32
.github/workflows/pypi.yaml
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
name: ytld-sub PyPI
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
# publish only when pushed to master
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-publish:
|
||||||
|
name: build-and-publish
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: [ "3.10" ]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v3
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
|
- name: Build Wheel
|
||||||
|
run: |
|
||||||
|
make wheel
|
||||||
|
|
||||||
|
- name: Publish distribution 📦 to PyPI
|
||||||
|
if: ${{ github.ref == 'refs/heads/master' }}
|
||||||
|
uses: pypa/gh-action-pypi-publish@release/v1
|
||||||
|
with:
|
||||||
|
password: ${{ secrets.PYPI_API_TOKEN }}
|
||||||
18
Makefile
18
Makefile
|
|
@ -1,7 +1,17 @@
|
||||||
|
# Get version related variables
|
||||||
export DATE=$(shell date +'%Y.%m.%d')
|
export DATE=$(shell date +'%Y.%m.%d')
|
||||||
export REV=$(shell git rev-parse --short HEAD)
|
export DATE_COMMIT_COUNT=$(shell git rev-list --count HEAD --since="$(DATE) 00:00:00")
|
||||||
export VERSION="$(DATE)+$(REV)"
|
export COMMIT_HASH=$(shell git rev-parse --short HEAD)
|
||||||
|
|
||||||
|
# Set Local version to YYYY.MM.DD-<hash>
|
||||||
|
export LOCAL_VERSION="$(DATE)+$(COMMIT_HASH)"
|
||||||
|
|
||||||
|
# Set PyPi version to YYYY.MM.DD or YYYY.MM.DD.postN if N > 0
|
||||||
|
ifeq ("$(DATE_COMMIT_COUNT)", "0")
|
||||||
|
export PYPI_VERSION="$(DATE)"
|
||||||
|
else
|
||||||
|
export PYPI_VERSION="$(DATE).post$(DATE_COMMIT_COUNT)"
|
||||||
|
endif
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
@-isort .
|
@-isort .
|
||||||
|
|
@ -14,7 +24,7 @@ check_lint:
|
||||||
&& pylint src/ \
|
&& pylint src/ \
|
||||||
&& pydocstyle src/*
|
&& pydocstyle src/*
|
||||||
wheel: clean
|
wheel: clean
|
||||||
$(shell echo "__version__ = \"$(VERSION)\"" > src/ytdl_sub/__init__.py)
|
$(shell echo "__pypi_version__ = \"$(PYPI_VERSION)\"\n__local_version__ = \"$(LOCAL_VERSION)\"" > src/ytdl_sub/__init__.py)
|
||||||
pip3 install build
|
pip3 install build
|
||||||
python3 -m build
|
python3 -m build
|
||||||
docker_stage: wheel
|
docker_stage: wheel
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
[metadata]
|
[metadata]
|
||||||
name = ytdl-sub
|
name = ytdl-sub
|
||||||
version = attr:ytdl_sub.__version__
|
version = attr:ytdl_sub.__pypi_version__
|
||||||
author = Jesse Bannon
|
author = Jesse Bannon
|
||||||
description = ytdl automated with metadata creation
|
description = Automate downloading and metadata generation with YoutubeDL
|
||||||
|
long_description = file: README.md
|
||||||
|
long_description_content_type= text/markdown
|
||||||
author_email = use_github_issues@nope.com
|
author_email = use_github_issues@nope.com
|
||||||
url = https://github.com/jmbannon/ytdl-sub
|
url = https://github.com/jmbannon/ytdl-sub
|
||||||
license = GNUv3
|
license = GNUv3
|
||||||
|
|
@ -50,4 +52,5 @@ docs =
|
||||||
sphinx-rtd-theme==1.0.0
|
sphinx-rtd-theme==1.0.0
|
||||||
build =
|
build =
|
||||||
build
|
build
|
||||||
|
twine
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
__version__ = "2023.02.20+30051b1"
|
__pypi_version__ = "2023.02.20.post14"
|
||||||
|
__local_version__ = "2023.02.20+6896905"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from ytdl_sub import __version__
|
from ytdl_sub import __local_version__
|
||||||
from ytdl_sub.cli.main_args_parser import parser
|
from ytdl_sub.cli.main_args_parser import parser
|
||||||
from ytdl_sub.utils.exceptions import ValidationException
|
from ytdl_sub.utils.exceptions import ValidationException
|
||||||
from ytdl_sub.utils.logger import Logger
|
from ytdl_sub.utils.logger import Logger
|
||||||
|
|
@ -36,7 +36,7 @@ def main():
|
||||||
"Version %s\nPlease upload the error log file '%s' and make a Github "
|
"Version %s\nPlease upload the error log file '%s' and make a Github "
|
||||||
"issue at https://github.com/jmbannon/ytdl-sub/issues with your config and "
|
"issue at https://github.com/jmbannon/ytdl-sub/issues with your config and "
|
||||||
"command/subscription yaml file to reproduce. Thanks for trying ytdl-sub!",
|
"command/subscription yaml file to reproduce. Thanks for trying ytdl-sub!",
|
||||||
__version__,
|
__local_version__,
|
||||||
Logger.debug_log_filename(),
|
Logger.debug_log_filename(),
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from src.ytdl_sub import __version__
|
from src.ytdl_sub import __local_version__
|
||||||
from src.ytdl_sub.main import main
|
from src.ytdl_sub.main import main
|
||||||
from ytdl_sub.utils.exceptions import ValidationException
|
from ytdl_sub.utils.exceptions import ValidationException
|
||||||
from ytdl_sub.utils.logger import Logger
|
from ytdl_sub.utils.logger import Logger
|
||||||
|
|
@ -64,5 +64,5 @@ def test_main_uncaught_error(capsys, mock_sys_exit, expected_uncaught_error_mess
|
||||||
|
|
||||||
assert mock_error.call_count == 1
|
assert mock_error.call_count == 1
|
||||||
assert mock_error.call_args.args[0] == expected_uncaught_error_message
|
assert mock_error.call_args.args[0] == expected_uncaught_error_message
|
||||||
assert mock_error.call_args.args[1] == __version__
|
assert mock_error.call_args.args[1] == __local_version__
|
||||||
assert mock_error.call_args.args[2] == Logger.debug_log_filename()
|
assert mock_error.call_args.args[2] == Logger.debug_log_filename()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue