Go Build API
Montuer has a continuously developed build recipe dedicated for Go Programming
Language to build its output.
The objective is simple: to build a Go app for a specific compute
system in a consistent and reproducible manner.
All users has to do is to issue this command:
|
|
For this recipe, they are arranged based on its own semantic versioning and is not directly related to Monteur's actual release version. Hence, feel free to explore and update each versions to suit your CI needs.
Resources
This recipe is built and maintained based on the following resources:
Go Programming Language - https://go.dev/
Monteur Build Data Structure - https://monteur.zoralab.com/en/ci-jobs/build/
One Time Setup
To ensure maximum compatibility with the recipe, you might need
to setup your build system with some of the Go
specific one-time setup into your build system.
Cross Build
There is a very high chance that you will perform
cross-build in your current build system. Unfortunately,
Go has yet to completely support its
internal linking feature for all its offering CPU
architectures
(See
Issue 50405).
Hence, you need to at least make sure the correct
crossbuild-essentials tools are readily
available in your operating system. Here are some
examples for installing cross-building essential tools
for armhf and aarch64:
|
|
Recipe File
Here are all the Monteur Build CI Job recipe files
for operating Go semi-autonomously.
They are sorted by the latest version first, at the top.
Please read through its requiremnets and changes before
procuring.
Version v2.0.0
Download Link: go-v2p0p0.toml
Minimum Requirements
Montuer version:
v0.0.2and above.Supported platform: STRICTLY depends on
Goavailability.
Installation Instructions
Download and place the recipe file into your
.configs/montuer/build/jobsdirectory as[OS]-[ARCH].tomlfilename pattern likelinux-amd64.toml.Update the recipe's
Metadata.Nameto match the build summary name.Update the recipe's
Metadata.Descriptionto accordingly especially replacing<APP>,<OS>, and<CPU>placeholders with their respective actual values.Update the recipe's
Variables.PlatformOSto match the target OS with the Go compatible value (e.g.linux).Update the recipe's
Variables.PlatformCPUto match the target CPU architecture with the Go compatible value (e.g.amd64and NOTx86_64).Update the recipe's
Variables.PlatformExtto optionally match the OS compatible file extension like.exeforwindows. Otherwise, leave it blank.Update the recipe's
Variables.BuildFlagsto match your own Go build customizations.Update the recipe's
Variables.BuildConditionsto match the build environments and conditions. The default includes everything sensible so please remove all non-applicable ones likeCC=arm-linux-gnueabi-gccfor non-armbuild. Please keepCGO_ENABLED=0as minimum value to explictly instructgonot to usecgoat all.Update the recipe's
FMTVariables.SrcPathto match the directory location of yourmainpackage (containingmain.go).Update the recipe's
[[Dependencies]]to have applicable dependencies likearm-linux-gnueabi-gccforarmbuild.
Changelog
BACKWARD COMPATBILE - Added
armbuild with their specific dependencies and build conditions.BACKWARD COMPATBILE - Added
-trimpathand its other variants intoVariables.BuildFlags.BACKWARD COMPATBILE - Added
Variables.BuildConditionsto enable CGO and arm configurable settings.BACKWARD COMPATBILE - Added
CGO_ENABLED=0to explictly instructgoto usecgoat will.
Version v1.0.0
Download Link: go-v1p0p0.toml
Minimum Requirements
Montuer version:
v0.0.1.Supported platform: STRICTLY depends on
Goavailability.
Installation Instructions
Download and place the recipe file into your
.configs/app/variants/directory as[OS]-[ARCH].tomlfilename pattern likelinux-amd64.toml.Update the recipe's
Metadata.Nameto match the build summary name.Update the recipe's
Metadata.Descriptionaccordingly especially replacing<APP>,<OS>, and<CPU>placeholders with their respective actual values.Update the recipe's
Variables.PlatformOSto match the target OS with the Go compatible value (e.g.linux).Update the recipe's
Variables.PlatformCPUto match the target CPU architecture with the Go compatible value (e.g.amd64and NOTx86_64).Update the recipe's
Variables.PlatformExtto optionally match the OS compatible file extension like.exeforwindows. Otherwise, leave it blank.Update the recipe's
Variables.BuildFlagsto match your own Go build customizations.Update the recipe's
FMTVariables.SrcPathto match the directory location of yourmainpackage (containingmain.go).
Changelog
BACKWARD COMPATBILE - Created the base TOML configuration recipe.
BACKWARD COMPATBILE - Tested with GitLab CI.
BACKWARD COMPATBILE - Using
gowith-buildmode=pie -ldflags "-s -w"as default arguments.
Epilogue
That's all for Monteur's Build CI Job handling Go building tasks.
If you have any question, please feel free to raise your
question at our Issues
Section.