Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #169 from viniciusramosdefaria/feature/packaging
Browse files Browse the repository at this point in the history
Feature/packaging
  • Loading branch information
viniciusramosdefaria authored Jun 17, 2020
2 parents 65685ea + 0e96c94 commit 5498f10
Show file tree
Hide file tree
Showing 24 changed files with 590 additions and 3 deletions.
93 changes: 91 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ references:
ruby: &RUBY_IMAGE cimg/ruby:2.6.5
ci_machine: &CI_MACHINE_IMAGE ubuntu-1604:202004-01
horus: &HORUS_IMAGE library/docker:dind
ubuntu: &UBUNTU_IMAGE cimg/base:2020.01
centos: &CENTOS_IMAGE viniciusramosdefaria/centos-circleci:7.0
windows: &WINDOWS_IMAGE windows-server-2019

paths:
test-results: &TEST_RESULTS_DIR bin
Expand Down Expand Up @@ -75,7 +78,19 @@ executors:
resource_class: windows.medium
shell: powershell.exe -ExecutionPolicy Unrestricted
machine:
image: windows-server-2019
image: *WINDOWS_IMAGE

ubuntu-executor:
docker:
- image: *UBUNTU_IMAGE
user: root
working_directory: /workspace

centos-executor:
docker:
- image: *CENTOS_IMAGE
user: root
working_directory: /workspace

jobs:
lint:
Expand Down Expand Up @@ -259,6 +274,63 @@ jobs:
. ./.circleci/scripts/credentials.sh
make delivery
deb-package:
environment:
<<: *ENVIRONMENT
executor: ubuntu-executor
steps:
- checkout
- attach_workspace:
at: /workspace/dist
- run:
name: Generating package for debian
command: |
. ./.circleci/scripts/version.sh
. ./.circleci/scripts/gen-deb.sh
- persist_to_workspace:
root: dist
paths:
- installer

rpm-package:
environment:
<<: *ENVIRONMENT
executor: centos-executor
steps:
- checkout
- attach_workspace:
at: /workspace/dist
- run:
name: Generating package for rpm
command: |
. ./.circleci/scripts/version.sh
. ./.circleci/scripts/gen-rpm.sh
- persist_to_workspace:
root: dist
paths:
- installer

win-package:
executor:
name: windows-executor
steps:
- checkout
- attach_workspace:
at: /workspace/dist
- run:
command: |
. ./.circleci/scripts/version.sh
echo $RELEASE_VERSION > release_version.txt
shell: bash.exe
- run:
command: |
.circleci/scripts/gen-win.ps1
shell: powershell.exe
- persist_to_workspace:
root: dist
paths:
- installer

release:
environment:
<<: *ENVIRONMENT
Expand Down Expand Up @@ -454,4 +526,21 @@ workflows:
<<: *FILTERS_DELIVERY
requires:
- build-code

- deb-package
- rpm-package
- win-package
- deb-package:
filters:
<<: *FILTERS_DELIVERY
requires:
- build-code
- rpm-package:
filters:
<<: *FILTERS_DELIVERY
requires:
- build-code
- win-package:
filters:
<<: *FILTERS_DELIVERY
requires:
- build-code
4 changes: 4 additions & 0 deletions .circleci/scripts/credentials.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ elif expr "$CIRCLE_BRANCH" : '^beta' >/dev/null; then
export AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID_PROD"
export AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY_PROD"

elif expr "$CIRCLE_BRANCH" : '^feature/packaging' >/dev/null; then
export AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID_PROD"
export AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY_PROD"

else
echo ""
fi
11 changes: 11 additions & 0 deletions .circleci/scripts/gen-deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh


mkdir -p dist/installer

curl -fsSL https://raw.githubusercontent.com/mh-cbon/latest/master/install.sh | GH=mh-cbon/go-bin-deb sh -xe
go-bin-deb generate --file packaging/debian/deb-single.json --version ${RELEASE_VERSION} -o dist/installer/ritchie-single.deb -a amd64
rm -rf pkg-build
go-bin-deb generate --file packaging/debian/deb-team.json --version ${RELEASE_VERSION} -o dist/installer/ritchie-team.deb -a amd64
rm -rf pkg-build
go-bin-deb generate --file packaging/debian/deb-team-zup.json --version ${RELEASE_VERSION} -o dist/installer/ritchie-team-zup.deb -a amd64
23 changes: 23 additions & 0 deletions .circleci/scripts/gen-rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

changelog init

mkdir -p pkg-build/SPECS

echo ${RELEASE_VERSION}

mkdir -p dist/installer

go-bin-rpm generate-spec --file packaging/rpm/rpm-team.json -a amd64 --version ${RELEASE_VERSION} > pkg-build/SPECS/ritchiecli.spec
go-bin-rpm generate --file packaging/rpm/rpm-team.json -a amd64 --version ${RELEASE_VERSION} -o dist/installer/ritchie-team.rpm

