Skip to content

Commit

Permalink
Upload release artifacts to Google Cloud (#504)
Browse files Browse the repository at this point in the history
* Rename package to release and configure it to upload the artifacts to GCS

* Add release steps to upload the installation scripts to GCS

* Upload the artifacts to the latest/ directory

* Remove space

* Fix Rubocop issues

* Fix Rakefile
  • Loading branch information
Pedro Piñera Buendía committed Sep 19, 2019
1 parent 06d3517 commit ebd8c9b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 6 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ gem "encrypted-environment", "~> 0.2.0"
gem "google-cloud-storage", "~> 1.21"
gem "colorize", "~> 0.8.1"
gem "cocoapods", "~> 1.7"
gem "highline", "~> 2.0"
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ GEM
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (~> 0.7)
highline (2.0.2)
httpclient (2.8.3)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -229,6 +230,7 @@ DEPENDENCIES
danger-swiftlint (~> 0.23.0)
encrypted-environment (~> 0.2.0)
google-cloud-storage (~> 1.21)
highline (~> 2.0)
minitest (~> 5.11)
rake (~> 12.3)
rubocop (~> 0.74.0)
Expand Down
7 changes: 4 additions & 3 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This document describes the process of releasing new versions of tuist.
4. Update the version in the `Constants.swift` file.
5. Update the `CHANGELOG.md` to include the version section.
6. Commit the changes and tag the commit with the version `git tag x.y.z`.
7. Package the release running `bundle exec rake package`.
8. Push the changes to remote and create a new release on GitHub including the changelog. Attach all the files in the `build/` directory.
9. Deploy the documentation website to [Netlify](https://app.netlify.com/sites/peaceful-fermat-c0d5d7/deploys).
7. Package and upload the release to GCS by running `bundle exec rake release`.
8. Upload the installation scripts to GCS by running `bundle exec rake release_scripts`.
9. Create a release on GitHub with the version as a title, the body from the CHANGELOG file, and attach the artifacts in the `build/` directory.
10. Deploy the documentation website to [Netlify](https://app.netlify.com/sites/peaceful-fermat-c0d5d7/deploys).
40 changes: 37 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require 'fileutils'
require "google/cloud/storage"
require "encrypted/environment"
require 'colorize'
require 'highline'

Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "--format pretty"
Expand All @@ -29,10 +30,16 @@ task :style_ruby_correct do
system("bundle", "exec", "rubocop", "-a")
end

desc("Builds tuist and tuistenv for release and archives them")
task :package do
desc("Builds, archives, and publishes tuist and tuistenv for release")
task :release do
decrypt_secrets
package
release
end

desc("Publishes the installation scripts")
task :release_scripts do
decrypt_secrets
release_scripts
end

desc("Packages tuist, tags it with the commit sha and uploads it to gcs")
Expand Down Expand Up @@ -62,6 +69,13 @@ def decrypt_secrets
Encrypted::Environment.load_from_ejson("secrets.ejson", private_key: ENV["SECRET_KEY"])
end

def release_scripts
bucket = storage.bucket("tuist-releases")
print_section("Uploading installation scripts to the tuist-releases bucket on GCS")
bucket.create_file("install/install", "scripts/install").acl.public!
bucket.create_file("install/uninstall", "scripts/uninstall").acl.public!
end

def package
print_section("Building tuist")
FileUtils.mkdir_p("build")
Expand All @@ -82,10 +96,30 @@ def package
FileUtils.cp(".build/release/tuistenv.zip", "build/tuistenv.zip")
end

def release
version = cli.ask("Introduce the released version:")

package

bucket = storage.bucket("tuist-releases")

print_section("Uploading to the tuist-releases bucket on GCS")

bucket.create_file("build/tuist.zip", "#{version}/tuist.zip").acl.public!
bucket.create_file("build/tuistenv.zip", "#{version}/tuistenv.zip").acl.public!

bucket.create_file("build/tuist.zip", "latest/tuist.zip").acl.public!
bucket.create_file("build/tuistenv.zip", "latest/tuistenv.zip").acl.public!
end

def system(*args)
Kernel.system(*args) || abort
end

def cli
@cli ||= HighLine.new
end

def storage
@storage ||= Google::Cloud::Storage.new(
project_id: ENV["GCS_PROJECT_ID"],
Expand Down

0 comments on commit ebd8c9b

Please sign in to comment.