Code Monkey home page Code Monkey logo

action-snapcraft's Introduction

Snapcraft Action

GitHub Action for setting up Snapcraft

Overview

This action…

  • Installs Snapcraft on Ubuntu 18.04+/macOS
  • Optionally logs you in to the Snap Store
  • Allows you to run Snapcraft commands in your GitHub Actions workflows

Note that the more recently created snapcore/action-build and snapcore/action-publish effectively copy the use_lxd strategy (below). Building using this actions still takes ~3:30 min less time than snapcore/action-build.

Usage

Basic

To use this action, add the following step to your workflow:

- name: Install Snapcraft
  uses: samuelmeuli/action-snapcraft@v2

A full example:

name: My workflow

on: push

jobs:
  my-job:
    runs-on: ubuntu-latest
    env:
      SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
    steps:
      - name: Check out Git repository
        uses: actions/checkout@v3

      - name: Install Snapcraft
        uses: samuelmeuli/action-snapcraft@v2

      # You can now run Snapcraft shell commands
      - name: Use Snapcraft
        run: snapcraft --help

Log in

This action can also log you in to the Snap Store. For this to work, you need an Ubuntu One account.

You will also need a Snap Store login token. To obtain one, run the following command on your machine:

snapcraft export-login --snaps SNAP_NAME --channels edge -

NOTE: You will need to manually push a package to the Snap Store to get a valid SNAP_NAME first.

Copy that token and add it as a secret to GitHub Actions. You can do this in your GitHub repository under Settings β†’ Secrets. You can name it SNAPCRAFT_TOKEN for convenience.

Set SNAPCRAFT_STORE_CREDENTIALS environment variable either in:

  • root yml file: to be available for all jobs
  • inside a job: to be available inside a specific job (recommended), or
  • inside a step: to be available only in a specific step
env:
  SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}

Finally, add the following option to your workflow step:

- name: Install Snapcraft
  uses: samuelmeuli/action-snapcraft@v2
  with:
    skip_install: true # optional, if already installed in an earlier step

Build using LXD

Using runs-on: ubuntu-20.04 or later, LXD is availabe by default. If using runs-on: ubuntu-18.04, LXD can be installed as shown below. This is an alternative to using multipass (GitHub VMs give the error launch failed: CPU does not support KVM extensions. when trying to use multipass).

- name: Install Snapcraft with LXD
  uses: samuelmeuli/action-snapcraft@v2
  with:
    use_lxd: ${{ matrix.os == 'ubuntu-18.04' }}
- name: Build snap
  run: sg lxd -c 'snapcraft --use-lxd'

Development

Suggestions and contributions are always welcome! Please discuss larger changes via issue before submitting a pull request.

Currently maintained by @casperdcl.

Related

action-snapcraft's People

Contributors

casperdcl avatar samuelmeuli avatar saviq avatar mightymatth avatar pbek avatar dependabot[bot] avatar sp1thas avatar aleandros avatar victorioberra avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.