rm -rf pkg-build && mkdir -p pkg-build/SPECS

go-bin-rpm generate-spec --file packaging/rpm/rpm-single.json -a amd64 --version ${RELEASE_VERSION} > pkg-build/SPECS/ritchiecli.spec
go-bin-rpm generate --file packaging/rpm/rpm-single.json -a amd64 --version ${RELEASE_VERSION} -o dist/installer/ritchie-single.rpm

rm -rf pkg-build && mkdir -p pkg-build/SPECS

go-bin-rpm generate-spec --file packaging/rpm/rpm-team-zup.json -a amd64 --version ${RELEASE_VERSION} > pkg-build/SPECS/ritchiecli.spec
go-bin-rpm generate --file packaging/rpm/rpm-team-zup.json -a amd64 --version ${RELEASE_VERSION} -o dist/installer/ritchie-team-zup.rpm

78 changes: 78 additions & 0 deletions .circleci/scripts/gen-win.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

Write-Output 'DOWLOADING GO-MSI INSTALLER'

$url = "https://github.com/mh-cbon/go-msi/releases/download/1.0.2/go-msi-amd64.msi"
$output = "$((Get-Item -Path ".\").FullName)\go-msi-amd64.msi"
$start_time = Get-Date

$wc = New-Object System.Net.WebClient
$wc.DownloadFile($url, $output)

Write-Output "Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)"

Write-Output 'INSTALLING GO-MSI'

Start-Process msiexec.exe -Wait -ArgumentList "/I $output /quiet"

Write-Output 'DOWLOADING WIX FILES'

$url = "http://wixtoolset.org/downloads/v3.10.3.3007/wix310-binaries.zip"
$output = "$((Get-Item -Path ".\").FullName)\wix310-binaries.zip"
$start_time = Get-Date

$wc = New-Object System.Net.WebClient
$wc.DownloadFile($url, $output)

Write-Output "Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)"

