forked from canonical/snapd
-
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.
- Loading branch information
Showing
7 changed files
with
163 additions
and
7 deletions.
There are no files selected for viewing
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# SPDX-FileCopyrightText: Canonical Ltd. | ||
|
||
name: Download snap package | ||
author: Zygmunt Krynicki | ||
description: | | ||
Download snap action adapated from https://github.com/canonical/snapd-wsl-tests/blob/main/.github/actions/download-snap/action.yaml | ||
inputs: | ||
snap-name: | ||
description: Name of the snap in the store | ||
required: true | ||
snap-revision: | ||
description: Revision to download (mutually exclusive with channel) | ||
snap-channel: | ||
description: Name of the channel to use (mutually exclusive with revision) | ||
default: latest/stable | ||
snaps-dir: | ||
description: Directory where snaps should be stored | ||
default: snaps | ||
outputs: | ||
snap-name: | ||
description: Name of the downloaded snap | ||
value: ${{ inputs.snap-name }} | ||
snap-revision: | ||
description: Revision of the downloaded snap | ||
value: ${{ inputs.snap-revision && inputs.snap-revision || steps.query-store.outputs.snap-revision }} | ||
offline-snaps-dir: | ||
description: Directory where downloaded snaps and assertions are stored | ||
value: ${{ inputs.snaps-dir }} | ||
branding: | ||
icon: download | ||
color: orange | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Use specific revision | ||
if: ${{ inputs.snap-revision != '' }} | ||
shell: bash | ||
env: | ||
SNAP_REVISION: ${{ inputs.snap-revision }} | ||
run: | | ||
echo "SNAP_REVISION=$SNAP_REVISION" >> $GITHUB_ENV | ||
- name: Query the Snap Store | ||
id: query-store | ||
if: ${{ inputs.snap-revision == '' }} | ||
env: | ||
SNAP_NAME: ${{ inputs.snap-name }} | ||
SNAP_CHANNEL: ${{ inputs.snap-channel }} | ||
shell: bash | ||
run: | | ||
SNAP_REVISION=$(curl -sS --unix-socket /run/snapd.socket http://localhost/v2/find?name=${SNAP_NAME} | jq -r ".result[].channels.\"${SNAP_CHANNEL}\".revision") | ||
echo "SNAP_REVISION=$SNAP_REVISION" >> $GITHUB_ENV | ||
- name: Cache ${{ inputs.snap-name }} | ||
id: cache-snap | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
${{ inputs.snaps-dir }}/${{ inputs.snap-name }}_${{ inputs.snap-revision && inputs.snap-revision || steps.query-store.outputs.snap-revision }}.snap | ||
${{ inputs.snaps-dir }}/${{ inputs.snap-name }}_${{ inputs.snap-revision && inputs.snap-revision || steps.query-store.outputs.snap-revision }}.assert | ||
key: snaps/${{ inputs.snap-name }}-${{ inputs.snap-revision && inputs.snap-revision || steps.query-store.outputs.snap-revision }} | ||
- name: Download ${{ inputs.snap-name }} | ||
if: ${{ steps.cache-snap.outputs.cache-hit != 'true' }} | ||
env: | ||
SNAP_NAME: ${{ inputs.snap-name }} | ||
SNAP_REVISION: ${{ inputs.snap-revision && inputs.snap-revision || steps.query-store.outputs.snap-revision }} | ||
SNAPS_DIR: ${{ inputs.snaps-dir }} | ||
shell: bash | ||
run: | | ||
mkdir -p $SNAPS_DIR | ||
snap download --revision=$SNAP_REVISION --target-directory=$SNAPS_DIR $SNAP_NAME |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# SPDX-FileCopyrightText: Canonical Ltd. | ||
|
||
name: Install offline snap package | ||
author: Zygmunt Krynicki | ||
description: | | ||
Install snap action using an initialized WSL distribution and downloaded snap | ||
file. | ||
inputs: | ||
snap-name: | ||
description: Name of the snap to install | ||
required: true | ||
snap-revision: | ||
description: Revision of the snap to install | ||
required: true | ||
offline-snaps-dir: | ||
description: Directory where downloaded snaps and assertions are stored | ||
default: snaps | ||
snap-classic-confinement: | ||
description: Use classic confinement | ||
type: boolean | ||
default: false | ||
branding: | ||
icon: download | ||
color: orange | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Install ${{ inputs.snap-name}} revision ${{ inputs.snap-revision }} snap | ||
env: | ||
SNAP_NAME: ${{ inputs.snap-name }} | ||
SNAP_REVISION: ${{ inputs.snap-revision }} | ||
SNAP_CLASSIC_CONFINEMENT: ${{ inputs.snap-classic-confinement }} | ||
OFFLINE_SNAPS_DIR: ${{ inputs.offline-snaps-dir }} | ||
shell: bash | ||
run: | | ||
sudo snap ack "${OFFLINE_SNAPS_DIR}/${SNAP_NAME}_${SNAP_REVISION}.assert" | ||
classic= | ||
if [ ${{ inputs.snap-classic-confinement }} == 'true' ]; then | ||
classic="--classic" | ||
fi | ||
sudo snap install $classic "${OFFLINE_SNAPS_DIR}/${SNAP_NAME}_${SNAP_REVISION}.snap" |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Install snap package | ||
author: Zygmunt Krynicki | ||
description: | | ||
Install snap action | ||
inputs: | ||
snap-name: | ||
description: Name of the snap to install | ||
required: true | ||
snap-channel: | ||
description: Name of the channel to use (mutually exclusive with revision) | ||
default: latest/stable | ||
snaps-dir: | ||
description: Directory where snaps should be stored | ||
default: snaps | ||
snap-classic-confinement: | ||
description: Use classic confinement | ||
type: boolean | ||
default: false | ||
outputs: | ||
snap-revision: | ||
description: Revision of the installed snap | ||
value: ${{ steps.download.outputs.snap-revision }} | ||
branding: | ||
icon: download | ||
color: orange | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Download snap ${{ inputs.snap-name }} from the Snap Store | ||
id: download | ||
uses: ./.github/actions/download-snap | ||
with: | ||
snap-name: ${{ inputs.snap-name }} | ||
snap-channel: ${{ inputs.snap-channel }} | ||
snaps-dir: ${{ inputs.snaps-dir }} | ||
- name: Install downloaded snap ${{ inputs.snap-name }} | ||
uses: ./.github/actions/install-offline-snap | ||
with: | ||
snap-name: ${{ inputs.snap-name }} | ||
snap-revision: ${{ steps.download.outputs.snap-revision }} | ||
snap-classic-confinement: ${{ inputs.snap-classic-confinement }} | ||
offline-snaps-dir: ${{ steps.download.outputs.offline-snaps-dir }} |
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
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
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