From e5edc4e5aafb3f31678c02fdd71fe8d8cb3eb470 Mon Sep 17 00:00:00 2001 From: Kishi <41839133+Kishi85@users.noreply.github.com> Date: Tue, 18 Feb 2020 13:41:35 +0100 Subject: [PATCH] Use Github Actions for automated building and release --- .drone.yml | 34 -------------- .github/workflows/release.yml | 84 +++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 34 deletions(-) delete mode 100644 .drone.yml create mode 100644 .github/workflows/release.yml diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 83a44d2..0000000 --- a/.drone.yml +++ /dev/null @@ -1,34 +0,0 @@ -kind: pipeline -name: python37-buster - -steps: -- name: build - image: debian:buster-slim - commands: - - apt update -qq -y - - apt install -qq -y build-essential fakeroot git python-all python3-cryptography python3-stdeb python3-wheel - - git fetch --tags - - python3 setup.py sdist bdist_wheel - - sed "s/=determine_version()/='$(python3 setup.py --version)'/gi" -i setup.py - - sed "s@('readme'@('share/doc/python3-acertmgr'@" -i setup.py - - python3 setup.py --command-packages=stdeb.command bdist_deb - - python3 setup.py --version > version.github -- name: pypi_publish - image: plugins/pypi - settings: - username: __token__ - password: - from_secret: pypi_token - skip_build: True - when: - event: tag -- name: github_publish - image: plugins/github-release - settings: - api_key: - from_secret: github_token - draft: true - files: deb_dist/*.deb - title: version.github - when: - event: tag diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ca8d0bb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,84 @@ +--- +name: Build (and release) +on: [ push, pull_request ] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install dependencies + run: | + sudo apt update -qq -y + sudo apt install -qq -y build-essential fakeroot git python-all python3-cryptography python3-stdeb python3-wheel twine + + - name: Prepare build process + id: buildprep + run: | + # Fetch tags and determine version + git fetch --tags + VER="$(python3 setup.py --version)" + echo "Version found: $VER" + echo "::set-output name=version::$VER" + + - name: Build python package using setuptools (source/wheel) + run: | + python3 setup.py sdist --formats=gztar + python3 setup.py bdist_wheel + + - name: Prepare stdeb build process + run: | + sed "s/=determine_version()/='$(python3 setup.py --version)'/gi" -i setup.py + sed "s@('readme'@('share/doc/python3-acertmgr'@" -i setup.py + - name: Build debian package using setuptools and stdeb + run: python3 setup.py --command-packages=stdeb.command bdist_deb + + - name: Create a changelog from git log since last non-pre/rc tag + run: | + # Determine current tag and last non-rc/pre tag + CTAG="$(git describe --tags --abbrev=0)" + LTAG="$(git tag | grep -B1 ${CTAG} | head -n1)" + while echo $LTAG | grep -q 'rc\|pre'; do + LTAG="$(git tag | grep -B1 ${LTAG} | head -n1)" + done + # Write changelog + echo "Changes since ${LTAG}:" > changelog.txt + git log --format=' * %s' ${LTAG}..${CTAG} >> changelog.txt + cat changelog.txt + + - name: Collect files for artifact upload + run: | + mkdir -v artifacts + cp -v changelog.txt artifacts/ + cp -v dist/*.tar.gz artifacts/ + cp -v dist/*.whl artifacts/ + cp -v deb_dist/*.deb artifacts/ + - name: Upload build artifact + uses: actions/upload-artifact@v1 + with: + name: ${{ format('acertmgr_build_{0}', steps.buildprep.outputs.version) }} + path: artifacts + + - name: Create new GitHub release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + name: ${{ steps.buildprep.outputs.version }} + draft: true + prerelease: ${{ contains(github.ref, 'rc') || contains(github.ref, 'pre') }} + body_path: changelog.txt + files: | + artifacts/*.tar.gz + artifacts/*.whl + artifacts/*.deb + + - name: Create new PyPI release + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + if: "startsWith(github.ref, 'refs/tags/') && (!(contains(github.ref, 'rc') || contains(github.ref, 'pre')))" + run: | + if [ "$TWINE_USERNAME" != '' -a "$TWINE_PASSWORD" != '' ]; then + twine upload dist/* + fi