|
| 1 | +name: Build a Debian package |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '**' |
| 7 | + tags: |
| 8 | + - 'v*' |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + build-deb: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + os: [ 'debian', 'raspios' ] |
| 20 | + include: |
| 21 | + - os: debian |
| 22 | + dist: buster |
| 23 | + arch: amd64 |
| 24 | + keyring_cmd: sudo apt-get install -y debian-archive-keyring |
| 25 | + - os: raspios |
| 26 | + dist: buster |
| 27 | + arch: armhf |
| 28 | + keyring_cmd: wget http://archive.raspbian.org/raspbian/pool/main/r/raspbian-archive-keyring/raspbian-archive-keyring_20120528.2_all.deb && sudo dpkg -i raspbian-archive-keyring_20120528.2_all.deb |
| 29 | + |
| 30 | + name: Build a Debian package for ${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }} |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v2 |
| 33 | + - name: Set up Python |
| 34 | + uses: actions/setup-python@v1 |
| 35 | + with: |
| 36 | + python-version: 3.8 |
| 37 | + |
| 38 | + - name: Install pipenv |
| 39 | + run: | |
| 40 | + python -m pip install --upgrade pip pipenv |
| 41 | + python --version; python -m pip --version; pipenv --version |
| 42 | + - id: cache-pipenv |
| 43 | + uses: actions/cache@v1 |
| 44 | + with: |
| 45 | + path: ~/.local/share/virtualenvs |
| 46 | + key: ${{ runner.os }}-3.8-pipenv-${{ hashFiles('**/Pipfile.lock') }} |
| 47 | + - name: Setup project with pipenv |
| 48 | + if: steps.cache-pipenv.outputs.cache-hit != 'true' |
| 49 | + run: | |
| 50 | + pipenv install --dev |
| 51 | +
|
| 52 | + - name: Prepare to build a Debian source package |
| 53 | + run: | |
| 54 | + sudo apt-get -y install python3-all debhelper dh-python dh-systemd |
| 55 | +
|
| 56 | + - name: Build a Debian source package |
| 57 | + run: | |
| 58 | + pipenv run build_srcdeb |
| 59 | +
|
| 60 | + - id: cache-pbuilder-chroot |
| 61 | + uses: actions/cache@v1 |
| 62 | + with: |
| 63 | + path: /var/cache/pbuilder/${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}-base.tgz |
| 64 | + key: ${{ runner.os }}-pbuilder-${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}-${{ hashFiles('**/Pipfile.lock') }} |
| 65 | + - name: Prepare the pbuilder chroot for ${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }} |
| 66 | + if: steps.cache-pbuilder-${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}-chroot.outputs.cache-hit != 'true' |
| 67 | + run: | |
| 68 | + sudo apt-get install -y pbuilder qemu-user-static |
| 69 | + ${{ matrix.keyring_cmd }} |
| 70 | + sudo cp scripts/.pbuilderrc /root/ |
| 71 | + sudo mkdir -p /var/cache/pbuilder/${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}/aptcache/ |
| 72 | + sudo OS=${{ matrix.os }} DIST=${{ matrix.dist }} ARCH=${{ matrix.arch }} pbuilder --create |
| 73 | +
|
| 74 | + - name: Build the Debian package for ${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }} using pbuilder |
| 75 | + run: | |
| 76 | + cd deb_dist |
| 77 | + sudo OS=${{ matrix.os }} DIST=${{ matrix.dist }} ARCH=${{ matrix.arch }} pbuilder build *.dsc |
| 78 | +
|
| 79 | + - name: Archive the built Debian package for ${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }} |
| 80 | + uses: actions/upload-artifact@v2 |
| 81 | + with: |
| 82 | + name: ${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}-deb |
| 83 | + path: /var/cache/pbuilder/${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}/result/*.deb |
| 84 | + |
| 85 | + - name: Archive the additional Debian package files for ${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }} |
| 86 | + uses: actions/upload-artifact@v2 |
| 87 | + with: |
| 88 | + name: ${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}-packagefiles |
| 89 | + path: | |
| 90 | + /var/cache/pbuilder/${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}/result/*.dsc |
| 91 | + /var/cache/pbuilder/${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}/result/*.tar.* |
| 92 | +
|
| 93 | + - name: Get the tag name |
| 94 | + id: tag-name |
| 95 | + if: startsWith(github.ref, 'refs/tags') |
| 96 | + uses: olegtarasov/get-tag@v2.1.1 |
| 97 | + |
| 98 | + - name: Create a new release |
| 99 | + if: startsWith(github.ref, 'refs/tags') |
| 100 | + uses: ncipollo/release-action@v1.8.8 |
| 101 | + with: |
| 102 | + allowUpdates: true |
| 103 | + artifacts: /var/cache/pbuilder/${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.arch }}/result/*.deb |
| 104 | + draft: true |
| 105 | + name: Smart Meter Data Collector ${{ steps.tag-name.outputs.tag }} |
| 106 | + omitBody: true |
| 107 | + omitBodyDuringUpdate: true |
| 108 | + omitNameDuringUpdate: true |
| 109 | + omitPrereleaseDuringUpdate: true |
| 110 | + token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments