mirror of
https://code.forgejo.org/actions/go-versions
synced 2025-07-04 15:55:59 +02:00
Implement builders to build Go from source code
This commit is contained in:
parent
8c06ab5f1e
commit
6cf25b0561
21 changed files with 836 additions and 0 deletions
57
builders/nix-go-builder.psm1
Normal file
57
builders/nix-go-builder.psm1
Normal file
|
@ -0,0 +1,57 @@
|
|||
using module "./builders/go-builder.psm1"
|
||||
|
||||
class NixGoBuilder : GoBuilder {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Ubuntu Go builder class.
|
||||
|
||||
.DESCRIPTION
|
||||
Contains methods that required to build Ubuntu Go artifact from sources. Inherited from base NixGoBuilder.
|
||||
|
||||
.PARAMETER platform
|
||||
The full name of platform for which Go should be built.
|
||||
|
||||
.PARAMETER version
|
||||
The version of Go that should be built.
|
||||
|
||||
#>
|
||||
|
||||
[string] $InstallationTemplateName
|
||||
[string] $InstallationScriptName
|
||||
[string] $OutputArtifactName
|
||||
|
||||
NixGoBuilder(
|
||||
[version] $version,
|
||||
[string] $platform,
|
||||
[string] $architecture
|
||||
) : Base($version, $platform, $architecture) {
|
||||
$this.InstallationTemplateName = "nix-setup-template.sh"
|
||||
$this.InstallationScriptName = "setup.sh"
|
||||
$this.OutputArtifactName = "go-$Version-$Platform-$Architecture.tar.gz"
|
||||
}
|
||||
|
||||
[void] ExtractBinaries($archivePath) {
|
||||
Extract-TarArchive -ArchivePath $archivePath -OutputDirectory $this.WorkFolderLocation
|
||||
}
|
||||
|
||||
[void] CreateInstallationScript() {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Create Go artifact installation script based on template specified in InstallationTemplateName property.
|
||||
#>
|
||||
|
||||
$installationScriptLocation = New-Item -Path $this.WorkFolderLocation -Name $this.InstallationScriptName -ItemType File
|
||||
$installationTemplateLocation = Join-Path -Path $this.InstallationTemplatesLocation -ChildPath $this.InstallationTemplateName
|
||||
|
||||
$installationTemplateContent = Get-Content -Path $installationTemplateLocation -Raw
|
||||
$installationTemplateContent = $installationTemplateContent -f $this.Version.ToString(3)
|
||||
$installationTemplateContent | Out-File -FilePath $installationScriptLocation
|
||||
|
||||
Write-Debug "Done; Installation script location: $installationScriptLocation)"
|
||||
}
|
||||
|
||||
[void] ArchiveArtifact() {
|
||||
$OutputPath = Join-Path $this.ArtifactFolderLocation $this.OutputArtifactName
|
||||
Create-TarArchive -SourceFolder $this.WorkFolderLocation -ArchivePath $OutputPath
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue