Adding github action to promote snap to stable release automatically
pull/157/head
BIBOLV 2020-09-01 00:00:48 +03:00
rodzic ea783a3daf
commit 0d72b395ce
3 zmienionych plików z 65 dodań i 1 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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

Wyświetl plik

@ -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