github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/ci/release/debian.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 "strings" 22 23 "github.com/mysteriumnetwork/go-ci/env" 24 "github.com/mysteriumnetwork/go-ci/job" 25 "github.com/mysteriumnetwork/go-ci/shell" 26 "github.com/mysteriumnetwork/node/ci/deb" 27 "github.com/mysteriumnetwork/node/logconfig" 28 ) 29 30 type releaseDebianOpts struct { 31 repository string 32 version string 33 buildNumber string 34 } 35 36 func releaseDebianPPA(opts *releaseDebianOpts) error { 37 if err := deb.TermsTemplateFile("debian/templates"); err != nil { 38 return err 39 } 40 41 for _, codename := range []string{"bionic", "focal", "jammy"} { 42 err := shell.NewCmdf("bin/release_ppa %s %s %s %s", opts.repository, opts.version, opts.buildNumber, codename).Run() 43 if err != nil { 44 return err 45 } 46 } 47 return nil 48 } 49 50 func ppaVersion(buildVersion string) string { 51 // Using e.g. 0.10.0-rc makes it >= than actual release 0.10.0 52 // W: myst source: rc-version-greater-than-expected-version 0.10.0+rc2+build71088039+bionic > 0.10.0 53 // (consider using 0.10.0~rc2+build71088039+bionic) 54 ver := strings.Replace(buildVersion, "-rc", "~rc", -1) 55 // Using ~rc makes it >= ~rc2, so always use a number suffix, starting from rc1 56 if strings.HasSuffix(ver, "~rc") { 57 ver = strings.Replace(ver, "~rc", "~rc1", -1) 58 } 59 // PPA treats minus as previous version 60 ver = strings.Replace(ver, "-", "+", -1) 61 return ver 62 } 63 64 // ReleaseDebianPPASnapshot releases to node-dev PPA 65 func ReleaseDebianPPASnapshot() error { 66 logconfig.Bootstrap() 67 68 if err := env.EnsureEnvVars( 69 env.SnapshotBuild, 70 env.BuildVersion, 71 env.BuildNumber, 72 ); err != nil { 73 return err 74 } 75 job.Precondition(func() bool { 76 return env.Bool(env.SnapshotBuild) 77 }) 78 79 return releaseDebianPPA(&releaseDebianOpts{ 80 repository: "node-dev", 81 version: ppaVersion(env.Str(env.BuildVersion)), 82 buildNumber: env.Str(env.BuildNumber), 83 }) 84 } 85 86 // ReleaseDebianPPAPreRelease releases to node-pre PPA (which is then manually promoted to node PPA) 87 func ReleaseDebianPPAPreRelease() error { 88 logconfig.Bootstrap() 89 90 if err := env.EnsureEnvVars( 91 env.TagBuild, 92 env.RCBuild, 93 env.BuildVersion, 94 env.BuildNumber, 95 ); err != nil { 96 return err 97 } 98 job.Precondition(func() bool { 99 return env.Bool(env.TagBuild) && !env.Bool(env.RCBuild) 100 }) 101 102 return releaseDebianPPA(&releaseDebianOpts{ 103 repository: "node-pre", 104 version: ppaVersion(env.Str(env.BuildVersion)), 105 buildNumber: env.Str(env.BuildNumber), 106 }) 107 }