All you need is a web browser (sic).
The whole setup should take about 20 minutes. I tried to write as much detail as possible so do not be daunted by the size of this guide, it's just very detailed to make the process easier.
- Apple account with active Apple Development Program subscription, enrolled as individual or part of a team
- GitHub account
- Google account
- iOS Device with TestFlight installed for testing
Here is a quick summary of what we are about to do:
- Clone the GitHub repository and set it up
- Generate Apple signing credentials and replace placeholders in the repo
- Log in to GitHub and press the ➕ button in the top right corner, then select "Import repository". We import the repository instead of forking it so that there's an option to set your repository to private. GitHub forks of public repositories can only be set to public. ⏯
- Paste the clone url:
https://github.com/solar2d/demo-app-store-automation.git
, pick a name for your repo, (e.g. "Solar2Demo"), and choose a visibility. This particular project does not contain any unencrypted sensitive information but if you plan to extend it, make it private. You can change the visibility later. - In your repo press "⚙ Settings" in the menu bar and pick "Secrets" in the sidebar.
- Press "New Repository Secret" and type the following Name and Value pairs into their corresponding fields, clicking "Add secret" for each. ⏯:
- Name:
AppleUser
Value: Your Apple ID user email. - Name:
ApplePassword
Value: Your Apple ID password. Most likely you have two-factor authentication set up, in which case don't use your actual password; Head to https://appleid.apple.com/ and log in, generate an "app-specific password" to use instead.
- Name:
- If your Apple Account is enrolled in the development program as part of a team then you have to specify an
AppleTeamId
secret. This step is otherwise optional. ⏯- Click on "Actions" in the menu bar and select "List Apple Teams" from the sidebar.
- Click on the "Run Workflow" button and confirm by clicking the green button.
- Wait a moment for the workflow to appear on the list. After some time, the symbol next to it should become a check mark ✓. Click on "List Apple Teams" near the check mark.
- Click "list" in the sidebar and then "List Teams" from the main page area. This should expand an ASCII table.
- Locate the desired team short name from the ProviderShortname column and save it as
AppleTeamId
in "Settings" → "Secrets". - This action log can contain some sensitive information, such as your name, accessible by anyone who has access to the repo, so I recommend deleting it. To do that, head back to the Actions tab and in the main page area click on the ⋯ button next to "List Apple Teams". Run and select "Delete workflow run". ⏯
- You may want to edit your app name. For that:
- Click on "Code" in the menu bar, and navigate to the "Util" directory.
- Click on the "recipe.lua" file and then the ✎ pencil button to edit it.
- Change the name in quotes, (currently "Solar2Demo"), in the editor and click the "Commit changes" button to save the file.
- I would strongly advise against using anything but basic English letters, or changing anything else in this file, unless you are very certain of what you are doing.
- Log in to the Apple Developer Web Portal: http://developer.apple.com/account/
- Select "Certificates, Identifiers & Profiles".
- In the sidebar, select "Identifiers" and click ➕ to create one.
- You want to create an "App ID" of the type "App".
- Fill out the form for this app:
- Description: Something you will recognize your app by, e.g.
Solar2D Demo App
. - App prefix: I usually select one which says "Team ID", but it doesn't matter much.
- Explicit bundle id: e.g.
com.solar2d.solar2demo
. You would have to change the company name to something else since this must be unique. - Default capabilities usually work just fine. You can edit them later.
- Description: Something you will recognize your app by, e.g.
Apple requires applications to be cryptographically signed. To do that you need two things: certificate and provisioning profile. Certificate identify your team and created created per account (same certificate is shared for all your projects). Xcode automates this process, but we will instead use command line utilities provided for free by Google Cloud Shell. ⏯
- Follow this: link. It should open a new terminal session for you.
- Run:
rm -f key.key distribution*; openssl req -newkey rsa:2048 -keyout key.key -out request.csr -nodes -subj "/C=CA/ST=/L=/O=/CN=Solar2D"; cloudshell dl request.csr
- This should prompt downloading a "request.csr" file. Accept it and do not close the terminal, you'll need it again in a minute.
- In the Apple Developer portal, go to "Certificates" → "IDs & Profiles" → "Certificates".
- Hit the ➕ button to start the process of creating a certificate.
- Select "Apple Distribution".
- Hit "Choose File" and select the "request.csr" file we just downloaded.
- Hit "Create" and then "Download" to get the "distribution.cer" certificate file.
- Return to the Cloud Shell window and upload the certificate. You can do this by dragging and dropping the "distribution.cer" file to the console or by selecting it via "Upload Files" in the ⋮ (More) menu.
- Run:
openssl x509 -inform DER -in distribution.cer -out distribution.crt && openssl pkcs12 -export -out distribution.p12 -inkey key.key -in distribution.crt && cloudshell dl distribution.p12 && rm -f key.key request.csr distribution.c*
- When prompted for a password I suggest using a strong randomly generated password.
- Save the password in your GitHub repo as
CertPassword
secret, (we added other secrets in the previous section). You will also need this password if you decide to use an actual Mac and import the certificate there. - Accept the p12 bundle, containing encrypted signing certificates.
- In your GitHub repo, navigate to "Code", then click on the "Util" directory.
- Press the "Add file" button and select "Upload files".
- Select the downloaded "distribution.p12" file and click the "Commit changes" button.
In your next project jump right to step 12 and reuse this password and distribution.p12
file.
Second part involved in signing is a provisioning profile. It identifies your application and its capabilities, so it has to be created for each project individually.
- Head to Developer Portal, select "Profiles" and click ➕ to create one.
- Select "App Store" from the Distribution section.
- Select the app ID we created earlier, ("com.solar2d.solar2demo" in my case).
- On the next page select the certificate we just created. If you have multiple then pick one with an expiry date exactly one year forward.
- On the next page type in the name "distribution" and hit "Generate".
- Download the generated profile. If your file is named differently, make sure you rename it to
distribution.mobileprovision
as the build script expects the file to be named as such. - Upload the file to replace a placeholder in the "Util" directory of your GitHub repository, as per the end of the previous section.
We have to create an App listing in order to upload and test the app.
- Head to the App Store Connect website: https://appstoreconnect.apple.com/
- Log in, read, and accept any user agreements.
- Select "My Apps".
- In the menu near "Apps" click the ➕ button and select "New App".
- In the popup:
- Select iOS as the platform.
- Name your app, e.g. "Solar2Demo".
- Choose a language, e.g. "English (U.S.)".
- Set the Bundle ID we created previously. For me it is "Solar2D Demo App - com.solar2d.solar2demo".
- Set an SKU to identify the app for yourself, e.g. "Solar2Demo".
- Select "Full Access" and click "Create".
- After a few moments you will have the App listing page.
- You will need this browser window later to set up testers, so keep it around.
When all is done you should have the following:
- 4 Secrets in GitHub repository settings ⏯:
-
AppleUser
-
ApplePassword
-
AppleTeamId
(Optional) -
CertPassword
-
- 2 files replaced in
Util
directory ⏯:-
Util/distribution.p12
-
Util/distribution.mobileprovision
-
Now for the fun part; Building and uploading the app:
- Navigate to your GitHub repo and select "Actions" from the menu bar.
- Select "Build and Deliver" in the workflows sidebar.
- Select "Run Workflow", leave all parameters as default and confirm by pressing the green button.
Done!
This will start a build. It should succeed in about 3-10 minutes, but it will also upload the built app to the App Store Connect, where it will undergo automatic processing. This may take some time.
Right after the GitHub action submitted a build, you can set up testing. To do that:
- Head back to the App Store Connect portal, and navigate to your app in "My Apps".
- In the top menu select "TestFlight" and then select "App Store Connect Users" in the sidebar under the "Internal Group" section.
- Hit ➕ near "Testers" and add at least yourself. This will send you an email.
- You have to open this email on your iOS device and click the button in it. The TestFlight app should open and prompt you to accept app testing.
When the build process is complete, you will get an email and/or push notification with a status update. Use TestFlight on the device to install your app and test it.
With repository and TestFlight already set up, all you have to do is push your code, navigate to "Build and Deliver" in your repo Actions, and run the workflow.
Then wait for a notification and use TestFlight to get the update.
Replace the project in the "Project" directory with your creation. Clone the repository to your computer, replace or modify contents, commit changes, and make new builds. When the update is ready, update your app with TestFlight.
Another option is to modify scripts and integrate them into your existing projects hosted on GitHub. Check out .github/workflows/build.yml
and Util/build.sh
for that.
If you enjoyed this template and guide, make sure you "Star" these projects on GitHub:
- Solar2D Game Engine: https://github.com/coronalabs/corona
- This template: https://github.com/solar2d/demo-app-store-automation
Solar2D is a fully open source game engine which relies on user donations to exist. Consider supporting the project on Patreon.
GitHub Actions has usage limits, especially for private repositories, so make sure you check them out. Today free users get 200 macOS minutes and incur costs of ¢8/minute over that limit. This is more than enough for pushing a build once or twice a week. You don't have to set up billing details until you run out of free minutes, and even then it is hard to beat their pricing.
If you have any questions report them to https://github.com/solar2d/demo-app-store-automation/issues.
Enjoy and create some awesome Solar2D games!