** I want to leave the difficult things to the machine as much as possible. ** **
Obviously, in order to update the iOS app, it is necessary to update the content of the update as well.
Until now, I used to copy and paste the app wording that the operator entered in Google Sheets one by one into App Store Connect.
Occasionally there is no problem, but as the number increases, it becomes difficult. I want to automate and make it easier. I want to make it easier. It was easy!
So, it worked, ** I'll write a procedure to automate the update of the App Store description using Google Sheets and Fastlane. ** **
-[Google Spreadsheet with App Store description](https://qiita.com/drafts/0f15157e93b8b9339656/edit#2-app-store Create a google spreadsheet with description)
This time, I will write it as an example of getting the wording of the App Store from the spreadsheet with this content.
Separate sheets by language (sheet names are "ja" for Japanese and "en-US" for English)
Japanese
app name | subtitle | promotion | Details | Update contents | keyword |
---|---|---|---|---|---|
Fully automatic shoulder massager | Please improve blood flow | Please use it. | This is a very healthy app. | Made minor corrections | Fully automatic, Massine |
English
app name | subtitle | promotion | Details | Update contents | keyword |
---|---|---|---|---|---|
Full Auto Shoulder massager | Please improve blood flow. | Please use it. | It's a very healthy app. | bugfix | Full Auto、 Let's |
To get the wording from Google Sheets, you need to hit "Google Drive API" and "Google SpreadSheet API".
And to hit these APIs from CI, you need to create a service account on GCP.
Go to Google Cloud Platform and create a project.
Go to APIs & Services> Credentials, click Create Credentials, and click Service Account.
Fill in your name, ID and service account description and click the Create button.
Determine the permissions of the service account. This time, I want to load Google Sheets, so ask the viewer (choose the appropriate permissions in a timely manner) and click the Continue button.
Click the Finish button.
A new item has been added to the service account column. Click.
Click Add Key, then click Create New Key.
A dialog like this will appear. Specify JSON and click Create. ** Rename the saved JSON file to config.json. ** **
After that, search for "Google Drive API" and "Google Spreadsheet API" from API Services> API Library, enable each API, and the setting is completed.
You can write it in the Fastfile, but in order not to make the Fastfile bloated, create your own Action and divide the processing.
Hit the following command.
bundle exec fastlane new action
You will be asked for a name, so guess an appropriate name. Should I say ** metadata **?
[20:28:11]: Name of your action: metadata
A file called fastlane / action / metadata.rb
will be generated.
Use the gem google-drive-ruby to load Google Sheets.
Add the following to the Gemfile
:
gem "google_drive"
Installation.
bundle install
Put the service account key (config.json) generated by Google Cloud Platform in fastlane / action /
(Jump here if you don't want to put the service account key / items / 0f15157e93b8b9339656 # 7-fastlane-plugin and published))
Add the following to the beginning of fastlane / action / metadata.rb
.
require "google_drive"
Write the following code in self.run (params)
.
Specify the contents of the spreadsheet written at the beginning as the following constants.
--LANGUAGES specifies the sheet name --COLUMNS specifies the Fastlane text file name for each item from the left (Refer to deliver for each text file name)
LANGUAGES = ["ja", "en-US"]
COLUMNS = ["name", "subtitle", "promotional_text", "description", "release_notes", "keywords"]
Load the spreadsheet, specifying the service account key file path and spreadsheet ID.
session = GoogleDrive::Session.from_config("config.json")
spreadsheet = session.spreadsheet_by_key("Spreadsheet ID")
All you have to do is pull the text for each column from the last row of the sheet for each language and save it in each text file.
LANGUAGES.each do |language|
spreadsheet.worksheet_by_title(language).rows.last.each_with_index do |text, i|
File.open("#{FastlaneCore::FastlaneFolder.path}metadata/#{language}/#{COLUMNS[i]}.txt", mode = "wb") do |f| f.write(text) end
end
end
require "google_drive"
module Fastlane
module Actions
class MetadataAction < Action
def self.run(params)
LANGUAGES = ["ja", "en-US"]
COLUMNS = ["name", "subtitle", "promotional_text", "description", "release_notes", "keywords"]
session = GoogleDrive::Session.from_config("config.json")
spreadsheet = session.spreadsheet_by_key("Spreadsheet ID")
LANGUAGES.each do |language|
spreadsheet.worksheet_by_title(language).rows.last.each_with_index do |text, i|
File.open("#{FastlaneCore::FastlaneFolder.path}metadata/#{language}/#{COLUMNS[i]}.txt", mode = "wb") do |f| f.write(text) end
end
end
end
def self.description
"A short description with <= 80 characters of what this action does"
end
def self.details
"You can use this action to do cool things..."
end
def self.available_options
[]
end
def self.authors
["Your GitHub/Twitter Name"]
end
def self.is_supported?(platform)
platform == :ios
end
end
end
end
After that, if you execute metadata on Fastfile, the items read from Google Spreadsheet will be saved in each text file.
Then run deliver (skip_metadata: false)
to update the App Store description.
lane :deploy_appstore do
metadata
deliver(skip_metadata: false)
end
By the way, if you make a pull request when a diff appears, it is recommended because the difference between the previous versions will be obvious at a glance.
What I explained so far, I tried Fastlane Plugin.
There were other plugins for the same purpose, but ** this allows me to specify an environment variable because I didn't want to Git manage the service account key file. ** Also, if you specify text file name that deliver does not use for metadata update in colims, the column there will be ignored. I have.
You can use it like this.
fetch_metadata_from_google_sheets(
languages: ["ja", "en-US"],
columns: ["version", "name", "subtitle", "release_notes", "promotional_text", "description", "keywords"],
spreadsheet_id: ENV["TEST_APP_STORE_METADATA_SPREADSHEET_ID"],
project_id: ENV["TEST_GCP_PROJECT_ID"],
service_account_private_key_id: ENV["TEST_GCP_SERVICE_ACCOUNT_PRIVATE_KEY_ID"],
service_account_private_key: ENV["TEST_GCP_SERVICE_ACCOUNT_PRIVATE_KEY"],
service_account_client_email: ENV["TEST_GCP_SERVICE_ACCOUNT_CLIENT_EMAIL"],
service_account_client_id: ENV["TEST_GCP_SERVICE_ACCOUNT_CLIENT_ID"],
service_account_auth_uri: ENV["TEST_GCP_SERVICE_ACCOUNT_AUTH_URI"],
service_account_token_uri: ENV["TEST_GCP_SERVICE_ACCOUNT_TOKEN_URI"],
service_account_auth_provider_x509_cert_url: ENV["TEST_GCP_SERVICE_ACCOUNT_AUTH_PROVIDER_X509_CERT_URL"],
service_account_client_x509_cert_url: ENV["TEST_GCP_SERVICE_ACCOUNT_CLIENT_X509_CERT_URL"]
)
For details, please refer to the following ribodigries.
kurarararara/fastlane-plugin-fetch_metadata_from_google_sheets https://github.com/kurarararara/fastlane-plugin-fetch_metadata_from_google_sheets
Until now, I was confused about making mistakes every time I copied and pasted, but after the automatic update, I made no mistakes and it became much easier.
If you have any problems, please try it.
Please also read this article.
Recommended Posts