Skip to content

Commit

Permalink
Merge pull request #82 from cloudblue/windows_installer
Browse files Browse the repository at this point in the history
v24.5
  • Loading branch information
marcserrat authored Dec 15, 2021
2 parents e8b6097 + d5afab9 commit a02728c
Show file tree
Hide file tree
Showing 20 changed files with 700 additions and 1,196 deletions.
54 changes: 30 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
branches: [ master ]

jobs:
build:
test:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -34,26 +34,32 @@ jobs:
- name: Testing
run: |
poetry run pytest -v
- name: Upload coverage
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
fail_ci_if_error: true
verbose: true
- name: Fix coverage.xml for Sonar
run: |
sed -i 's/\/home\/runner\/work\/connect-cli\/connect-cli\//\/github\/workspace\//g' coverage.xml
- name: SonarCloud
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Wait sonar to process report
uses: jakejarvis/wait-action@master
with:
time: '60s'
- name: SonarQube Quality Gate check
uses: sonarsource/sonarqube-quality-gate-action@master
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
sonar:
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python 3.10.0
uses: actions/setup-python@v2
with:
python-version: '3.10.0'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Generate coverage report
run: |
poetry run pytest
- name: SonarCloud
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: SonarQube Quality Gate check
uses: sonarsource/sonarqube-quality-gate-action@master
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
120 changes: 15 additions & 105 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,6 @@ jobs:
tags: cloudblueconnect/connect-cli:${{ steps.tag.outputs.result }},cloudblueconnect/connect-cli:latest
- name: Docker image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Build linux distro
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo version = '${{ steps.tag.outputs.result }}' > connect/.data/version.txt
poetry run pyinstaller resources/ccli.spec
- name: Package linux distro
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tar cvfz connect-cli_${{ steps.tag.outputs.result }}_linux_amd64.tar.gz dist
- name: Upload distro package to artifacts
uses: actions/upload-artifact@v2
with:
name: linux_distro
path: connect-cli_${{ steps.tag.outputs.result }}_linux_amd64.tar.gz
retention-days: 5
windows:
runs-on: windows-latest
steps:
Expand All @@ -98,7 +81,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
pip install poetry pynsist wheel
poetry install
- name: Checkout latest reports repository
run: |
Expand All @@ -111,81 +94,36 @@ jobs:
result-encoding: string
script: |
return context.payload.ref.replace(/refs\/tags\//, '')
- name: Build windows distro
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate connect-cli wheel
run: |
echo version = '${{ steps.tag.outputs.result }}' > connect/.data/version.txt
poetry run pyinstaller resources/ccli.spec
poetry version ${{ steps.tag.outputs.result }}
poetry build
cp dist/*.whl resources/.
- name: Generate pynsist config file
run: |
poetry export --format requirements.txt --without-hashes --output resources/requirements.txt
poetry run python resources/generate_pynsist_config.py
cat resources/ccli.cfg
- name: Build windows installer
run: |
pynsist resources/ccli.cfg
- name: Package windows distro
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OS_NAME: windows
CPU_ARCH: amd64
PKG_TAG: ${{ steps.tag.outputs.result }}
run: |
& { compress-archive -path '.\dist' -destinationpath '.\connect-cli_${{ steps.tag.outputs.result }}_windows_amd64.zip' }
& { compress-archive -path '.\resources\build\nsis\connect-cli_${{ steps.tag.outputs.result }}_setup.exe' -destinationpath '.\connect-cli_${{ steps.tag.outputs.result }}_windows_amd64.zip' }
- name: Upload distro package to artifacts
uses: actions/upload-artifact@v2
with:
name: windows_distro
path: connect-cli_${{ steps.tag.outputs.result }}_windows_amd64.zip
retention-days: 5
osx:
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
brew install cairo pango gdk-pixbuf libffi git
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Linting
run: |
poetry run flake8
- name: Testing
run: |
poetry run pytest
- name: Checkout latest reports repository
run: |
poetry run python resources/get_latest_reports.py
- name: Extract tag name
uses: actions/github-script@v3
id: tag
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
return context.payload.ref.replace(/refs\/tags\//, '')
- name: Build osx distro
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo version = '${{ steps.tag.outputs.result }}' > connect/.data/version.txt
poetry run pyinstaller resources/ccli.spec
- name: Package osx distro
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tar cvfz connect-cli_${{ steps.tag.outputs.result }}_osx_amd64.tar.gz dist
- name: Upload distro package to artifacts
uses: actions/upload-artifact@v2
with:
name: osx_distro
path: connect-cli_${{ steps.tag.outputs.result }}_osx_amd64.tar.gz
retention-days: 5
release:
runs-on: ubuntu-latest
needs: [linux, windows, osx]
needs: [linux, windows]
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -210,20 +148,6 @@ jobs:
release_name: Release ${{ steps.tag.outputs.result }}
draft: false
prerelease: false
- name: Download linux artifact
uses: actions/download-artifact@v2
with:
name: linux_distro
path: ./
- name: Attach linux distro to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./connect-cli_${{ steps.tag.outputs.result }}_linux_amd64.tar.gz
asset_name: connect-cli_${{ steps.tag.outputs.result }}_linux_amd64.tar.gz
asset_content_type: application/tar+gzip
- name: Download windows artifact
uses: actions/download-artifact@v2
with:
Expand All @@ -238,17 +162,3 @@ jobs:
asset_path: ./connect-cli_${{ steps.tag.outputs.result }}_windows_amd64.zip
asset_name: connect-cli_${{ steps.tag.outputs.result }}_windows_amd64.zip
asset_content_type: application/zip
- name: Download osx artifact
uses: actions/download-artifact@v2
with:
name: osx_distro
path: ./
- name: Attach osx distro to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./connect-cli_${{ steps.tag.outputs.result }}_osx_amd64.tar.gz
asset_name: connect-cli_${{ steps.tag.outputs.result }}_osx_amd64.tar.gz
asset_content_type: application/tar+gzip
37 changes: 6 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Since it is extensible, users can write their own plugins to extend its function

### Prerequisites

`connect-cli` depends on [Cairo](https://www.cairographics.org/), [Pango](https://pango.gnome.org/) and
[GDK-PixBuf](https://developer.gnome.org/gdk-pixbuf/stable/).
`connect-cli` depends on [Git](https://git-scm.com/), [Cairo](https://www.cairographics.org/),
[Pango](https://pango.gnome.org/) and [GDK-PixBuf](https://developer.gnome.org/gdk-pixbuf/stable/).

Please refers to the platform-specific instructions on how to install these dependecies:

Expand Down Expand Up @@ -42,7 +42,7 @@ To use the Docker image of `connect-cli`:
Please refer to the [`connect-cli` docker image documentation](https://hub.docker.com/r/cloudblueconnect/connect-cli) for more information.


### Using Homebrew (Mac OS X only)
### Using Homebrew on Mac OS X

To install `connect-cli` with homebrew run:

Expand All @@ -52,36 +52,11 @@ To install `connect-cli` with homebrew run:
$ brew install cloudblue/connect/connect-cli
```

### Using the installer on Windows

An installer package is available for Windows 10 or newer.
You can download its zip file from the [Github Releases](https://github.com/cloudblue/connect-cli/releases) page.

### Binary distributions

A single executable binary distribution is available for windows, linux and mac os x.
You can it from the [Github Releases](https://github.com/cloudblue/connect-cli/releases) page.

To install under linux:

```
$ curl -O -J https://github.com/cloudblue/connect-cli/releases/download/xx.yy/connect-cli_xx.yy_linux_amd64.tar.gz
$ tar xvfz connect-cli_xx.yy_linux_amd64.tar.gz
$ sudo cp dist/ccli /usr/local/bin/ccli
```

To install under Mac OS X:

```
$ curl -O -J https://github.com/cloudblue/connect-cli/releases/download/xx.yy/connect-cli_xx.yy_osx_amd64.tar.gz
$ tar xvfz connect-cli_xx.yy_osx_amd64.tar.gz
$ sudo cp dist/ccli /usr/local/bin/ccli
```

> If your user is not a sudoer, you can copy the `ccli` executable from the dist directory to a directory of your choice
> that is listed in the `PATH` variable.

To install under Windows

Download the windows single executable zipfile from [Github Releases](https://github.com/cloudblue/connect-cli/releases/download/xx.yy/connect-cli_xx.yy_windows_amd64.zip), extract it and place it in a folder that is included in your `PATH` system variable.


## Usage
Expand Down
13 changes: 1 addition & 12 deletions connect/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,11 @@

# This file is part of the Ingram Micro Cloud Blue Connect connect-cli
# Copyright (c) 2019-2021 Ingram Micro. All Rights Reserved.
import os
import re

from pkg_resources import DistributionNotFound, get_distribution


MODULE_REGEX = r'[0-9]+.[0-9]'

BASE_DIR = os.path.dirname(os.path.dirname(__file__))
VERSION_FILE = os.path.join(BASE_DIR, os.path.join('.data', 'version.txt'))

try:
if os.path.exists(VERSION_FILE):
__version__ = re.search(MODULE_REGEX, open(VERSION_FILE, 'r').read()).group()
else:
__version__ = get_distribution('connect-cli').version
__version__ = get_distribution('connect-cli').version
except DistributionNotFound: # pragma: no cover
__version__ = '0.0.0'

Expand Down
6 changes: 0 additions & 6 deletions connect/cli/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

# This file is part of the Ingram Micro Cloud Blue Connect connect-cli.
# Copyright (c) 2019-2021 Ingram Micro. All Rights Reserved.
import sys

import click
import requests

Expand Down Expand Up @@ -38,7 +36,3 @@ def check_for_updates(*args):
)
except requests.RequestException:
pass


def is_bundle():
return getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS')
23 changes: 7 additions & 16 deletions connect/cli/plugins/project/cookiehelpers.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
import os
import shutil
import stat

from cookiecutter import generate
from cookiecutter.config import DEFAULT_CONFIG
from cookiecutter.utils import rmtree


def force_delete(func, path, exc_info):
os.chmod(path, stat.S_IWRITE)
func(path)


def purge_cookiecutters_dir():
# Avoid asking rewrite clone boilerplate project
cookie_dir = DEFAULT_CONFIG['cookiecutters_dir']
if os.path.isdir(cookie_dir):
rmtree(cookie_dir)
shutil.rmtree(cookie_dir, onerror=force_delete)


def slugify(name):
return name.lower().strip().replace(' ', '_').replace('-', '_').replace('.', '_').replace(',', '')


def remove_github_actions(project_dir: str):
shutil.rmtree(f'{project_dir}/.github')


def monkey_patch():
def _run_hook_from_repo_dir(
repo_dir, hook_name, project_dir, context, delete_project_on_failure,
): # pragma: no cover
'''Fake method for monkey patching purposes'''
pass
generate._run_hook_from_repo_dir = _run_hook_from_repo_dir
Loading

0 comments on commit a02728c

Please sign in to comment.