From 4bdb8bad250fb5eae52d787a816cc17cad1b7931 Mon Sep 17 00:00:00 2001 From: pastak Date: Fri, 6 Nov 2015 14:59:30 +0900 Subject: [PATCH 1/2] fetch destributions from packagecloud API --- circle_release.rb | 14 ++++++++++++++ circle_release.sh | 26 -------------------------- rpm_docker.sh | 3 +-- rpm_release.rb | 14 ++++++++++++++ 4 files changed, 29 insertions(+), 28 deletions(-) create mode 100755 circle_release.rb delete mode 100755 circle_release.sh create mode 100644 rpm_release.rb diff --git a/circle_release.rb b/circle_release.rb new file mode 100755 index 0000000..4f5abfd --- /dev/null +++ b/circle_release.rb @@ -0,0 +1,14 @@ +#!/usr/bin/env ruby +require 'json' +TOKEN = process.env['PACKAGECLOUD_TOKEN'] + +body = `curl -u #{TOKEN}: https://packagecloud.io/api/v1/distributions.json` +json = JSON.parse(body) + +json['deb'].each do |item| + os = item['index_name'] + item['versions'].each do |version| + target = "#{os}/#{version['index_name']}" + `package_cloud push gyazo/gyazo-for-linux/#{target} ../gyazo*all.deb || true` + end +end diff --git a/circle_release.sh b/circle_release.sh deleted file mode 100755 index 956148a..0000000 --- a/circle_release.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -declare -a deb_targets=( - "linuxmint/petra" - "linuxmint/qiana" - "linuxmint/rebecca" - "linuxmint/rafaela" - "linuxmint/rosa" - "debian/squeeze" - "debian/wheezy" - "debian/jessie" - "debian/stretch" - "debian/buster" - "ubuntu/precise" - "ubuntu/quantal" - "ubuntu/raring" - "ubuntu/saucy" - "ubuntu/trusty" - "ubuntu/utopic" - "ubuntu/vivid" - "ubuntu/wily" -) - -for e in ${deb_targets[@]}; do - package_cloud push gyazo/gyazo-for-linux/$e ../gyazo*all.deb || true -done diff --git a/rpm_docker.sh b/rpm_docker.sh index aefb226..3fcce12 100644 --- a/rpm_docker.sh +++ b/rpm_docker.sh @@ -2,5 +2,4 @@ sudo service docker start docker build -t gyazo/build:latest . -docker run -e PACKAGECLOUD_TOKEN=$PACKAGECLOUD_TOKEN gyazo/build package_cloud push gyazo/gyazo-for-linux/el/6 /root/rpmbuild/RPMS/x86_64/$PACKAGE-$VERSION-1.x86_64.rpm || true -docker run -e PACKAGECLOUD_TOKEN=$PACKAGECLOUD_TOKEN gyazo/build package_cloud push gyazo/gyazo-for-linux/el/7 /root/rpmbuild/RPMS/x86_64/$PACKAGE-$VERSION-1.x86_64.rpm || true +docker run -e PACKAGECLOUD_TOKEN=$PACKAGECLOUD_TOKEN gyazo/build || /root/rpm_release.rb diff --git a/rpm_release.rb b/rpm_release.rb new file mode 100644 index 0000000..03e506c --- /dev/null +++ b/rpm_release.rb @@ -0,0 +1,14 @@ +#!/usr/bin/env ruby +require 'json' +TOKEN = process.env['PACKAGECLOUD_TOKEN'] + +body = `curl -u #{TOKEN}: https://packagecloud.io/api/v1/distributions.json` +json = JSON.parse(body) + +json['rpm'].each do |item| + os = item['index_name'] + item['versions'].each do |version| + target = "#{os}/#{version['index_name']}" + `package_cloud push gyazo/gyazo-for-linux/#{target} /root/rpmbuild/RPMS/x86_64/$PACKAGE-$VERSION-1.x86_64.rpm` + end +end From 48c7642852a1e784c47fab27304d0685a17559aa Mon Sep 17 00:00:00 2001 From: pastak Date: Fri, 6 Nov 2015 15:16:35 +0900 Subject: [PATCH 2/2] tweak --- circle.yml | 2 +- circle_release.rb | 2 +- rpm_docker.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/circle.yml b/circle.yml index d18fbcb..ad5e641 100644 --- a/circle.yml +++ b/circle.yml @@ -12,5 +12,5 @@ deployment: branch: release commands: - sh ./deb.sh - - bash ./circle_release.sh + - ruby ./circle_release.rb - bash ./rpm_docker.sh diff --git a/circle_release.rb b/circle_release.rb index 4f5abfd..8d39a35 100755 --- a/circle_release.rb +++ b/circle_release.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby require 'json' -TOKEN = process.env['PACKAGECLOUD_TOKEN'] +TOKEN = ENV['PACKAGECLOUD_TOKEN'] body = `curl -u #{TOKEN}: https://packagecloud.io/api/v1/distributions.json` json = JSON.parse(body) diff --git a/rpm_docker.sh b/rpm_docker.sh index 3fcce12..2e33e35 100644 --- a/rpm_docker.sh +++ b/rpm_docker.sh @@ -2,4 +2,4 @@ sudo service docker start docker build -t gyazo/build:latest . -docker run -e PACKAGECLOUD_TOKEN=$PACKAGECLOUD_TOKEN gyazo/build || /root/rpm_release.rb +docker run -e PACKAGECLOUD_TOKEN=$PACKAGECLOUD_TOKEN gyazo/build ruby /tmp/build/rpm_release.rb