Skip to content

snap

snap #24

Workflow file for this run

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
outputs:
snap-file: ${{ steps.build-snap.outputs.snap }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Debug Info
run: |
echo "github.ref: ${{ github.ref }}"
echo "github.head_ref: ${{ github.head_ref }}"
echo "github.event_name: ${{ github.event_name }}"
- name: Build the snap # generates .snap file and stores its name in the variable steps.build-snap.outputs.snap
uses: snapcore/action-build@v1
id: build-snap
# Make sure the snap is installable
- run: |
sudo snap install --dangerous ${{ steps.build-snap.outputs.snap }}
# Do some testing
- uses: actions/upload-artifact@v4
with:
name: ngrok
path: ${{ steps.build-snap.outputs.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
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