Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit f8e1406

Browse files
author
Julio Montes
committed
snap: add GH actions jobs to release the snap package
Use Github actions to build and release the snap package automatically when a new tag is pushed. fixes #3098 Signed-off-by: Julio Montes <julio.montes@intel.com>
1 parent 3f92a9c commit f8e1406

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Release Kata 1.x in snapcraft store
2+
on:
3+
push:
4+
tags:
5+
- '1.*'
6+
jobs:
7+
release-snap:
8+
runs-on: ubuntu-20.04
9+
steps:
10+
- name: Check out Git repository
11+
uses: actions/checkout@v2
12+
13+
- name: Install Snapcraft
14+
uses: samuelmeuli/action-snapcraft@v1
15+
with:
16+
snapcraft_token: ${{ secrets.snapcraft_token }}
17+
18+
- name: Build snap
19+
run: |
20+
sudo apt-get install -y git git-extras
21+
kata_url="https://github.com/kata-containers/runtime"
22+
latest_version=$(git ls-remote --tags ${kata_url} | egrep -o "refs.*" | egrep -v "\-alpha|\-rc|{}" | egrep -o "[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+" | sort -V -r | head -1)
23+
current_version="$(echo ${GITHUB_REF} | cut -d/ -f3)"
24+
# Check if the current tag is the latest tag
25+
if echo -e "$latest_version\n$current_version" | sort -C -V; then
26+
# Current version is the latest version, build it
27+
snapcraft -d snap --destructive-mode
28+
fi
29+
30+
- name: Upload snap
31+
run: |
32+
snap_version="$(echo ${GITHUB_REF} | cut -d/ -f3)"
33+
snap_file="kata-containers_${snap_version}_amd64.snap"
34+
# Upload the snap if it exists
35+
if [ -f ${snap_file} ]; then
36+
snapcraft upload --release=stable ${snap_file}
37+
fi

0 commit comments

Comments
 (0)