Skip to content

Commit

Permalink
Merge pull request #82 from leopardslab/deb-package
Browse files Browse the repository at this point in the history
Deb package
  • Loading branch information
agentmilindu authored Jul 6, 2019
2 parents 9bdb3fa + 78c77ff commit d98a3d5
Show file tree
Hide file tree
Showing 6 changed files with 271 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ coverage*
.idea/*

snap.login

.DS_Store
25 changes: 16 additions & 9 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ builds:
- amd64
- arm
- arm64

archives:
- replacements:
386: i386
Expand All @@ -30,8 +31,12 @@ changelog:
snapshot:
name_template: "{{.ProjectName}}_{{.Tag}}"

brew:
github:
release:
draft: false
name_template: "{{.ProjectName}} v{{.Version}}"

brews:
- github:
owner: leopardslab
name: homebrew-dunner
folder: Formula
Expand All @@ -44,20 +49,22 @@ nfpm:
name_template: '{{ .ProjectName }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
homepage: https://github.com/leopardslab/Dunner
description: A Docker based task runner tool
maintainer: LeopardsLab Community
license: MIT
formats:
- deb
- rpm
dependencies:
- git
recommends:
- rpm
snapcraft:
name_template: '{{ .ProjectName }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'

snapcrafts:
- name_template: '{{ .ProjectName }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
summary: A Docker based task runner tool
description: |
Dunner is a task runner tool like Grunt but used Docker images like CircleCI do. |
You can define tasks and steps of the tasks in your `.dunner.yaml` file and then run these steps with `Dunner do taskname`
grade: stable
confinement: classic
confinement: strict
base: core18
publish: true
apps:
dunner:
plugs: ["home"]
38 changes: 35 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,68 @@
language: go

go:
- 1.11.x
- master

services:
- docker

env:
global:
- DEP_VERSION="0.5.0"
- PATH=/snap/bin:$PATH
services:
- docker

addons:
apt:
update: true
packages:
- rpm
- snapd

before_install:
- rpmbuild --version
- openssl aes-256-cbc -K $encrypted_12c8071d2874_key -iv $encrypted_12c8071d2874_iv
-in snap.login.enc -out snap.login -d
- curl -L -s https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64
-o $GOPATH/bin/dep
- chmod +x $GOPATH/bin/dep

install:
- make setup
- sudo snap install snapcraft --classic

script:
- make ci

after_success:
- bash <(curl -s https://codecov.io/bash)
- test -n "$TRAVIS_TAG" && snapcraft login --with snap.login

deploy:

- provider: script
skip_cleanup: true
script: curl -sL https://git.io/goreleaser | bash -s -- --rm-dist
verbose: true
on:
tags: true
condition: "$TRAVIS_OS_NAME = linux"
branch: master
go: 1.11.x

- provider: script
skip_cleanup: true
script: bash release/publish_rpm_to_bintray.sh
verbose: true
on:
tags: true
condition: "$TRAVIS_OS_NAME = linux"
branch: master
go: 1.11.x

- provider: script
skip_cleanup: true
script: curl -sL https://git.io/goreleaser | bash
script: bash release/publish_deb_to_bintray.sh
verbose: true
on:
tags: true
Expand Down
109 changes: 109 additions & 0 deletions release/publish_deb_to_bintray.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/bin/sh

set -e

REPO="dunner-deb"
PACKAGE="dunner"
DISTRIBUTIONS="stable"
COMPONENTS="main"

if [ -z "$USER" ]; then
echo "USER is not set"
exit 1
fi

if [ -z "$API_KEY" ]; then
echo "API_KEY is not set"
exit 1
fi

setVersion () {
VERSION=$(curl --silent "https://api.github.com/repos/leopardslab/dunner/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/');
}

setUploadDirPath () {
UPLOADDIRPATH="pool/d/$PACKAGE"
}

downloadDebianArtifacts() {
echo "Dowloading debian artifacts"
FILES=$(curl -s https://api.github.com/repos/leopardslab/dunner/releases/latest \
| grep "browser_download_url.*deb" \
| cut -d : -f 3 \
| sed -e 's/^/https:/' \
| tr -d '"' );
echo $FILES
for i in $FILES; do
RESPONSE_CODE=$(curl -O -w "%{response_code}" "$i")
code=$(echo "$RESPONSE_CODE" | head -c2)
if [ $code != "20" ] && [ $code != "30" ]; then
echo "Unable to download $i HTTP response code: $RESPONSE_CODE"
fi
done;
echo "Finished downloading"
}

bintrayUpload () {
for i in $FILES; do
FILENAME=${i##*/}
ARCH=$(echo ${FILENAME##*_} | cut -d '.' -f 1)
if [ $ARCH == "386" ]; then
ARCH="i386"
fi

URL="https://api.bintray.com/content/leopardslab/$REPO/$PACKAGE/$VERSION/$UPLOADDIRPATH/$FILENAME;deb_distribution=$DISTRIBUTIONS;deb_component=$COMPONENTS;deb_architecture=$ARCH?publish=1&override=1"
echo "Uploading $URL"

RESPONSE_CODE=$(curl -T $FILENAME -u$USER:$API_KEY $URL -I -s -w "%{response_code}" -o /dev/null);
code=$(echo "$RESPONSE_CODE" | head -c2)
if [ $code != "20" ] && [ $code != "30" ]; then
echo "Unable to upload, HTTP response code: $RESPONSE_CODE"
exit 1
fi
echo "HTTP response code: $RESPONSE_CODE"
done;
}

bintraySetDownloads () {
for i in $FILES; do
FILENAME=${i##*/}
ARCH=$(echo ${FILENAME##*_} | cut -d '.' -f 1)
if [ $ARCH == "386" ]; then
ARCH="i386"
fi
URL="https://api.bintray.com/file_metadata/leopardslab/$REPO/$UPLOADDIRPATH/$FILENAME"

echo "Putting $FILENAME in $PACKAGE's download list"
RESPONSE_CODE=$(curl -X PUT -d "{ \"list_in_downloads\": true }" -H "Content-Type: application/json" -u$USER:$API_KEY $URL -s -w "%{http_code}" -o /dev/null);

if [ "$(echo $RESPONSE_CODE | head -c2)" != "20" ]; then
echo "Unable to put in download list, HTTP response code: $RESPONSE_CODE"
exit 1
fi
echo "HTTP response code: $RESPONSE_CODE"
done
}

snooze () {
echo "\nSleeping for 30 seconds. Have a coffee..."
sleep 30s;
echo "Done sleeping\n"
}

printMeta () {
echo "Publishing: $PACKAGE"
echo "Version to be uploaded: $VERSION"
}

cleanArtifacts () {
rm -f "$(pwd)/*.deb"
}

cleanArtifacts
downloadDebianArtifacts
setVersion
printMeta
setUploadDirPath
bintrayUpload
snooze
bintraySetDownloads
109 changes: 109 additions & 0 deletions release/publish_rpm_to_bintray.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/bin/sh

set -e

REPO="dunner-rpm"
PACKAGE="dunner"

if [ -z "$USER" ]; then
echo "USER is not set"
exit 1
fi

if [ -z "$API_KEY" ]; then
echo "API_KEY is not set"
exit 1
fi

setVersion () {
VERSION=$(curl --silent "https://api.github.com/repos/leopardslab/dunner/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/');
}

setUploadDirPath () {
UPLOADDIRPATH="$PACKAGE/$VERSION"
}

downloadRpmArtifacts() {
echo "Dowloading rpm artifacts"
FILES=$(curl -s https://api.github.com/repos/leopardslab/dunner/releases/latest \
| grep "browser_download_url.*rpm" \
| cut -d : -f 3 \
| sed -e 's/^/https:/' \
| tr -d '"' );
echo "$FILES"
for i in $FILES; do
RESPONSE_CODE=$(curl -O -w "%{response_code}" "$i")
echo "$RESPONSE_CODE"
code=$(echo "$RESPONSE_CODE" | head -c2)
if [ $code != "20" ] && [ $code != "30" ]; then
echo "Unable to download $i HTTP response code: $RESPONSE_CODE"
exit 1
fi
done;
echo "Finished downloading"
}

bintrayUpload () {
for i in $FILES; do
FILENAME=${i##*/}
ARCH=$(echo ${FILENAME##*_} | cut -d '.' -f 1)
if [ $ARCH == "386" ]; then
ARCH="i386"
fi

URL="https://api.bintray.com/content/leopardslab/$REPO/$PACKAGE/$VERSION/$UPLOADDIRPATH/$FILENAME?publish=1&override=1"
echo "Uploading $URL"

RESPONSE_CODE=$(curl -T $FILENAME -u$USER:$API_KEY $URL -I -s -w "%{http_code}" -o /dev/null);
if [[ "$(echo $RESPONSE_CODE | head -c2)" != "20" ]]; then
echo "Unable to upload, HTTP response code: $RESPONSE_CODE"
exit 1
fi
echo "HTTP response code: $RESPONSE_CODE"
done;
}

bintraySetDownloads () {
for i in $FILES; do
FILENAME=${i##*/}
ARCH=$(echo ${FILENAME##*_} | cut -d '.' -f 1)
if [ $ARCH == "386" ]; then
ARCH="i386"
fi
URL="https://api.bintray.com/file_metadata/leopardslab/$REPO/$UPLOADDIRPATH/$FILENAME"

echo "Putting $FILENAME in $PACKAGE's download list"
RESPONSE_CODE=$(curl -X PUT -d "{ \"list_in_downloads\": true }" -H "Content-Type: application/json" -u$USER:$API_KEY $URL -s -w "%{http_code}" -o /dev/null);

if [ "$(echo $RESPONSE_CODE | head -c2)" != "20" ]; then
echo "Unable to put in download list, HTTP response code: $RESPONSE_CODE"
exit 1
fi
echo "HTTP response code: $RESPONSE_CODE"
done
}

snooze () {
echo "\nSleeping for 30 seconds. Have a coffee..."
sleep 30s;
echo "Done sleeping\n"
}

printMeta () {
echo "Publishing: $PACKAGE"
echo "Version to be uploaded: $VERSION"
}

cleanArtifacts () {
rm -f "$(pwd)/*.rpm"
}

cleanArtifacts
downloadRpmArtifacts
setVersion
printMeta
setUploadDirPath
bintrayUpload
snooze
bintraySetDownloads

24 changes: 0 additions & 24 deletions snapcraft.yaml

This file was deleted.

0 comments on commit d98a3d5

Please sign in to comment.