Merge pull request #61 from ngrok/release/testing #247
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: snap | |
on: | |
push: | |
branches: | |
- main # When a commit is created on main | |
pull_request: | |
types: [opened, reopened] # when a pull request is opened or reopened | |
branches: | |
- main # the branch that the pull request is targeting | |
workflow_dispatch: # When the workflow is manually triggered | |
jobs: | |
build: | |
# It will run if: | |
# 1. The event triggering the workflow is a 'pull_request' event, | |
# 2. The branch name contains the word 'release', | |
# OR | |
# 3. The event triggering the workflow is a 'workflow_dispatch' event. (manual run) | |
if: (github.event_name == 'pull_request' && contains(github.head_ref, 'release')) || github.event_name == 'workflow_dispatch' | |
runs-on: ubuntu-22.04 | |
outputs: | |
snap-file: ${{ steps.build-snap.outputs.snap }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install snapcraft | |
run: | | |
sudo snap install snapcraft --classic | |
- uses: snapcore/action-build@v1 | |
# Upload the snap file as an artifact | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ngrok-snaps | |
path: ./*.snap | |
publish: | |
# It will run if: | |
# 1. The event triggering the workflow is a 'push' event, | |
# 2. The pushed branch name contains the word 'release', | |
# OR | |
# 3. The event triggering the workflow is a 'workflow_dispatch' event. (manual run) | |
if: (github.event_name == 'push' && contains(github.ref, 'release')) || github.event_name == 'workflow_dispatch' | |
runs-on: ubuntu-22.04 | |
needs: build # Wait for the build job to complete | |
steps: | |
- name: Download All Snap Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: ngrok-snaps | |
merge-multiple: true | |
- run: ls -R | |
- name: Publish to Snap Store | |
env: | |
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} | |
run: | | |
sudo snap install snapcraft --classic | |
for snap in ngrok-snaps/*.snap; do | |
echo "Publishing $snap" | |
snapcraft push "$snap" --release=stable | |
done |