-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (61 loc) · 2.02 KB
/
deploy.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: Deploy
on:
push:
tags:
- v*
branches:
- main
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
env:
TZ: Europe/Berlin
DOCKER_BUILDKIT: 1
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set version
run: |
# from refs/tags/v1.2.3 get 1.2.3
VERSION=$(git describe --tags)
PLACEHOLDER='__version__ = "unknown"'
VERSION_FILE='minivirt/version.py'
# ensure the placeholder is there. If grep doesn't find the placeholder
# it exits with exit code 1 and github actions aborts the build.
grep "$PLACEHOLDER" "$VERSION_FILE"
sed -i "s/$PLACEHOLDER/__version__ = \"${VERSION}\"/g" "$VERSION_FILE"
grep "version: 'git'" snap/snapcraft.yaml
sed -i "s/version: 'git'/version: ${VERSION}/g" snap/snapcraft.yaml
- name: Deploy image
run: |
IMAGE_VERSION=$(git describe --tags)
docker build -t restvirt:${IMAGE_VERSION} .
docker tag restvirt:${IMAGE_VERSION} ghcr.io/verbit/restvirt:${IMAGE_VERSION}
docker push ghcr.io/verbit/restvirt:${IMAGE_VERSION}
- name: Build Snap
uses: snapcore/action-build@v1
id: snapcraft
- name: Determine Snap Channel
id: snap_channel
run: |
if (git describe --tags --exact-match); then
echo '::set-output name=SNAP_CHANNEL::stable'
else
echo '::set-output name=SNAP_CHANNEL::edge'
fi
- name: Deploy Snap
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_CREDS }}
with:
snap: ${{ steps.snapcraft.outputs.snap }}
release: ${{ steps.snap_channel.outputs.SNAP_CHANNEL }}