7
7
8
8
jobs :
9
9
build-and-publish :
10
- runs-on : ubuntu-latest
10
+ runs-on : ubuntu-20.04
11
11
steps :
12
12
- name : Checkout
13
13
uses : actions/checkout@v4
14
14
with :
15
15
fetch-depth : 0
16
16
17
- - name : Install Snapcraft
18
- uses : samuelmeuli/action-snapcraft@v2
17
+ - name : Set up Go
18
+ uses : actions/setup-go@v4
19
19
with :
20
- use_lxd : true
21
-
20
+ go-version : ' 1.23'
21
+ cache : true
22
+
22
23
- name : Extract version from tag
23
24
id : get_version
24
25
run : |
25
26
VERSION=${GITHUB_REF#refs/tags/v}
26
- echo "VERSION =$VERSION" >> $GITHUB_ENV
27
+ echo "version =$VERSION" >> $GITHUB_OUTPUT
27
28
echo "The version is $VERSION"
28
29
30
+ - name : Setup Snapcraft
31
+ run : |
32
+ sudo apt-get update
33
+ sudo apt-get install -y snapd
34
+ sudo snap install snapcraft --classic
35
+
29
36
- name : Update version in snapcraft.yaml
30
37
run : |
31
- sed -i "s/^version: git/version: $VERSION /" snap/snapcraft.yaml
38
+ sed -i "s/^version: git/version: ${{ steps.get_version.outputs.version }} /" snap/snapcraft.yaml
32
39
cat snap/snapcraft.yaml
33
40
41
+ - name : Install LXD
42
+ run : |
43
+ sudo snap install lxd
44
+ sudo lxd init --auto
45
+
34
46
- name : Build snap
35
47
run : |
36
- snapcraft
48
+ # Use LXD as the build environment
49
+ sudo snap install snapcraft --classic
50
+ SNAPCRAFT_BUILD_ENVIRONMENT=lxd snapcraft
37
51
38
- - name : Publish snap
39
- uses : snapcore/action-publish@v1
40
- env :
41
- SNAPCRAFT_STORE_CREDENTIALS : ${{ secrets.SNAPCRAFT_TOKEN }}
52
+ - name : Upload snap as artifact
53
+ uses : actions/upload-artifact@v3
42
54
with :
43
- snap : httpprobe_*.snap
44
- release : stable
55
+ name : httpprobe-snap
56
+ path : ./*.snap
57
+
58
+ - name : Publish snap
59
+ if : startsWith(github.ref, 'refs/tags/v')
60
+ run : |
61
+ echo "${{ secrets.SNAPCRAFT_TOKEN }}" > snapcraft.login
62
+ snapcraft login --with snapcraft.login
63
+ snapcraft upload --release=stable *.snap
64
+ rm -f snapcraft.login
0 commit comments