@@ -12,7 +12,9 @@ import (
1212 "net/http"
1313 "os"
1414 "os/exec"
15+ "strconv"
1516 "strings"
17+ "time"
1618
1719 "github.com/google/go-github/v71/github"
1820 "github.com/oracle/oci-go-sdk/v65/core"
@@ -52,7 +54,7 @@ func main() {
5254func run (cmd * cobra.Command , argv []string ) error {
5355 filepath := "images/ubuntu/templates/"
5456 sourceFile := fmt .Sprintf ("%s%s-%s.pkr.hcl" , filepath , args .os , args .osVersion )
55- imageFile := fmt .Sprintf ("build/%s-%s/ image.raw" , args . os , args . osVersion )
57+ imageFile := fmt .Sprintf ("build/image.raw" )
5658 filename := ""
5759 imageName := fmt .Sprintf ("%s-%s-%s-gha-image" , args .os , args .osVersion , args .arch )
5860
@@ -123,15 +125,17 @@ func run(cmd *cobra.Command, argv []string) error {
123125 }
124126 log .Printf ("Packer build completed successfully.\n " )
125127
126- command = exec .Command ("oci" , "os" , "object" , "put" , "--parallel-upload-count" , "100" , "--bucket-name" , args .bucketName , "--name" , "ubuntu-gha-image" , "--file" , imageFile )
128+ timestamp := strconv .FormatInt (time .Now ().UTC ().UnixNano (), 10 )
129+
130+ command = exec .Command ("oci" , "os" , "object" , "put" , "--parallel-upload-count" , "100" , "--bucket-name" , args .bucketName , "--name" , fmt .Sprintf ("ubuntu-gha-image-%s" , timestamp ), "--file" , imageFile )
127131
128132 command .Stdout = os .Stdout
129133 if err := command .Run (); err != nil {
130134 log .Print (command .String ())
131135 log .Fatal ("could not run command: " , err )
132136 }
133137
134- command = exec .Command ("oci" , "compute" , "image" , "import" , "from-object" , "--bucket-name" , args .bucketName , "--compartment-id" , args .compartmentId , "--namespace" , args .namespace , "--operating-system" , imageName , "--display-name" , imageName , "--name" , imageName , "--operating-system-version" , * selectedRelease .TagName )
138+ command = exec .Command ("oci" , "compute" , "image" , "import" , "from-object" , "--bucket-name" , args .bucketName , "--compartment-id" , args .compartmentId , "--namespace" , args .namespace , "--operating-system" , imageName , "--display-name" , imageName , "--name" , fmt . Sprintf ( "ubuntu-gha-image-%s" , timestamp ) , "--operating-system-version" , * selectedRelease .TagName )
135139 command .Stdout = os .Stdout
136140 if err := command .Run (); err != nil {
137141 log .Print (command .String ())
@@ -346,7 +350,7 @@ source "qemu" "img" {
346350 iso_url = "%s"
347351 iso_checksum = "%s"
348352 memory = 12000
349- cpus = 3
353+ cpus = 6
350354 output_directory = "build/"
351355 accelerator = "kvm"
352356 disk_size = "80G"
@@ -358,6 +362,7 @@ source "qemu" "img" {
358362 ssh_username = "ubuntu"
359363 ssh_password = "ubuntu"
360364 ssh_timeout = "60m"
365+ headless = true
361366}` , args .isoURL , args .isoChecksum )
362367
363368 replacements [`sources = ["source.azure-arm.build_image"]` ] = `sources = ["source.azure-arm.build_image", "source.qemu.img"]
0 commit comments