Skip to content

Commit

Permalink
update github build workflows and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
raymar9 committed May 19, 2023
1 parent 1871f51 commit 12deff7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 63 deletions.
39 changes: 15 additions & 24 deletions .github/workflows/build-deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ name: Build a Debian package
on:
push:
branches:
- '**'
- "**"
tags:
- 'v*'
- "v*"
workflow_dispatch:

permissions:
contents: write

jobs:
build-deb:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
matrix:
os: [ 'debian', 'raspios' ]
os: ["debian", "raspios"]
include:
- os: debian
dist: bullseye
Expand All @@ -29,32 +29,22 @@ jobs:

name: Build a Debian package for ${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}
steps:
- uses: actions/checkout@v2

- uses: actions/checkout@v3
- name: Update apt cache
run: |
sudo apt-get update
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.8

python-version: 3.9
cache: "pipenv"
- name: Install pipenv
run: |
python -m pip install --upgrade pip pipenv
python --version; python -m pip --version; pipenv --version
- name: Cache pipenv environment
id: cache-pipenv
uses: actions/cache@v1
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-3.8-pipenv-${{ hashFiles('**/Pipfile.lock') }}
- name: Setup project with pipenv
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: |
pipenv install --dev
pipenv --python 3.9 install --dev
- name: Prepare to build a Debian source package
run: |
sudo apt-get -y install python3-all debhelper dh-python rename
Expand All @@ -65,10 +55,11 @@ jobs:
- name: Cache pbuilder chroot
id: cache-pbuilder-chroot
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: /var/cache/pbuilder/${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}-base.tgz
key: ${{ runner.os }}-pbuilder-${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}-${{ hashFiles('**/Pipfile.lock') }}

- name: Prepare the pbuilder chroot for ${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}
if: steps.cache-pbuilder-${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}-chroot.outputs.cache-hit != 'true'
run: |
Expand All @@ -86,13 +77,13 @@ jobs:
sudo rename "s/_all\./_${{ matrix.arch }}\./" /var/cache/pbuilder/${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}/result/*.deb
- name: Archive the built Debian package for ${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}-deb
path: /var/cache/pbuilder/${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}/result/*.deb

- name: Archive the additional Debian package files for ${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}-packagefiles
path: |
Expand All @@ -102,11 +93,11 @@ jobs:
- name: Get the tag name
id: tag-name
if: startsWith(github.ref, 'refs/tags')
uses: olegtarasov/[email protected].1
uses: olegtarasov/[email protected].2

- name: Create a new release
if: startsWith(github.ref, 'refs/tags')
uses: ncipollo/release-action@v1.8.8
uses: ncipollo/release-action@v1.12.0
with:
allowUpdates: true
artifacts: /var/cache/pbuilder/${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}/result/*.deb
Expand Down
32 changes: 13 additions & 19 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,66 @@ name: Publish Python package to PyPI / Test PyPI
on:
push:
branches:
- '**'
- "**"
tags:
- 'v*'
- "v*"
workflow_dispatch:

permissions:
contents: write

jobs:
build-and-publish:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

name: Build a Python package and upload it to PyPI / Test PyPI
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.8

python-version: 3.9
cache: "pipenv"
- name: Install pipenv
run: |
python -m pip install --upgrade pip pipenv
python --version; python -m pip --version; pipenv --version
- id: cache-pipenv
uses: actions/cache@v1
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-3.8-pipenv-${{ hashFiles('**/Pipfile.lock') }}
- name: Setup project with pipenv
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: |
pipenv install --dev
pipenv --python 3.9 install --dev
- name: Build a Python package
run: |
pipenv run build
- name: Archive the built Python package
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: smartmeter-datacollector-py
path: dist/*

- name: Publish the Python package to Test PyPI
if: github.ref == 'refs/heads/master'
uses: pypa/gh-action-pypi-publish@v1.4.2
uses: pypa/gh-action-pypi-publish@v1.8.6
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true

- name: Publish the Python package to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@v1.4.2
uses: pypa/gh-action-pypi-publish@v1.8.6
with:
password: ${{ secrets.PYPI_API_TOKEN }}

- name: Get the tag name
id: tag-name
if: startsWith(github.ref, 'refs/tags')
uses: olegtarasov/[email protected].1
uses: olegtarasov/[email protected].2

- name: Create a new release
if: startsWith(github.ref, 'refs/tags')
uses: ncipollo/release-action@v1.8.8
uses: ncipollo/release-action@v1.12.0
with:
allowUpdates: true
artifacts: dist/*.tar.gz,dist/*.whl
Expand Down
26 changes: 8 additions & 18 deletions .github/workflows/python-code-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,42 @@ name: Python code checks
on:
push:
branches:
- '**'
- "**"
pull_request:
branches:
- master
workflow_dispatch:

jobs:
check_python_code:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9' ]
python-version: ["3.7", "3.8", "3.9"]

name: Running Python code checks with Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

cache: "pipenv"
- name: Install pipenv
run: |
python -m pip install --upgrade pip pipenv
python --version; python -m pip --version; pipenv --version
- name: Adjust Python version in Pipfile
run: |
sed -i 's/^python_version = .*/python_version = "${{ matrix.python-version }}"/' Pipfile
cat Pipfile
- id: cache-pipenv
uses: actions/cache@v1
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-${{ matrix.python-version }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
- name: Setup project with pipenv
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: |
pipenv install --dev
pipenv --python ${{ matrix.python-version }} install --dev
- name: Check code style
run: |
pipenv run format_check
- name: Check import order
run: |
pipenv run isort_check
- name: Lint with pylint
- name: Lint with pylint
run: |
pipenv run lint_check
- name: Run unit tests
Expand Down
4 changes: 2 additions & 2 deletions scripts/debianize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ python setup.py \
--no-python2-scripts=true \
--with-dh-systemd \
--compat=10 \
--build-depends="dh-systemd (>= 1.5)"
--build-depends="dh-python"

# add Pre-Depends to debian/control for python3-pip
sed -i 's/^\(Depends: \)/Pre-Depends: python3-pip\n\1/' debian/control
Expand All @@ -25,7 +25,7 @@ sed -i 's/${python3:Depends}/python3:any/' debian/control
# fix the debhelper compatibility level in debian/control
sed -i 's/>= 9/>= 10/' debian/control

PIP_REQUIREMENTS=$(pipenv lock -r)
PIP_REQUIREMENTS=$(pipenv requirements)

# write the debian/postinst file
cat <<EOT >> debian/postinst
Expand Down

0 comments on commit 12deff7

Please sign in to comment.