diff --git a/.github/workflows/promote_snap.yml b/.github/workflows/promote_snap.yml new file mode 100644 index 0000000..acf465f --- /dev/null +++ b/.github/workflows/promote_snap.yml @@ -0,0 +1,26 @@ +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 snap/promote_snap.sh \ No newline at end of file diff --git a/snap/promote_snap.sh b/snap/promote_snap.sh new file mode 100644 index 0000000..9c74e54 --- /dev/null +++ b/snap/promote_snap.sh @@ -0,0 +1,38 @@ +#!/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 + +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 10 ]]; 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/snap/snapcraft.yaml b/snap/snapcraft.yaml index 5411965..0a5ac80 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -35,7 +35,7 @@ parts: source-type: git override-pull: | snapcraftctl pull - if [ -n $(git describe --tags | grep -) ]; then + 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