diff --git a/.gitignore b/.gitignore index e9cd914..fd75581 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ coverage* .idea/* snap.login + +.DS_Store \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml index 6cc6e0a..9a96230 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -12,6 +12,7 @@ builds: - amd64 - arm - arm64 + archives: - replacements: 386: i386 @@ -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 @@ -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"] diff --git a/.travis.yml b/.travis.yml index d710dc2..8a40ffc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/release/publish_deb_to_bintray.sh b/release/publish_deb_to_bintray.sh new file mode 100755 index 0000000..42877d6 --- /dev/null +++ b/release/publish_deb_to_bintray.sh @@ -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 diff --git a/release/publish_rpm_to_bintray.sh b/release/publish_rpm_to_bintray.sh new file mode 100755 index 0000000..afc928e --- /dev/null +++ b/release/publish_rpm_to_bintray.sh @@ -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 + diff --git a/snapcraft.yaml b/snapcraft.yaml deleted file mode 100644 index ec68653..0000000 --- a/snapcraft.yaml +++ /dev/null @@ -1,24 +0,0 @@ -name: dunner -version: git -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: strict -base: core18 - -parts: - dunner: - plugin: go - go-importpath: github.com/leopardslab/dunner - source: . - source-type: git - build-packages: - - gcc - -apps: - dunner: - command: bin/dunner - plugs: - - personal-files