Skip to content

feat(cli): add CLI commands for notices (notices, notice, notify) #506

feat(cli): add CLI commands for notices (notices, notice, notify)

feat(cli): add CLI commands for notices (notices, notice, notify) #506

Workflow file for this run

name: Pebble snap
on:
pull_request:
branches: [master]
push:
branches: [master]
release:
types: [published]
# We don't want this workflow to have multiple runs in parallel because
# what could happen is that a slow-running and older execution will upload
# an older snap to `edge`, after the newer and latest snap has already been released.
concurrency: ${{ github.workflow }}
env:
SNAP_NAME: pebble
DEFAULT_TRACK: latest
DEFAULT_RISK: edge
jobs:
snaps:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64, ppc64el, armhf, s390x]
steps:
- name: Checkout Pebble repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set LP credentials for remote build
id: set-local-paths
run: |
lp_creds_path="$HOME/.local/share/snapcraft/provider/launchpad"
mkdir -p $lp_creds_path
echo '${{ secrets.LP_CREDENTIALS }}' > ${lp_creds_path}/credentials
git config --global user.email "${{ secrets.PEBBLE_DEV_MAILING_LIST}}"
git config --global user.name "pebble-dev"
echo "home=$HOME" >> $GITHUB_OUTPUT
- name: Build ${{ env.SNAP_NAME }} Snap for ${{ matrix.arch }}
id: build-snap
uses: snapcore/[email protected]
with:
snapcraft-args: remote-build --build-for=${{ matrix.arch }} --launchpad-accept-public-upload
- uses: actions/upload-artifact@v3
if: failure()
with:
name: snapcraft-logs
path: |
${{ steps.set-local-paths.outputs.home }}/.cache/snapcraft/log/
${{ steps.set-local-paths.outputs.home }}/.local/state/snapcraft/log/
${{ env.SNAP_NAME }}_*.txt
- name: Install and test ${{ steps.build-snap.outputs.snap }}
# NOTE: this line can be adjusted if we start supporting multi-arch runners
if: ${{ matrix.arch == 'amd64' }}
run: |
set -ex
sudo snap install --dangerous --classic ${{ steps.build-snap.outputs.snap }}
# Make sure it is installed
pebble version --client
# Run smoke test
pebble enter --create-dirs exec echo Hello | grep Hello
- name: Attach ${{ steps.build-snap.outputs.snap }} to GH workflow execution
uses: actions/upload-artifact@v2
with:
name: ${{ steps.build-snap.outputs.snap }}
path: ${{ steps.build-snap.outputs.snap }}
- name: Release ${{ steps.build-snap.outputs.snap }} to ${{ env.DEFAULT_TRACK }}/${{ env.DEFAULT_RISK }}
if: ${{ github.event_name != 'pull_request' }}
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
with:
snap: ${{ steps.build-snap.outputs.snap }}
release: ${{ env.DEFAULT_TRACK }}/${{ env.DEFAULT_RISK }}
promote:
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
needs: [snaps]
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64, ppc64el, armhf, s390x]
env:
TO_TRACK: latest
TO_RISK: candidate
steps:
- name: Install Snapcraft
run: sudo snap install snapcraft --classic
- name: Get current ${{ matrix.arch }} ${{ env.SNAP_NAME }} snap in ${{ env.TO_TRACK }}/${{ env.TO_RISK }}
id: get-snap
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
run: |
revision="$(snapcraft status ${{ env.SNAP_NAME }} \
--track ${{ env.DEFAULT_TRACK }} --arch ${{ matrix.arch }} \
| grep "${{ env.DEFAULT_RISK }}" | awk -F' ' '{print $3}')"
echo "revision=$revision" >> $GITHUB_OUTPUT
# It would be easier to use `snapcraft promote`, but there's an error when trying
# to avoid the prompt with the "--yes" option:
# > 'latest/edge' is not a valid set value for --from-channel when using --yes.
- name: Promote ${{ env.SNAP_NAME }} snap rev${{ steps.get-snap.outputs.revision }} to ${{ env.TO_TRACK }}/${{ env.TO_RISK }}
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
run: |
snapcraft release ${{ env.SNAP_NAME }} \
${{ steps.get-snap.outputs.revision }} \
${{ env.TO_TRACK }}/${{ env.TO_RISK }}