diff --git a/.github/workflows/build_snap.yml b/.github/workflows/build_snap.yml new file mode 100644 index 0000000..5d663fc --- /dev/null +++ b/.github/workflows/build_snap.yml @@ -0,0 +1,51 @@ +name: Build Snap + +on: + push: + branches: + - 'master' + tags: + - '*.*.*' + +jobs: + build-and-release: + runs-on: ubuntu-latest + strategy: + matrix: + architecture: + - amd64 + - armhf + - arm64 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: weetmuts/wmbusmeters + tags: type=ref,event=tag + - name: Build + id: build + uses: diddlesnaps/snapcraft-multiarch-action@v1 + with: + architecture: ${{ matrix.architecture }} + - name: Publish release to Stable + uses: snapcore/action-publish@v1 + if: ${{ steps.meta.outputs.tags }} + env: + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.snapcraft_token }} + with: + snap: ${{ steps.build.outputs.snap }} + release: stable + - name: Publish latest to Edge + uses: snapcore/action-publish@v1 + if: ${{ !steps.meta.outputs.tags }} + env: + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.snapcraft_token }} + with: + snap: ${{ steps.build.outputs.snap }} + release: edge \ No newline at end of file diff --git a/.github/workflows/promote_snap.sh b/.github/workflows/promote_snap.sh deleted file mode 100644 index e45412d..0000000 --- a/.github/workflows/promote_snap.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -SNAP_NAME="wmbusmeters" -ARCH_LIST="arm64 armhf amd64" - -if [ -n "$(git describe --tags | grep -)" ]; then - GIT_REV="$(git describe --tags | cut -f1,2 -d'-')" - echo "$GIT_REV is branch not tag release, exiting.." - exit 1 -else - GIT_VER="$(git describe --tags)" - echo "This is release - $GIT_VER" -fi - -if $(timeout 5 snapcraft status $SNAP_NAME >/dev/null); then - echo "snapcraft login sucessfull, continuing" -else - echo "Looks like snapcraft login is not sucessfull, exiting...." - exit 1 -fi - -for arch in $ARCH_LIST -do - snap_build_version="$(snapcraft status --arch $arch $SNAP_NAME | grep edge | awk '{print $2}')" - - c=0 - while [[ "$GIT_VER" != "$snap_build_version" && $c -lt 30 ]]; do - echo "GIT release version "$GIT_VER" != snap latest edge version at snapcraft for $arch "$snap_build_version", iter : $c"; - ((c = $c + 1)); - sleep 300; - snap_build_version="$(snapcraft status --arch $arch $SNAP_NAME | grep edge | awk '{print $2}')" - done - - if [[ "$GIT_VER" != "$snap_build_version" ]]; then - echo "GIT release version "$GIT_VER" != snap latest edge version on snapcraft for $arch "$snap_build_version", exiting.."; - exit 1 - fi -done - -for arch in $ARCH_LIST -do - snap_build_id="$(snapcraft status --arch $arch $SNAP_NAME | grep edge | awk '{print $3}')" - echo "Snap build id for arch $arch - $snap_build_id, promoting to stable release" - snapcraft release $SNAP_NAME $snap_build_id stable -done diff --git a/.github/workflows/promote_snap.yml b/.github/workflows/promote_snap.yml deleted file mode 100644 index 5fc7394..0000000 --- a/.github/workflows/promote_snap.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Promote snap from edge to stable channel -on: - push: - tags: - - '*' - -jobs: - initial_sleep: - runs-on: ubuntu-latest - steps: - - name: Sleep for 30 minutes - uses: jakejarvis/wait-action@master - with: - time: '30m' - promote: - needs: initial_sleep - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - run: git fetch --prune --unshallow - - name: Install Snapcraft - uses: samuelmeuli/action-snapcraft@v1 - with: - snapcraft_token: ${{ secrets.snapcraft_token }} - - name: Run promote script - run: bash .github/workflows/promote_snap.sh \ No newline at end of file diff --git a/README.md b/README.md index 92e3d9a..e13eb9f 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ The program runs on GNU/Linux, MacOSX, FreeBSD, and Raspberry Pi. | Ubuntu | [![Build Ubuntu Status](https://github.com/weetmuts/wmbusmeters/workflows/Build%20Ubuntu/badge.svg)](https://github.com/weetmuts/wmbusmeters/actions)| | MacOSX | [![Build MacOSX Status](https://github.com/weetmuts/wmbusmeters/workflows/Build%20MacOSX/badge.svg)](https://github.com/weetmuts/wmbusmeters/actions)| | Docker | [![Build Docker Status](https://github.com/weetmuts/wmbusmeters/workflows/Build%20docker/badge.svg)](https://hub.docker.com/r/weetmuts/wmbusmeters/)| -| Snap | [![wmbusmeters](https://snapcraft.io//wmbusmeters/badge.svg)](https://snapcraft.io/wmbusmeters)| +| Snap | [![Build Snap Status](https://github.com/weetmuts/wmbusmeters/workflows/Build%20Snap/badge.svg)](https://snapcraft.io/wmbusmeters)| # Distributions diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 7cce547..cadd4cb 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -10,18 +10,18 @@ description: | to allow snap read USB devices and check that root user of your system is added to group that can read USB devices -base: core18 +base: core22 confinement: strict architectures: - build-on: amd64 - run-on: amd64 + build-for: amd64 - build-on: arm64 - run-on: arm64 + build-for: arm64 - build-on: armhf - run-on: armhf + build-for: armhf parts: script: @@ -34,15 +34,15 @@ parts: source: "https://github.com/weetmuts/wmbusmeters.git" source-type: git override-pull: | - snapcraftctl pull + craftctl default if [ -n "$(git describe --tags | grep -)" ]; then GIT_REV="$(git describe --tags | cut -f1,2 -d'-')" - snapcraftctl set-version "$GIT_REV" - snapcraftctl set-grade devel + craftctl set version="$GIT_REV" + craftctl set grade=devel else GIT_VER="$(git describe --tags)" - snapcraftctl set-version "$GIT_VER" - snapcraftctl set-grade stable + craftctl set version="$GIT_VER" + craftctl set grade=stable fi plugin: autotools build-packages: @@ -68,20 +68,14 @@ parts: rtl-wmbus: source: "https://github.com/weetmuts/rtl-wmbus.git" plugin: make - artifacts: - - build/rtl_wmbus - organize: - build/rtl_wmbus: usr/bin/rtl_wmbus - prime: - - usr/bin/rtl_wmbus + make-parameters: + - DESTDIR=/usr rtl-433: source: "https://github.com/merbanan/rtl_433.git" plugin: cmake - organize: - bin/rtl_433: usr/bin/rtl_433 - prime: - - usr/bin/rtl_433 + cmake-parameters: + - -DCMAKE_INSTALL_PREFIX=/usr apps: wmbusmeters: @@ -97,8 +91,6 @@ apps: layout: /usr/bin/wmbusmeters: bind-file: $SNAP/usr/bin/wmbusmeters - /sbin/killall5: - bind-file: $SNAP/sbin/killall5 #rtl /usr/bin/rtl_433: bind-file: $SNAP/usr/bin/rtl_433 @@ -106,51 +98,33 @@ layout: bind-file: $SNAP/usr/bin/rtl_sdr /usr/bin/rtl_wmbus: bind-file: $SNAP/usr/bin/rtl_wmbus - /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/librtlsdr.so.0: - symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/librtlsdr.so.0 - /lib/$SNAPCRAFT_ARCH_TRIPLET/libusb-1.0.so.0: - symlink: $SNAP/lib/$SNAPCRAFT_ARCH_TRIPLET/libusb-1.0.so.0 + /usr/lib/$CRAFT_ARCH_TRIPLET/librtlsdr.so.0: + symlink: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/librtlsdr.so.0 + /usr/lib/$CRAFT_ARCH_TRIPLET/libusb-1.0.so.0: + symlink: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/libusb-1.0.so.0 #mosquitto /usr/bin/mosquitto_pub: bind-file: $SNAP/usr/bin/mosquitto_pub /usr/bin/mosquitto_sub: bind-file: $SNAP/usr/bin/mosquitto_sub - /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libmosquitto.so.1: - symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libmosquitto.so.1 - /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libcares.so.2: - symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libcares.so.2 + /usr/lib/$CRAFT_ARCH_TRIPLET/libmosquitto.so.1: + symlink: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/libmosquitto.so.1 + /usr/lib/$CRAFT_ARCH_TRIPLET/libcjson.so.1: + symlink: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/libcjson.so.1 #curl /usr/bin/curl: bind-file: $SNAP/usr/bin/curl - /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libcurl.so.4: - symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libcurl.so.4 - /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libnghttp2.so.14: - symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libnghttp2.so.14 - /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/librtmp.so.1: - symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/librtmp.so.1 - /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libpsl.so.5: - symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libpsl.so.5 - /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libldap_r-2.4.so.2: - symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libldap_r-2.4.so.2 - /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/liblber-2.4.so.2: - symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/liblber-2.4.so.2 - /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libsasl2.so.2: - symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libsasl2.so.2 - /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libgssapi.so.3: - symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libgssapi.so.3 - /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libheimntlm.so.0: - symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libheimntlm.so.0 - /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libasn1.so.8: - symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libasn1.so.8 - /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libhcrypto.so.4: - symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libhcrypto.so.4 - /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libroken.so.18: - symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libroken.so.18 - /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libwind.so.0: - symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libwind.so.0 - /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libheimbase.so.1: - symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libheimbase.so.1 - /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libhx509.so.5: - symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libhx509.so.5 - /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libkrb5.so.26: - symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libkrb5.so.26 \ No newline at end of file + /usr/lib/$CRAFT_ARCH_TRIPLET/libcurl.so.4: + symlink: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/libcurl.so.4 + /usr/lib/$CRAFT_ARCH_TRIPLET/libnghttp2.so.14: + symlink: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/libnghttp2.so.14 + /usr/lib/$CRAFT_ARCH_TRIPLET/librtmp.so.1: + symlink: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/librtmp.so.1 + /usr/lib/$CRAFT_ARCH_TRIPLET/libpsl.so.5: + symlink: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/libpsl.so.5 + /usr/lib/$CRAFT_ARCH_TRIPLET/libldap-2.5.so.0: + symlink: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/libldap-2.5.so.0 + /usr/lib/$CRAFT_ARCH_TRIPLET/liblber-2.5.so.0: + symlink: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/liblber-2.5.so.0 + /usr/lib/$CRAFT_ARCH_TRIPLET/libsasl2.so.2: + symlink: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/libsasl2.so.2 \ No newline at end of file