diff --git a/.travis.yml b/.travis.yml index 7092dd16..e11af1b4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,8 @@ matrix: env: - RUN_LONG_TESTS=yes - DEPLOY_BINARIES=yes + - APTLY_USER=aptly + - secure: "ejVss+Ansvk9f237iXVd87KA8N/SkfJkEdr/KCw9WRkVw3M9WyYtFnqpakIUPFT8RsSc7MW+RU4OM90DsbE9dbDIL0oW+t6QH/IfGjNG2HjDiGEWN/tMLeAQTtzPaVqlItJBo0ILMF2K6NrgkYBYU+tZ8gk5w7CuARvAk82d00o=" - go: master env: RUN_LONG_TESTS=no @@ -58,16 +60,33 @@ notifications: on_start: false # default: false before_deploy: - - make build - - export FILE_TO_UPLOAD=$(ls build/aptly-*) + - make release deploy: - provider: releases - api_key: - - secure: "MMk5S1Im6RrVudZasjtlCJa/rvRp4oavrR86WI2kQszs1iZIcdGyVhHiOGfWTwMjA/3iPdbAdu/WrjxCwI14GC5ws+rs8ICO6JIZktjtAwlfwlrV+nsrCiYx1EThghq43VEcykgz2UAJoJj/egv+UCEpe8yDTsvJ6we5HiXdTw0=" - file_glob: true - file: "${FILE_TO_UPLOAD}" - skip_cleanup: true - on: - tags: true - condition: "$DEPLOY_BINARIES = yes" + - provider: releases + api_key: + - secure: "MMk5S1Im6RrVudZasjtlCJa/rvRp4oavrR86WI2kQszs1iZIcdGyVhHiOGfWTwMjA/3iPdbAdu/WrjxCwI14GC5ws+rs8ICO6JIZktjtAwlfwlrV+nsrCiYx1EThghq43VEcykgz2UAJoJj/egv+UCEpe8yDTsvJ6we5HiXdTw0=" + file_glob: true + file: build/* + skip_cleanup: true + on: + tags: true + condition: "$DEPLOY_BINARIES = yes" + - provider: s3 + access_key_id: + secure: "I2etn22HHsQjJNhr6zdM/P4VLCYwEA/6HEf2eGvwey93oLeog+KnDCUI7lwGAHYuwzyDGQbZZ6YdoNc3b0kxaRWT0W+ke78TAdJhTZ+xbqGfEWv1er0zklJLOsimYF097rDJw8g3Oh/Gjwt5TTp0GJ5l3IhJ6zepNsKCMuwQpJM=" + secret_access_key: + secure: "inRWX7FuyhkhKzGknSd2/mjZaNFZm/zHMejM99OF6PiGLNtyt/esdA0ToYL8B8Icl0/SISlLlEr/DDa4OGENKueFVeHrKH7OK0jVbWp9Yvw4hCXSlw9VmlkHDMQrC4gybS2Hf7el8N4AFVqyeUE7LqiP3WruHRdbE9XgOnTkLkg=" + bucket: aptly-nightly + skip_cleanup: true + acl: public-read + local_dir: build + on: + branch: master + condition: "$DEPLOY_BINARIES = yes" + - provider: script + script: bash upload-artifacts.sh nightly + skip_cleanup: true + on: + branch: master + condition: "$DEPLOY_BINARIES = yes" diff --git a/Makefile b/Makefile index ade02504..ff4cee4f 100644 --- a/Makefile +++ b/Makefile @@ -36,11 +36,6 @@ endif install: go install -v -ldflags "-X main.Version=$(VERSION)" -build: - rm -rf build - mkdir -p build - go build -v -ldflags "-X main.Version=$(VERSION)" -o "build/aptly-$(VERSION)" - system/env: system/requirements.txt ifeq ($(RUN_LONG_TESTS), yes) rm -rf system/env @@ -66,14 +61,20 @@ mem.png: mem.dat mem.gp gnuplot mem.gp open mem.png -goxc: +goxc: dev rm -rf root/ mkdir -p root/usr/share/man/man1/ root/etc/bash_completion.d/ root/usr/share/zsh/vendor-completions/ cp man/aptly.1 root/usr/share/man/man1 cp completion.d/aptly root/etc/bash_completion.d/ cp completion.d/_aptly root/usr/share/zsh/vendor-completions/ gzip root/usr/share/man/man1/aptly.1 - goxc -pv=$(VERSION) -max-processors=4 $(GOXC_OPTS) + goxc -pv=$(VERSION) -max-processors=2 $(GOXC_OPTS) + +release: GOXC_OPTS=-tasks-=bintray,go-vet,go-test,rmbin +release: goxc + rm -rf build/ + mkdir -p build/ + mv xc-out/$(VERSION)/aptly_$(VERSION)_* build/ man: make -C man @@ -81,4 +82,4 @@ man: version: @echo $(VERSION) -.PHONY: man version build +.PHONY: man version release goxc diff --git a/aptly-api.service b/aptly-api.service index 4167d217..40fe7879 100644 --- a/aptly-api.service +++ b/aptly-api.service @@ -6,7 +6,7 @@ Documentation=https://www.aptly.info/doc/api/ [Service] Type=simple -ExecStart=/usr/bin/aptly serve api -no-lock -listen=127.0.0.1:8081 +ExecStart=/usr/bin/aptly api serve -no-lock -listen=127.0.0.1:8081 [Install] WantedBy=multi-user.target diff --git a/upload-artifacts.sh b/upload-artifacts.sh new file mode 100644 index 00000000..d26c82d2 --- /dev/null +++ b/upload-artifacts.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +set -e + +builds=build/ +packages=${builds}*.deb +folder=`mktemp -u tmp.XXXXXXXXXXXXXXX` +aptly_user="$APTLY_USER" +aptly_password="$APTLY_PASSWORD" +aptly_api="https://internal.aptly.info" + +for file in $packages; do + echo "Uploading $file..." + curl -sS -X POST -F "file=@$file" -u $aptly_user:$aptly_password ${aptly_api}/api/files/$folder + echo +done + +if [[ "$1" = "nightly" ]]; then + aptly_repository=aptly-nightly + aptly_published=s3:repo.aptly.info:./nightly + + echo "Adding packages to $aptly_repository..." + curl -sS -X POST -u $aptly_user:$aptly_password ${aptly_api}/api/repos/$aptly_repository/file/$folder + echo + + echo "Updating published repo..." + curl -sS -X PUT -H 'Content-Type: application/json' --data \ + '{"AcquireByHash": true, "Signing": {"Batch": true, "Keyring": "aptly.repo/aptly.pub", + "secretKeyring": "aptly.repo/aptly.sec", "PassphraseFile": "aptly.repo/passphrase"}}' \ + -u $aptly_user:$aptly_password ${aptly_api}/api/publish/$aptly_published + echo +fi + +curl -sS -X DELETE -u $aptly_user:$aptly_password ${aptly_api}/api/files/$folder +echo