Skip to content

Instantly share code, notes, and snippets.

@marcomorain
Created July 1, 2019 14:00
Show Gist options
  • Save marcomorain/3e0e987670c30700305e4568d79b33af to your computer and use it in GitHub Desktop.
Save marcomorain/3e0e987670c30700305e4568d79b33af to your computer and use it in GitHub Desktop.
desc 'Renew push certifications and store them on the server'
lane :renew_certificate do
fastlane_require 'spaceship'
config = whitelabel(type: :store, download: false)
# If we are at the limit of push certificates (2), then revoke
# the oldest.
Spaceship::Portal.login
existing_certificates = Spaceship::Portal.certificate.production_push.all
.select {|c| c.owner_name == config.bundle_id }
.sort_by(&:expires)
if existing_certificates.count == 2
UI.message "Found 2 existing push certificates; revoking the oldest"
existing_certificates.first.revoke!
end
pem(force: true, new_profile: Proc.new { |pem| upload_pem(config, pem) })
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment