Skip to content

Commit

Permalink
ci: release flow
Browse files Browse the repository at this point in the history
  • Loading branch information
markokr committed Jul 19, 2020
1 parent ff18745 commit 0a5f0e3
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 16 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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

47 changes: 35 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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)

4 changes: 2 additions & 2 deletions doc/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ rarfile history

.. py:currentmodule:: rarfile
unreleased
----------
Version 3.2a1 (2020-07-20)
--------------------------

New features:

Expand Down
20 changes: 20 additions & 0 deletions doc/note.awk
Original file line number Diff line number Diff line change
@@ -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")
}
}

4 changes: 2 additions & 2 deletions rarfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# rarfile.py
#
# Copyright (c) 2005-2019 Marko Kreen <markokr@gmail.com>
# Copyright (c) 2005-2020 Marko Kreen <markokr@gmail.com>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
Expand Down Expand Up @@ -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"]
Expand Down

0 comments on commit 0a5f0e3

Please sign in to comment.