|
| 1 | +name: Build and Publish Debian Package |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + |
| 6 | +jobs: |
| 7 | + build: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + env: |
| 10 | + DEB_BUILD_OPTIONS: nocheck # or whatever options you need |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + distro: [debian-bookworm, debian-bullseye, ubuntu-24.04, ubuntu-22.04] |
| 14 | + include: |
| 15 | + - distro: debian-bookworm |
| 16 | + image: debian:bookworm |
| 17 | + os: debian |
| 18 | + version: bookworm |
| 19 | + - distro: debian-bullseye |
| 20 | + image: debian:bullseye |
| 21 | + os: debian |
| 22 | + version: bullseye |
| 23 | + - distro: ubuntu-24.04 |
| 24 | + image: ubuntu:24.04 |
| 25 | + os: ubuntu |
| 26 | + version: noble |
| 27 | + - distro: ubuntu-22.04 |
| 28 | + image: ubuntu:22.04 |
| 29 | + os: ubuntu |
| 30 | + version: jammy |
| 31 | + container: |
| 32 | + image: ${{ matrix.image }} |
| 33 | + steps: |
| 34 | + - name: Setup dependencies |
| 35 | + run: | |
| 36 | + apt-get update |
| 37 | + apt-get install -y build-essential devscripts debhelper autotools-dev autoconf-archive \ |
| 38 | + pkg-config fakeroot sed git tar gzip python3-pip python3-venv curl jq libyaml-cpp-dev |
| 39 | +
|
| 40 | + curl -1sLf 'https://dl.cloudsmith.io/basic/robertburger/common/setup.deb.sh' | bash |
| 41 | + curl -1sLf 'https://dl.cloudsmith.io/basic/robertburger/robotkernel/setup.deb.sh' | bash |
| 42 | + apt-get update |
| 43 | + apt-get install -y libethercat libosal robotkernel-service-helper robotkernel-dev \ |
| 44 | + service-provider-canopen-protocol-dev \ |
| 45 | + service-provider-file-protocol-dev \ |
| 46 | + service-provider-key-value-dev \ |
| 47 | + service-provider-memory-inspection-dev \ |
| 48 | + service-provider-process-data-inspection-dev \ |
| 49 | + service-provider-sercos-protocol-dev |
| 50 | +
|
| 51 | + - name: Checkout code |
| 52 | + uses: actions/checkout@v4 |
| 53 | + |
| 54 | + - name: Mark working directory as safe |
| 55 | + run: git config --global --add safe.directory $GITHUB_WORKSPACE |
| 56 | + |
| 57 | + - name: update branch name |
| 58 | + run: | |
| 59 | + VERSION=$(dpkg-parsechangelog | sed -n 's/^Version: //p') |
| 60 | + sed "s|PACKAGE_VERSION|$VERSION|" configure.ac.in > configure.ac |
| 61 | + env: |
| 62 | + GITHUB_REF_NAME: ${{ github.ref_name }} |
| 63 | + |
| 64 | + - name: Build .deb package |
| 65 | + run: | |
| 66 | + # baue mit dpkg-buildpackage (ohne signieren) |
| 67 | + dpkg-buildpackage -us -uc -d |
| 68 | +
|
| 69 | + - name: Collect .deb artifact |
| 70 | + run: | |
| 71 | + mkdir -p artifacts/${{ matrix.os }}/${{ matrix.version }} |
| 72 | + mv ../module-ethercat*.deb artifacts/${{ matrix.os }}/${{ matrix.version }} |
| 73 | + |
| 74 | + - name: Set sanitized image name |
| 75 | + id: sanitize |
| 76 | + run: | |
| 77 | + version=$(dpkg-parsechangelog | sed -n 's/^Version: //p') |
| 78 | + echo "sanitized_image=$(echo "$version-$IMAGE" | tr '/:' '--')" >> $GITHUB_OUTPUT |
| 79 | + env: |
| 80 | + IMAGE: ${{ matrix.image }} |
| 81 | + |
| 82 | + - name: Upload .deb package |
| 83 | + uses: actions/upload-artifact@v4 |
| 84 | + with: |
| 85 | + name: module-ethercat-${{ steps.sanitize.outputs.sanitized_image }}.deb |
| 86 | + path: artifacts/${{ matrix.os }}/${{ matrix.version }}/*.deb |
| 87 | + |
| 88 | + - name: Upload to Cloudsmith (${{ matrix.os }}/${{ matrix.version }}) |
| 89 | + env: |
| 90 | + CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }} |
| 91 | + shell: bash |
| 92 | + run: | |
| 93 | + VERSION=$(dpkg-parsechangelog | sed -n 's/^Version: //p') |
| 94 | + FILENAME="artifacts/${{ matrix.os }}/${{ matrix.version }}/module-ethercat_${VERSION}_amd64.deb" |
| 95 | + FILENAME_DEV="artifacts/${{ matrix.os }}/${{ matrix.version }}/module-ethercat-dev_${VERSION}_amd64.deb" |
| 96 | + |
| 97 | + python3 -m venv cloudsmith |
| 98 | + cd cloudsmith |
| 99 | + source bin/activate |
| 100 | +
|
| 101 | + python3 -m pip install --upgrade pip |
| 102 | + pip3 install cloudsmith-cli |
| 103 | +
|
| 104 | + cloudsmith push deb robertburger/robotkernel/${{ matrix.os }}/${{ matrix.version }} ../${FILENAME} \ |
| 105 | + --republish \ |
| 106 | + --api-key "$CLOUDSMITH_API_KEY" |
| 107 | + |
| 108 | + cloudsmith push deb robertburger/robotkernel/${{ matrix.os }}/${{ matrix.version }} ../${FILENAME_DEV} \ |
| 109 | + --republish \ |
| 110 | + --api-key "$CLOUDSMITH_API_KEY" |
0 commit comments