Merge #11428 'Update SNAP packaging'

This commit is contained in:
Justin M. Keyes 2019-11-28 19:33:51 -08:00 committed by GitHub
commit 835f959193
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 128 additions and 11 deletions

View File

@ -4,6 +4,19 @@ language: c
env:
global:
# Encrypted environment variables, see
# http://docs.travis-ci.com/user/encryption-keys/
#
# SNAP_SECRET_KEY: generated by:
# travis encrypt SNAP_SECRET_KEY=xx --add
# https://github.com/neovim/neovim/pull/11428
# snapcraft key expires after 1 year. Steps to refresh it:
# 1. snapcraft enable-ci travis --refresh
# 2. mv .snapcraft/travis_snapcraft.cfg ci/snap/travis_snapcraft.cfg
# 3. Copy after_success command to ci/snap/deploy.sh from .travis.yml
# 4. Undo changes to .travis.yml
- secure: hd0qn2u8ABbJg5Bx4pBRcUQbKYFmcSHoecyHIPTCnGJT+NI41Bvm/IkN/N5DhBF+LbD3Q2nmR/dzI5H/dqS7RxMFvEx1DuFLendFHHX3MYf0AuKpXYY3gwgMTmqx8p/v6srlU7RBGWNGzHCWqksAem+EIWCe3I7WvfdKo1/DV/Y=
# Set "false" to force rebuild of third-party dependencies.
- CACHE_ENABLE=true
# Build directory for Neovim.
@ -145,6 +158,36 @@ jobs:
env:
- CLANG_SANITIZER=TSAN
- *common-job-env
- if: type != pull_request
name: snap
os: linux
env:
- LC_ALL: C.UTF-8
- LANG: C.UTF-8
- SNAPCRAFT_ENABLE_SILENT_REPORT: y
- SNAPCRAFT_ENABLE_DEVELOPER_DEBUG: y
addons:
snaps:
- name: snapcraft
channel: stable
classic: true
- name: http
- name: transfer
- name: lxd
channel: stable
# Override default before_install, before_cache.
before_install: /bin/true
before_cache: /bin/true
install: ci/snap/install.sh
before_script: echo "Building snap..."
script: ci/snap/script.sh
after_success: ci/snap/after_success.sh
deploy:
skip_cleanup: true
provider: script
script: ci/snap/deploy.sh
on:
branch: master
fast_finish: true
before_install: ci/before_install.sh

14
ci/snap/after_success.sh Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -e
set -o pipefail
RESULT_SNAP=$(find ./ -name "*.snap")
sudo snap install "$RESULT_SNAP" --dangerous --classic
/snap/bin/nvim --version
SHA256=$(sha256sum "$RESULT_SNAP")
echo "SHA256: ${SHA256} ."

21
ci/snap/deploy.sh Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -e
set -o pipefail
# not a tagged release, abort
# [[ "$TRAVIS_TAG" != "$TRAVIS_BRANCH" ]] && exit 0
mkdir -p .snapcraft
openssl aes-256-cbc -K $encrypted_ece1c4844832_key -iv $encrypted_ece1c4844832_iv
-in ci/snap/travis_snapcraft.cfg -out .snapcraft/snapcraft.cfg -d
SNAP=$(find ./ -name "*.snap")
# TODO(justinmk): This always does `edge` until we enable tagged builds.
if [[ "$SNAP" =~ "dirty" || "$SNAP" =~ "nightly" ]]; then
snapcraft push "$SNAP" --release edge
else
snapcraft push "$SNAP" --release candidate
fi

10
ci/snap/install.sh Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -e
set -o pipefail
sudo apt update
sudo /snap/bin/lxd.migrate -yes
sudo /snap/bin/lxd waitready
sudo /snap/bin/lxd init --auto

8
ci/snap/script.sh Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -e
set -o pipefail
mkdir -p "$TRAVIS_BUILD_DIR/snaps-cache"
sudo snapcraft --use-lxd

Binary file not shown.

View File

@ -1,5 +1,6 @@
name: neovim
version: git
name: nvim
base: core18
adopt-info: nvim
summary: Vim-fork focused on extensibility and agility.
description: |
Neovim is a project that seeks to aggressively refactor Vim in order to:
@ -9,22 +10,41 @@ description: |
Enable the implementation of new/modern user interfaces without any modifications to the core source
Improve extensibility with a new plugin architecture
For lots more details, see the wiki!
grade: stable # must be 'stable' to release into candidate/stable channels
confinement: classic
apps:
neovim:
command: usr/local/bin/nvim
plugs: [network, network-bind, x11]
nvim:
command: usr/bin/nvim
environment:
HOME: /home/$USER
VIM: $SNAP/usr/local/share/nvim/runtime
VIM: $SNAP/usr/share/nvim
VIMRUNTIME: $SNAP/usr/share/nvim/runtime
desktop: usr/share/applications/nvim.desktop
parts:
neovim:
nvim:
source: .
override-pull: |
snapcraftctl pull
major="$(awk '/NVIM_VERSION_MAJOR/{gsub(")","",$2); print $2}' CMakeLists.txt)"
minor="$(awk '/NVIM_VERSION_MINOR/{gsub(")","",$2); print $2}' CMakeLists.txt)"
patch="$(awk '/NVIM_VERSION_PATCH/{gsub(")","",$2); print $2}' CMakeLists.txt)"
version_prefix="v$major.$minor.$patch"
git_described="$(git describe --first-parent --dirty 2> /dev/null | perl -lpe 's/v\d.\d.\d-//g')"
git_described="${git_described:-$(git describe --first-parent --tags --always --dirty)}"
snapcraftctl set-version "${version_prefix}-${git_described}"
plugin: make
make-parameters:
- CMAKE_BUILD_TYPE=Release
- CMAKE_INSTALL_PREFIX=/usr
override-build: |
snapcraftctl build
# Fix Desktop file
sed -i 's|^Exec=nvim|Exec=/snap/bin/nvim.nvim|' ${SNAPCRAFT_PART_INSTALL}/usr/share/applications/nvim.desktop
sed -i 's|^TryExec=nvim|TryExec=/snap/bin/nvim.nvim|' ${SNAPCRAFT_PART_INSTALL}/usr/share/applications/nvim.desktop
sed -i 's|^Icon=.*|Icon=${SNAP}/usr/share/pixmaps/nvim.png|' ${SNAPCRAFT_PART_INSTALL}/usr/share/applications/nvim.desktop
build-packages:
- ninja-build
- libtool
@ -33,9 +53,10 @@ parts:
- automake
- cmake
- g++
- git
- gettext
- pkg-config
- unzip
snap:
- usr/local/bin
- usr/local/share/nvim
- -usr/local/share/man
prime:
- -usr/share/man