-
Notifications
You must be signed in to change notification settings - Fork 1
45 lines (42 loc) · 1.6 KB
/
promote-snap.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: Promote Snap
on:
workflow_dispatch:
inputs:
promotion:
type: choice
description: Channel to promote from
options:
- edge -> beta
- beta -> candidate
- candidate -> stable
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
jobs:
promote:
name: Promote Snap
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: sudo snap install --classic --channel edge snapcraft
- name: Set target channel
env:
PROMOTE_FROM: ${{ github.event.inputs.promotion }}
run: |
if [ "${PROMOTE_FROM}" == "edge -> beta" ]; then
echo "promote-from=edge" >> ${GITHUB_ENV}
echo "promote-to=beta" >> ${GITHUB_ENV}
elif [ "${PROMOTE_FROM}" == "beta -> candidate" ]; then
echo "promote-from=beta" >> ${GITHUB_ENV}
echo "promote-to=candidate" >> ${GITHUB_ENV}
elif [ "${PROMOTE_FROM}" == "candidate -> stable" ]; then
echo "promote-from=candidate" >> ${GITHUB_ENV}
echo "promote-to=stable" >> ${GITHUB_ENV}
fi
- name: Fetch Revision
run: |
SNAP_RELEASES=$(curl -s -H "Snap-Device-Series: 16" "http://api.snapcraft.io/v2/snaps/info/cos-alerter?fields=revision")
REVISION=$(echo $SNAP_RELEASES | jq '."channel-map"[] | select(.channel.risk=="${{ env.promote-from }}").revision')
echo "revision=$REVISION" >> ${GITHUB_ENV}
- name: Promote Snap
run: |
snapcraft release cos-alerter ${{ env.revision }} ${{ env.promote-to }}