Sha256: bfcd7c8e97c7b4315bf42742e21de8de045eb4d8b1d57a6f152d04b5541c1e3c

Contents?: true

Size: 1.46 KB

Versions: 9

Compression:

Stored size: 1.46 KB

Contents

module Dpl
  module Providers
    class Snap < Provider
      status :dev

      description sq(<<-str)
        tbd
      str

      env :snap

      opt '--token TOKEN', 'Snap API token', required: true, secret: true
      opt '--snap STR', 'Path to the snap to be pushed (can be a glob)', default: '**/*.snap'
      opt '--channel CHAN', 'Channel into which the snap will be released', default: 'edge'

      apt 'snapd', 'snap'

      cmds install:        'sudo snap install snapcraft --classic',
           login:          'snapcraft login --with %{token}',
           deploy:         'snapcraft push %{snap_path} --release=%{channel}'

      msgs login:          'Attemping to login ...',
           no_snaps:       'No snap found matching %{snap}',
           multiple_snaps: 'Multiple snaps found matching %{snap}: %{snap_paths}',
           deploy:         'Pushing snap %{snap_path}'

      def install
        return if which 'snapcraft'
        shell :install
        ENV['PATH'] += ':/snap/bin'
      end

      def login
        shell :login, assert: 'Failed to authenticate: %{err}', success: '%{out}', capture: true
      end

      def validate
        error :no_snaps if snaps.empty?
        error :multiple_snaps if snaps.size > 1
      end

      def deploy
        shell :deploy
      end

      def snap_path
        snaps.first
      end

      def snap_paths
        snaps.join(', ')
      end

      def snaps
        @snaps ||= Dir[snap].sort
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dpl-2.0.0.alpha.11 lib/dpl/providers/snap.rb
dpl-2.0.0.alpha.10 lib/dpl/providers/snap.rb
dpl-2.0.0.alpha.9 lib/dpl/providers/snap.rb
dpl-2.0.0.alpha.8 lib/dpl/providers/snap.rb
dpl-2.0.0.alpha.7 lib/dpl/providers/snap.rb
dpl-2.0.0.alpha.6 lib/dpl/providers/snap.rb
dpl-2.0.0.alpha.5 lib/dpl/providers/snap.rb
dpl-2.0.0.alpha.2 lib/dpl/providers/snap.rb
dpl-2.0.0.alpha.1 lib/dpl/providers/snap.rb