forked from ubuntu-robotics/snap_workflows
-
Notifications
You must be signed in to change notification settings - Fork 2
73 lines (64 loc) · 2.06 KB
/
publish.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
63
64
65
66
67
68
69
70
71
72
name: publish
on:
workflow_call:
inputs:
snap-track:
default: latest
description: Snap Store channel track use for publication.
required: false
type: string
secrets:
snapstore-login:
description: Snap Store credential (see 'snapcraft export-login').
required: true
jobs:
prepare-publish:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.get-snap-file.outputs.matrix }}
steps:
- name: Check Snapstore login
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.snapstore-login }}
run: |
# Check if the key is empty
if [ -z "${SNAPCRAFT_STORE_CREDENTIALS}" ]; then
echo "Snapstore login is empty!"
exit 1
fi
- name: Download snap artifact
uses: actions/download-artifact@v4
with:
path: .
pattern: 'workflow-build-snap-*'
- name: Retrieve snap file
id: get-snap-file
run: |
files=$(find . -name '*.snap' -printf "\"%h/%f\",")
echo "Files: ${files}"
jsonfiles=$(echo "[${files%?}]")
echo "JSON Files: ${jsonfiles}"
echo "matrix=${jsonfiles}" >> "$GITHUB_OUTPUT"
publish:
needs: [prepare-publish]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
snap: ${{ fromJson(needs.prepare-publish.outputs.matrix) }}
steps:
- name: Download snap artifact
uses: actions/download-artifact@v4
with:
path: .
# @todo(artivis) The matrix is based on the snap filename to be published.
# Associate it the artifact name so that this job only downloads
# the one artifact it needs.
pattern: 'workflow-build-snap-*'
- name: Publish snap
uses: canonical/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.snapstore-login }}
with:
snap: ${{ matrix.snap }}
release: ${{ inputs.snap-track }}/${{ startsWith(github.ref, 'refs/tags/') && 'candidate' || 'edge'}}