Add-Type -AssemblyName System.IO.Compression.FileSystem
function Unzip
{
param([string]$zipfile, [string]$outpath)

[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}

Write-Output 'EXTRACTING WIX FILES TO PATH'

Unzip "$((Get-Item -Path ".\").FullName)\wix310-binaries.zip" "C:\\Users\circleci\AppData\Local\Microsoft\WindowsApps"

Write-Output 'Setting Release Version Variable'

$release_version=$(Get-Content .\release_version.txt)

mkdir dist\installer

copy LICENSE packaging/windows

cd packaging\windows

Write-Output 'GENERATING MSI TEAM INSTALLER'

& 'C:\Program Files\go-msi\go-msi.exe' make --msi ritchiecliteam.msi --version $release_version --path wix-team.json

Write-Output 'GENERATING CHOCO TEAM INSTALLER'

& 'C:\Program Files\go-msi\go-msi.exe' choco --version $release_version"-team" --input ritchiecliteam.msi --path wix-team.json

Write-Output 'GENERATING MSI SINGLE INSTALLER'

& 'C:\Program Files\go-msi\go-msi.exe' make --msi ritchieclisingle.msi --version $release_version --path wix-single.json

Write-Output 'GENERATING CHOCO SINGLE INSTALLER'

& 'C:\Program Files\go-msi\go-msi.exe' choco --version $release_version"-single" --input ritchieclisingle.msi --path wix-single.json

Write-Output 'GENERATING MSI TEAM ZUP INSTALLER'

& 'C:\Program Files\go-msi\go-msi.exe' make --msi ritchiecliteamzup.msi --version $release_version --path wix-team-zup.json

Write-Output 'GENERATING CHOCO TEAM ZUP INSTALLER'

& 'C:\Program Files\go-msi\go-msi.exe' choco --version $release_version"-teamzup" --input ritchiecliteamzup.msi --path wix-team-zup.json

Write-Output 'COPYING FILES TO THE RIGHT PLACE'

copy ritchie* ..\..\dist\installer

copy *.nupkg ..\..\dist\installer
2 changes: 1 addition & 1 deletion .circleci/scripts/gonna_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

DEPLOYED_VERSION=$(curl -s https://commons-repo.ritchiecli.io/stable.txt)

VERSION_TO_CHECK_AGAINST=$($VERSION_PLACEHOLDER | sed "s/PLACEHOLDER//")
VERSION_TO_CHECK_AGAINST=$(echo "$VERSION_PLACEHOLDER" | sed "s/PLACEHOLDER//")

if [ "$DEPLOYED_VERSION" == "$VERSION_TO_CHECK_AGAINST" ]; then
echo "RELEASE"
Expand Down
2 changes: 2 additions & 0 deletions .circleci/scripts/ritchie_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ elif expr "$VERSION" : '^nightly' >/dev/null; then
echo "https://ritchie-server.zup.io"
elif expr "$VERSION" : '^beta' >/dev/null; then
echo "https://ritchie-server.zup.io"
elif expr "$CIRCLE_BRANCH" : '^feature/packaging' >/dev/null; then
echo "https://ritchie-server.zup.io"
else
echo ""
fi
2 changes: 2 additions & 0 deletions .circleci/scripts/version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ elif expr "$CIRCLE_BRANCH" : '^nightly' >/dev/null; then
export RELEASE_VERSION="nightly"
elif expr "$CIRCLE_BRANCH" : '^beta' >/dev/null; then
export RELEASE_VERSION="$(.circleci/scripts/beta.sh)"
elif expr "$CIRCLE_BRANCH" : '^feature/packaging' >/dev/null; then
export RELEASE_VERSION="1.0.0-test.1"
else
export RELEASE_VERSION=$(curl https://commons-repo.ritchiecli.io/stable.txt)
echo ""
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,5 @@ Temporary Items

# Jenkins mvn
settings.xml
/change.log
/pkg-build/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![CircleCI](https://circleci.com/gh/ZupIT/ritchie-cli/tree/master.svg?style=svg)](https://circleci.com/gh/ZupIT/ritchie-cli) [![codecov](https://codecov.io/gh/zupit/ritchie-cli/branch/master/graph/badge.svg)](https://codecov.io/gh/zupit/ritchie-cli) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)


<img class="special-img-class" src="/docs/img/ritchie-banner.png" />

## Ritchie
Expand Down
16 changes: 16 additions & 0 deletions packaging/Dockerfile-Centos
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM centos:7

# Install needed software and users
USER root
RUN groupadd -r circleci && useradd -r -d /home/circleci -m -g circleci circleci

RUN curl -s -L https://bintray.com/mh-cbon/rpm/rpm > /etc/yum.repos.d/w.repo

RUN yum install -y epel-release && \
yum install -y git tar curl wget sudo make yum-utils device-mapper-persistent-data lvm2 && \
yum clean all && \
yum install go-bin-rpm changelog rpm-build -y --quiet

RUN echo "%circleci ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

USER circleci
15 changes: 15 additions & 0 deletions packaging/debian/deb-single.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "ritchiecli",
"maintainer": "viniciusramosdefaria <viniciusramosdefaria@gmail.com>",
"description": "Install ritchie CLI",
"homepage": "https://ritchiecli.io",
"files": [
{
"from": "dist/linux/single/rit",
"to": "/usr/local/bin",
"base": "dist/linux/single",
"fperm": "0755"
}
],
"preinst-file": "packaging/scripts/preinst.sh"
}
16 changes: 16 additions & 0 deletions packaging/debian/deb-team-zup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "ritchiecli",
"maintainer": "viniciusramosdefaria <viniciusramosdefaria@gmail.com>",
"description": "Install ritchie CLI",
"homepage": "https://ritchiecli.io",
"files": [
{
"from": "dist/linux/team/rit",
"to": "/usr/local/bin",
"base" : "dist/linux/team",
"fperm": "0755"
}
],
"preinst-file": "packaging/scripts/preinst.sh",
"postinst-file": "packaging/scripts/postinst-zup.sh"
}
16 changes: 16 additions & 0 deletions packaging/debian/deb-team.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "ritchiecli",
"maintainer": "viniciusramosdefaria <viniciusramosdefaria@gmail.com>",
"description": "Install ritchie CLI",
"homepage": "https://ritchiecli.io",
"files": [
{
"from": "dist/linux/team/rit",
"to": "/usr/local/bin",
"base" : "dist/linux/team",
"fperm": "0755"
}
],
"preinst-file": "packaging/scripts/preinst.sh",
"postinst-file": "packaging/scripts/postinst.sh"
}
17 changes: 17 additions & 0 deletions packaging/rpm/rpm-single.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "ritchiecli",
"summary": "RitchieCLI installer",
"description": "Install ritchie CLI",
"license": "LICENSE",
"changelog-cmd": "changelog rpm",
"url": "https://github.com/ZupIT/ritchie-cli",
"files": [
{
"from": "dist/linux/single/rit",
"to": "/usr/local/bin",
"base": "dist/linux/single",
"type": ""
}
],
"preinst": "packaging/scripts/preinst.sh"
}
18 changes: 18 additions & 0 deletions packaging/rpm/rpm-team-zup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "ritchiecli",
"summary": "RitchieCLI installer",
"description": "Install ritchie CLI",
"license": "LICENSE",
"changelog-cmd": "changelog rpm",
"url": "https://github.com/ZupIT/ritchie-cli",
"files": [
{
"from": "dist/linux/team/rit",
"to": "/usr/local/bin",
"base": "dist/linux/team",
"type": ""
}
],
"preinst": "packaging/scripts/preinst.sh",
"postinst": "packaging/scripts/postinst-zup.sh"
}
Loading

0 comments on commit 5498f10

Please sign in to comment.