Friday, November 8, 2024

CodeBuild Adds macOS To Continuous Integration Pipelines

- Advertisement -

AWS CodeBuild may now be used to develop macOS applications. Manager Apple M2 computers running macOS 14 Sonoma now support building artefacts. Software packages that are ready for deployment are created, tested, and source code is assembled using AWS CodeBuild, a completely managed continuous integration solution.

Xcode is only compatible with macOS and is needed to build, test, sign, and distribute apps for the Apple operating systems (iOS, iPadOS, watchOS, tvOS, and macOS). It is highly likely that you have set up your continuous integration and deployment (CI/CD) pipeline to operate on Amazon Elastic Cloud Compute (Amazon EC2) Mac instances when you build for Apple systems in the AWS Cloud.

- Advertisement -

A customer’s pipeline could resemble the illustration below in its most basic form.

Anytime a new pull request or commit is made to the source code repository, the pipeline is initiated. Installation of the repository agent on the computer starts a series of processes that set up the environment, create, test, and finally publish the program to App Store Connect.

The administration and automation of macOS computers is made incredibly easier with Amazon EC2 Mac. A Mac mini running macOS in the cloud can have all the features from Amazon EC2, including volumes, snapshots, virtual private clouds (VPCs), security groups, and more.

Clients are still faced with two obstacles, though. First, get the Amazon Machine Image (AMI) ready for the build by adding all the necessary tools to it. Although Xcode is necessary for a minimum build environment, installing Fastlane, Ruby, and additional build or development tools and libraries is frequently done. For various macOS and Xcode version combinations, the majority of organisations need several build environments.

- Advertisement -

Adjusting your build fleet size based on the quantity and length of builds is the second challenge. Big companies usually need dozens of build machines because they do hundreds or thousands of builds every day. Reduce expenses by scaling up and down that fleet. Your dedicated use of EC2 Mac instances is reserved. To each dedicated host is assigned one instance. There are configuration requirements for scaling a fleet of dedicated hosts.

We now propose CodeBuild for macOS, a solution to these issues that will streamline the setup and maintenance of your macOS build machines.

Powered by instances powered by Amazon EC2, which are maintained by CodeBuild, the recently announced reserved capacity fleet serves as the foundation for CodeBuild for macOS. Configuring a set of instances specifically designated for your build environment is possible with reserved capacity fleets. In order to shorten build times, these machines stay inactive and are prepared to handle builds or tests instantly. Because reserved capacity fleets keep your machines provisioned and running constantly, you will continue to pay for them.

An AMI (standard disc image) is provided by CodeBuild for you to use while running builds. Popular tools for a development and build environment, such as Xcode, Fastlane, Ruby, Python, and Node.js, are preloaded on it. Check out the documentation for a complete list of installed tools. Updated versions of these utilities will be added to the disc images over time. Should you so want, you are also welcome to bring your own personalised disc image.

Furthermore, configuring auto scaling is a breeze with CodeBuild. AWS handle everything after you choose the capacity you require.

Watch as we demonstrate CodeBuild on macOS

Getting started with AWS Amplify on iOS and you set up a CI/CD pipeline to demonstrate how it works. You may learn how to make a basic iOS app with a cloud-based backend by following this article. Amazon Simple Storage Service (Amazon S3), Amazon DynamoDB, AWS AppSync, GraphQL API, file-based storage, and Amazon Cognito for user authentication are the resources used by the application. The element that connects all of these services is AWS Amplify for Swift.

There is a Git repository where you can find the app’s source code and instructions. The app’s build, testing, and deployment may all be automated with the use of scripts.

The following are the general stages involved in setting up a new CI/CD pipeline using CodeBuild for macOS:

  • Initiate the construction project.
  • Assemble the specialised machinery fleet.
  • Set up a construction trigger or many.
  • Join the project using a pipeline definition file (buildspec.yaml).

Choosing CodeBuild and then Create project, you launch the AWS Management Console to get started.

