forked from canonical/pebble
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(snap): (fix canonical#300) remotely build snaps from GH
- Loading branch information
1 parent
bbf5139
commit 92c0b15
Showing
2 changed files
with
71 additions
and
21 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,62 +3,112 @@ name: Pebble snap | |
on: | ||
pull_request: | ||
branches: [master] | ||
push: | ||
branches: [master] | ||
release: | ||
types: [published] | ||
|
||
env: | ||
SNAP_NAME: pebble | ||
SNAP_NAME: pebble-cjdc | ||
DEFAULT_TRACK: latest | ||
DEFAULT_RISK: edge | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
pebble-snap: ${{ steps.build-pebble-snap.outputs.snap }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
arch: [amd64, arm64, ppc64el, armhf, s390x] | ||
steps: | ||
- name: Checkout Pebble repo | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Build Pebble Snap | ||
id: build-pebble-snap | ||
uses: snapcore/action-build@v1 | ||
- 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: Attach pebble snap to GH workflow execution | ||
- 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: Attach ${{ matrix.arch }} snap to GH workflow execution | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ steps.build-pebble-snap.outputs.snap }} | ||
path: ${{ steps.build-pebble-snap.outputs.snap }} | ||
name: ${{ steps.build-snap.outputs.snap }} | ||
path: ${{ steps.build-snap.outputs.snap }} | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
needs: [build] | ||
outputs: | ||
pebble-version: ${{ steps.install-pebble.outputs.version }} | ||
|
||
strategy: | ||
fail-fast: true | ||
# NOTE: adjust this matrix if we ever start testing with multi-arch runners. | ||
matrix: | ||
arch: [amd64] | ||
steps: | ||
- uses: actions/download-artifact@v3 | ||
- name: Download ${{ env.SNAP_NAME }} snap for ${{ matrix.arch }} | ||
id: download-artifact | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
name: ${{ needs.build.outputs.pebble-snap }} | ||
name: "${{ env.SNAP_NAME }}*${{ matrix.arch }}.snap" | ||
name_is_regexp: true | ||
|
||
- name: Install the Pebble snap | ||
id: install-pebble | ||
run: | | ||
set -ex | ||
ls | ||
# Install the Pebble snap from the artifact built in the previous job | ||
sudo snap install --dangerous --classic ${{ needs.build.outputs.pebble-snap }} | ||
sudo snap install --dangerous --classic \ | ||
`ls ${{ env.SNAP_NAME }}*${{ matrix.arch }}.snap` | ||
# Make sure Pebble is installed | ||
echo "version=$(pebble version --client)" >> "$GITHUB_OUTPUT" | ||
echo "version=$(pebble-cjdc.pebble version --client)" >> "$GITHUB_OUTPUT" | ||
- name: Run smoke test | ||
run: pebble enter --create-dirs exec echo Hello | grep Hello | ||
run: pebble-cjdc.pebble enter --create-dirs exec echo Hello | grep Hello | ||
|
||
# upload: | ||
# if: ${{ github.event_name != 'pull_request' }} | ||
# runs-on: ubuntu-latest | ||
# needs: [test] | ||
# steps: | ||
# - uses: actions/download-artifact@v3 | ||
# with: | ||
# name: snaps | ||
|
||
# - name: Upload snaps to ${{ env.DEFAULT_TRACK }}/${{ env.DEFAULT_RISK }} | ||
# run: | | ||
# set -ex | ||
# for snap in `ls ${{ env.SNAP_NAME }}*.snap` | ||
# do | ||
# snapcraft | ||
|
||
promote: | ||
if: ${{ github.event_name == 'release' }} | ||
runs-on: ubuntu-latest | ||
needs: [test] | ||
needs: [upload] | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
|
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