diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..dc1b740 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,79 @@ +# +# https://docs.github.com/en/actions/reference +# https://github.com/actions +# + +name: REL + +on: + push: + tags: ["v[0-9]*"] + +jobs: + release: + name: "Publish" + runs-on: ubuntu-20.04 + steps: + + - name: "Checkout code" + id: checkout + uses: actions/checkout@v2 + + - name: "Setup Python" + id: setup + uses: actions/setup-python@v2 + with: + python-version: "3.8" + + - name: "Build tarball" + id: build + run: | + python -m pip install setuptools wheel + echo "::group::sdist" + PACKAGE=$(python setup.py --name) + VERSION=$(python setup.py --version) + TGZ="${PACKAGE}-${VERSION}.tar.gz" + test "${{github.ref}}" = "refs/tags/v${VERSION}" || { echo "ERR: tag mismatch"; exit 1; } + python setup.py sdist + test -f "dist/${TGZ}" || { echo "ERR: sdist failed"; exit 1; } + echo "::set-env name=PACKAGE::${PACKAGE}" + echo "::set-env name=VERSION::${VERSION}" + echo "::set-env name=TGZ::${TGZ}" + echo "::endgroup::" + + - name: "Install pandoc" + id: install-pandoc + run: | + sudo -nH apt-get -u -y install pandoc + pandoc --version + + - name: "Prepare release notes" + id: prepare-notes + run: | + mkdir -p tmp + make -s shownote > tmp/note.md + cat tmp/note.md + + - name: "Create release" + id: release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + with: + tag_name: ${{github.ref}} + release_name: ${{env.PACKAGE}} v${{env.VERSION}} + body_path: tmp/note.md + prerelease: ${{contains(env.VERSION, 'a') || contains(env.VERSION, 'b') || contains(env.VERSION, 'rc')}} + draft: true + + - name: "Upload source" + id: upload + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + with: + upload_url: ${{steps.release.outputs.upload_url}} + asset_path: dist/${{env.TGZ}} + asset_name: ${{env.TGZ}} + asset_content_type: application/x-gzip + diff --git a/Makefile b/Makefile index 1c1f3a6..61246ee 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,16 @@ -VER := $(shell python3 setup.py --version) -TGZ = dist/rarfile-$(VER).tar.gz - prefix = /usr/local +REPO = https://github.com/markokr/rarfile +NEWS = doc/news.rst + +PACKAGE = $(shell python3 setup.py --name) +VERSION = $(shell python3 setup.py --version) +RXVERSION = $(shell python3 setup.py --version | sed 's/\./[.]/g') +TAG = v$(VERSION) +TGZ = dist/$(PACKAGE)-$(VERSION).tar.gz +URL = $(REPO)/releases/download/v$(VERSION)/$(PACKAGE)-$(VERSION).tar.gz + all: pyflakes3 rarfile.py tox -e lint @@ -12,8 +19,6 @@ all: install: python setup.py install --prefix=$(prefix) -sdist: clean $(TGZ) - clean: rm -rf __pycache__ build dist .tox rm -f *.pyc MANIFEST *.orig *.rej *.html *.class test/*.pyc @@ -25,15 +30,33 @@ clean: toxclean: clean rm -rf .tox -$(TGZ): - rm -f dist/* - python3 setup.py sdist - -upload: $(TGZ) - twine upload $(TGZ) - ack: for fn in test/files/*.py27; do \ cp $$fn `echo $$fn | sed 's/py27/exp/'` || exit 1; \ done +prepare: + @echo "Checking version - $(VERSION)" + @grep -qE '^\w+ $(RXVERSION)\b' $(NEWS) \ + || { echo "Version '$(VERSION)' not in $(NEWS)"; exit 1; } + @echo "Checking git repo" + @git diff --stat --exit-code || { echo "ERROR: Unclean repo"; exit 1; } + +release: prepare + git tag $(TAG) + git push github $(TAG):$(TAG) + +upload: + mkdir -p dist && rm -f dist/* + cd dist && wget -q $(URL) + tar tvf $(TGZ) + twine upload $(TGZ) + +shownote: + awk -v VER="$(VERSION)" -f doc/note.awk $(NEWS) \ + | pandoc -f rst -t gfm --wrap=none + +unrelease: + git push github :$(TAG) + git tag -d $(TAG) + diff --git a/doc/news.rst b/doc/news.rst index 25a5a65..a9a27a0 100644 --- a/doc/news.rst +++ b/doc/news.rst @@ -4,8 +4,8 @@ rarfile history .. py:currentmodule:: rarfile -unreleased ----------- +Version 3.2a1 (2020-07-20) +-------------------------- New features: diff --git a/doc/note.awk b/doc/note.awk new file mode 100644 index 0000000..a5f1a5f --- /dev/null +++ b/doc/note.awk @@ -0,0 +1,20 @@ +# extract version notes for version VER + +/^[-_0-9a-zA-Z]+ v?[0-9]/ { + if ($2 == VER) { + good = 1 + next + } else { + good = 0 + } +} + +/^(===|---)/ { next } + +{ + if (good) { + # also remove sphinx syntax + print gensub(/:(data|class|attr|meth):`([^`]+)`/, "``\\2``", "g") + } +} + diff --git a/rarfile.py b/rarfile.py index 64a8169..59de75a 100644 --- a/rarfile.py +++ b/rarfile.py @@ -1,6 +1,6 @@ # rarfile.py # -# Copyright (c) 2005-2019 Marko Kreen +# Copyright (c) 2005-2020 Marko Kreen # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -111,7 +111,7 @@ def tohex(data): return hexlify(data).decode("ascii") -__version__ = "3.1" +__version__ = "3.2a1" # export only interesting items __all__ = ["is_rarfile", "is_rarfile_sfx", "RarInfo", "RarFile", "RarExtFile"]