Use rescue to conditionnaly build neovim according to available version

This commit is contained in:
flyingscorpio@clevo 2023-05-12 17:59:35 +02:00
parent 3fc4a674b5
commit 9bd6c03bf5
2 changed files with 49 additions and 19 deletions

View file

@ -0,0 +1,40 @@
---
- name: Install build dependencies
become: true
ansible.builtin.apt:
name:
- ninja-build
- gettext
- cmake
- unzip
- name: Make sure build directory exists
ansible.builtin.file:
path: ~/builds
state: directory
mode: 0755
- name: Clone neovim repo
ansible.builtin.git:
repo: https://github.com/neovim/neovim
dest: ~/builds/neovim
clone: true
version: stable
depth: 1
- name: Make neovim
community.general.make:
chdir: ~/builds/neovim
params:
CMAKE_BUILD_TYPE: Release
- name: Create neovim deb package
ansible.builtin.command:
chdir: ~/builds/neovim/build
cmd: cpack -G DEB
- name: Install neovim package
become: true
ansible.builtin.apt:
deb: ~/builds/neovim/build/nvim-linux64.deb

View file

@ -1,24 +1,14 @@
---
- name: Find latest neovim version
ansible.builtin.uri:
url: https://github.com/neovim/neovim/releases/latest
register: latest_http_content
- name: Set latest neovim version
ansible.builtin.set_fact:
neovim_version: "{{ latest_http_content.url | split('/') | last }}"
- name: Get latest neovim deb package
ansible.builtin.get_url:
url: "https://github.com/neovim/neovim/releases/download/{{ neovim_version }}/nvim-linux64.deb"
checksum: "sha256:https://github.com/neovim/neovim/releases/download/{{ neovim_version }}/nvim-linux64.deb.sha256sum"
dest: /tmp/nvim-linux64.deb
mode: 0644
- name: Install neovim deb package
become: true
ansible.builtin.apt:
deb: /tmp/nvim-linux64.deb
- name: Install neovim
block:
- name: Try installing with apt (from neovim v0.8)
become: true
ansible.builtin.apt:
name: neovim>0.8*
rescue:
- name: Build neovim
ansible.builtin.include_tasks: build_neovim.yml
- name: Install things with apt
become: true