-
Notifications
You must be signed in to change notification settings - Fork 4
78 lines (69 loc) · 2.93 KB
/
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
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
73
74
75
76
77
78
name: snap
on: # The event that triggers the workflow
push:
branches:
- master # When a commit is created on master
pull_request:
branches:
- master # When a pull request is opened against master
workflow_dispatch: # When the workflow is manually triggered
jobs:
build:
# Only run this job if the branch name contains "release" or a commit is created on master branch and the branch name contains "release" or manually triggered
if: contains(github.ref, 'release') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
strategy:
matrix:
architecture: [amd64, i386, armhf, arm64, s390x, ppc64le]
outputs:
snap-file: ${{ steps.build-snap.outputs.snap }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Snapcraft
run: sudo snap install snapcraft --classic
- name: Install LXD
run: |
sudo snap install lxd
sudo lxd init --auto
- name: Wait for LXD to be ready
run: |
while ! sudo lxd waitready; do
sleep 1
done
- name: Set architecture
run: echo "ARCH=${{ matrix.architecture }}" >> $GITHUB_ENV
- name: Build the snap # Build the snap for the specified architecture in the matrix strategy above and save the snap file path to an output
id: build-snap
run: |
snapcraft --use-lxd
echo "snap=${{ matrix.architecture }}.snap" >> $GITHUB_ENV
# Make sure the snap is installable
- run: |
sudo snap install --dangerous ${{ env.snap }}
# Upload the snap file as an artifact
- uses: actions/upload-artifact@v4
with:
name: ngrok-${{ matrix.architecture }}
path: ${{ env.snap }}
publish:
# Only run this job if the branch name contains "release" or a commit is created on master branch and the branch name contains "release" or manually triggered
if: (github.event_name == 'push' && github.ref == 'refs/heads/master' && contains(github.ref, 'release')) || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
needs: build # Wait for build job to be done
steps:
- name: Download package
uses: actions/download-artifact@v4
with:
name: ngrok-${{ matrix.architecture }}
path: .
- name: Publish to Snap Store
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }}
with:
snap: ${{needs.build.outputs.snap-file}}
# changes on the master branch we would like to publish to the edge risk level, so edge always has the latest changes which may not be considered as stable.
# On the other hand, if we are on a tagged version, we would like to publish to the candidate risk level.
# After thorough testing, the maintainer can manually promote the snap to beta/stable.
release: stable