If you haven’t read TestFlight Build By Fastlane using Swift – Step By step tutorial Kindly look and then follow this tutorial.
What is Continuous Integration (CI)?
Continuous Integration (CI) is a development practice where developers integrate code into a shared repository frequently, preferably several times a day. Each integration can then be verified by an automated build and automated tests. While automated testing is not strictly part of CI it is typically implied. For more read here.
1. Create Repository for the Project in GitLab
- Login to GitLab account and create a new repository and clone into your local machine.
2. Setup Gitlab Runner
- To install Gitlab Runner to the project, download the binary for your system using the command
sudo curl --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-amd64
- After the completion of download, give it permissions to execute using the command
sudo chmod +x /usr/local/bin/gitlab-runner
3. The next step is to register the runner, you can follow doc here.
- To register runner. Don’t register with sudo, we tried it will not work.
gitlab-runner register
- Enter your Gitlab instance URL
https://gitlab.com
- Enter your Gitlab runner token (This token will be available in Settings > CI/CD > Runners in the Gitlab project)
xxxx
- Enter description for the runner when prompted
fastlane-ios-runner
- Enter the tags associated with runner
ios, fastlane
- Enter the executor
shell
4. Start the GitLab Runner
To start the Gitlab runner enter the following commands.
gitlab-runner install gitlab-runner start
To check whether the runner has started, go to Settings > CI/CD > Runners ,the runner with provided tags and description must be available there. Now runner have green icon to indicate it’s active. If runner icon is grey or any other color your runner haven’t started.
5. fastlane Configuration
As I told early follow this tutorial (TestFlight Build By Fastlane using Swift – Step By step tutorial) to setup and configure the fastlane.
6. .gitlab-ci.yml configuration
What is .gitlab-ci.yml?
The .gitlab-ci.yml file is where you configure what CI does with your project. It lives in the root of your repository.
On any push to your repository, GitLab will look for the .gitlab-ci.yml file and start jobs on Runners according to the contents of the file, for that commit.
The .gitlab-ci.yml file defines sets of jobs with constraints of how and when they should be run. For more details please refer here
Now create a file named .gitlab-ci.yml in the root directory of your repository and edit the file as following,
Now push your code to master branch, now script will get executed and build will be uploaded to TestFlight.
The status of .gitlab-ci.yml execution can be checked in CI/CD > Pipelines in Left Menu.
Leave a Reply