2020-02-18 13:41:35 +01:00
|
|
|
---
|
|
|
|
name: Build (and release)
|
|
|
|
on: [ push, pull_request ]
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
2020-02-19 10:35:31 +01:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2020-10-12 17:22:03 +02:00
|
|
|
|
2020-02-18 13:41:35 +01:00
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
sudo apt update -qq -y
|
2020-10-12 19:22:02 +02:00
|
|
|
sudo apt install -qq -y build-essential fakeroot git python-all python3-cryptography python3-pip python3-stdeb python3-wheel twine
|
|
|
|
sudo pip3 install --upgrade setuptools wheel
|
2020-02-18 13:41:35 +01:00
|
|
|
|
|
|
|
- name: Prepare build process
|
|
|
|
id: buildprep
|
|
|
|
run: |
|
|
|
|
# Fetch tags and determine version
|
2020-03-04 17:29:11 +01:00
|
|
|
git fetch --tags -f
|
2020-02-18 13:41:35 +01:00
|
|
|
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
|
2020-02-19 10:35:31 +01:00
|
|
|
id: stdebprep
|
2020-02-18 13:41:35 +01:00
|
|
|
run: |
|
2020-02-19 10:35:31 +01:00
|
|
|
# Patch setup.py to allow stdeb proper debian style builds
|
2020-02-18 13:41:35 +01:00
|
|
|
sed "s/=determine_version()/='$(python3 setup.py --version)'/gi" -i setup.py
|
|
|
|
sed "s@('readme'@('share/doc/python3-acertmgr'@" -i setup.py
|
2020-02-19 10:35:31 +01:00
|
|
|
# Determine recommended dependencies for deb package
|
|
|
|
echo "::set-output name=recommends3::$(echo "python3-pkg-resources")"
|
|
|
|
# Find optional dependencies to suggest in deb package
|
|
|
|
echo "::set-output name=suggests3::$(python3 -c "from setup import extra_requirements; print('\n'.join(['\n'.join(x) for x in extra_requirements.values()]))" | grep -v cryptography | sed 's/PyYAML/yaml/gi' | awk '{ printf("python3-%s, ",$1)};' | awk '{$1=$1; print}')"
|
|
|
|
|
2020-02-18 13:41:35 +01:00
|
|
|
- name: Build debian package using setuptools and stdeb
|
2020-02-19 10:35:31 +01:00
|
|
|
run: python3 setup.py --command-packages=stdeb.command sdist_dsc --with-python2=False --with-python3=True --recommends3="${{ steps.stdebprep.outputs.recommends3 }}" --suggests3="${{ steps.stdebprep.outputs.suggests3 }}" bdist_deb
|
2020-02-18 13:41:35 +01:00
|
|
|
|
|
|
|
- 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/
|
2020-10-12 17:22:03 +02:00
|
|
|
|
2020-02-18 13:41:35 +01:00
|
|
|
- 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
|
2020-10-12 19:01:09 +02:00
|
|
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && (!(contains(github.ref, 'rc') || contains(github.ref, 'pre')))
|
|
|
|
uses: pypa/gh-action-pypi-publish@master
|
|
|
|
with:
|
|
|
|
user: ${{ secrets.PYPI_USERNAME }}
|
|
|
|
password: ${{ secrets.PYPI_PASSWORD }}
|