Once the connection to the source code repository is configured, you enter the name of the project. This demo makes use of GitHub. BitBucket and GitLab are supported by CodeBuild as well. A current list of compatible source code repositories is provided in the documentation.

You choose for Reserved capacity while using the Provisioning approach. Amazon EC2 Mac instances are available only with this model. You make the decision to define a fleet while developing the build project because you don’t currently have one. Create fleet is what you choose.

You may input a compute fleet name and choose macOS as the operating system on the compute fleet configuration page. You choose how much RAM and vCPUs my build project will require under Compute, and you choose how many instances you want under Capacity.

Along with other packages, it contains Xcode 15.4 and the iOS 17.5 simulator runtime.

To get back to the CodeBuild project creation page after you done, you choose Create fleet.

Next, in order to specify the permissions you desire for my build environment, you instruct CodeBuild to create a new service role. To get an Amplify configuration and access AWS Secrets Manager, you need to include rights specific to this project. The sample project code has the list of permissions you added.

Your set of build commands can be provided in a buildspec.yaml file that you include with your project, or you can provide them in the project specification.

Putting the build artefact on an S3 bucket so you can archive each build is optional, however you would like to do this. So, you choose Amazon S3 as the Type in the Artefact 1-Primary area and enter the names of the bucket and the artefact. Inside the buildspec.yaml file is the file name to upload.

You can set up a GitHub WebHook to be added by configuring the project trigger on the page. Whenever a commit or pull request is made to my GitHub project, CodeBuild will be set up to begin the build each time.

At the bottom of the screen, you choose the orange “Create project” button to finally start this project.

Things to consider

An Amazon EC2 Mac instance must be set up and accepted for the first build in 8 to 10 minutes. Not only CodeBuild is affected by this. Your submitted builds are queued and will be executed sequentially when the machine becomes available during the machine preparation period.

With reserved fleets, CodeBuild for macOS functions. Reserved fleets incur charges for the entire duration that the build machines are set aside for your exclusive use, even during idle builds, in contrast to on-demand fleets, where you pay for each minute of construction. Article 3.A.ii of the Software License Agreement for macOS mandates that the capacity reservation adhere to the 24-hour minimum allocation time for Amazon EC2 Mac.

Your AWS account allows you to share a fleet of machines with other CodeBuild projects. The fleet’s machinery is only available to you. Access to the computers is restricted to CodeBuild.

The workstations are repurposed for subsequent builds, although CodeBuild cleans the working directory in between builds. You can easily recover certain files after a build by utilising the CodeBuild local cache method. Make sure to clear any build artefacts, including the SwiftPM and Xcode package caches, and any global states, including the macOS keychain, before beginning a new build if you are building multiple projects on the same fleet.

As you deal with custom build images, make sure the architecture is 64-bit Mac-Arm. AWS Systems Manager Agent (SSM Agent) installation and startup are also required. The SSM Agent is used by CodeBuild for machine management and agent installation. Verify that the CodeBuild organisation ARN can access the AMI at this point.

In the US East (Ohio, N. Virginia), US West (Oregon), Asia Pacific (Sydney), and Europe (Frankfurt) AWS Regions, CodeBuild for macOS is distributed. Instances of Amazon EC2 Mac M2 are available in these same regions.

AWS CodeBuild Pricing

Pricing with AWS CodeBuild is as simple as pay-as-you-go. Minimum fees and upfront costs do not apply. Just the resources you utilize are paid for. Based on how long it takes for your build to run, you get billed for compute resources. The compute type that is chosen determines the rate.

- Advertisement -
Thota nithya
Thota nithya
Thota Nithya has been writing Cloud Computing articles for govindhtech from APR 2023. She was a science graduate. She was an enthusiast of cloud computing.
RELATED ARTICLES

Recent Posts

Popular Post

Govindhtech.com Would you like to receive notifications on latest updates? No Yes