github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/ci/release/docker.go (about)

     1  /*
     2   * Copyright (C) 2019 The "MysteriumNetwork/node" Authors.
     3   *
     4   * This program is free software: you can redistribute it and/or modify
     5   * it under the terms of the GNU General Public License as published by
     6   * the Free Software Foundation, either version 3 of the License, or
     7   * (at your option) any later version.
     8   *
     9   * This program is distributed in the hope that it will be useful,
    10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12   * GNU General Public License for more details.
    13   *
    14   * You should have received a copy of the GNU General Public License
    15   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    16   */
    17  
    18  package release
    19  
    20  import (
    21  	"github.com/mysteriumnetwork/go-ci/env"
    22  	"github.com/mysteriumnetwork/go-ci/job"
    23  	"github.com/mysteriumnetwork/node/ci/packages"
    24  	"github.com/mysteriumnetwork/node/logconfig"
    25  )
    26  
    27  // ReleaseDockerSnapshot uploads docker snapshot images to myst snapshots repository in docker hub
    28  func ReleaseDockerSnapshot() error {
    29  	logconfig.Bootstrap()
    30  
    31  	if err := env.EnsureEnvVars(
    32  		env.SnapshotBuild,
    33  		env.BuildVersion,
    34  	); err != nil {
    35  		return err
    36  	}
    37  	job.Precondition(func() bool {
    38  		return env.Bool(env.SnapshotBuild)
    39  	})
    40  
    41  	return packages.BuildMystAlpineImage(
    42  		[]string{"mysteriumnetwork/myst-snapshots:" + env.Str(env.BuildVersion) + "-alpine", "mysteriumnetwork/myst-snapshots:latest"},
    43  		true,
    44  	)
    45  }
    46  
    47  // ReleaseDockerTag uploads docker tag release images to docker hub
    48  func ReleaseDockerTag() error {
    49  	logconfig.Bootstrap()
    50  
    51  	if err := env.EnsureEnvVars(
    52  		env.TagBuild,
    53  		env.RCBuild,
    54  		env.BuildVersion,
    55  	); err != nil {
    56  		return err
    57  	}
    58  	job.Precondition(func() bool {
    59  		return env.Bool(env.TagBuild)
    60  	})
    61  
    62  	if env.Bool(env.RCBuild) {
    63  		err := packages.BuildMystAlpineImage(
    64  			[]string{"mysteriumnetwork/myst:" + env.Str(env.BuildVersion) + "-alpine"},
    65  			true,
    66  		)
    67  		if err != nil {
    68  			return err
    69  		}
    70  
    71  		err = packages.BuildMystDocumentationImage(
    72  			[]string{"mysteriumnetwork/documentation:" + env.Str(env.BuildVersion)},
    73  			true,
    74  		)
    75  		if err != nil {
    76  			return err
    77  		}
    78  	} else {
    79  		err := packages.BuildMystAlpineImage(
    80  			[]string{
    81  				"mysteriumnetwork/myst:" + env.Str(env.BuildVersion) + "-alpine",
    82  				"mysteriumnetwork/myst:latest-alpine",
    83  				"mysteriumnetwork/myst:latest",
    84  			},
    85  			true,
    86  		)
    87  		if err != nil {
    88  			return err
    89  		}
    90  
    91  		err = packages.BuildMystDocumentationImage(
    92  			[]string{
    93  				"mysteriumnetwork/documentation:" + env.Str(env.BuildVersion),
    94  				"mysteriumnetwork/documentation:latest",
    95  			},
    96  			true,
    97  		)
    98  		if err != nil {
    99  			return err
   100  		}
   101  	}
   102  	return nil
   103  }