Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag repo with Go compatible version names #100

Merged
merged 5 commits into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.13

require (
cloud.google.com/go v0.34.0
github.com/Masterminds/semver/v3 v3.0.3
github.com/ghodss/yaml v1.0.0
github.com/google/go-github/v28 v28.0.1
github.com/google/martian v2.1.0+incompatible // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ cloud.google.com/go v0.34.0 h1:eOI3/cP2VTU6uZLDYAoic+eyzzB9YyGmJ7eIjl8rOPg=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Masterminds/semver/v3 v3.0.3 h1:znjIyLfpXEDQjOIEWh+ehwpTU14UzUPub3c3sm36u14=
github.com/Masterminds/semver/v3 v3.0.3/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
Expand Down
19 changes: 19 additions & 0 deletions licenses/github.com/Masterminds/semver/v3/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (C) 2014-2019, Matt Butcher and Matt Farina

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2 changes: 2 additions & 0 deletions pkg/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ type Dependency struct {
// Auto will fetch the SHA to use based on other repos. Currently this supports reading
// istio.deps from istio/istio only.
Auto string `json:"auto,omitempty"`
// If true, go version semantic will be used for tagging the git repo, e.g. v1.2.3.
GoVersionEnabled bool `json:"goversionenabled,omitempty"`
}

// Ref returns the git reference of a dependency.
Expand Down
15 changes: 13 additions & 2 deletions pkg/publish/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ import (
"os"
"path"
"regexp"
"strings"

"istio.io/pkg/log"
"istio.io/release-builder/pkg/model"
"istio.io/release-builder/pkg/util"

semver "github.com/Masterminds/semver/v3"
"github.com/google/go-github/v28/github"
"golang.org/x/oauth2"
)
Expand All @@ -51,7 +53,7 @@ func Github(manifest model.Manifest, githubOrg string, githubToken string) error
continue
}
// Do not use dep.Org, as the source org is not necessarily the same as the publishing org
if err := GithubTag(client, githubOrg, repo, manifest.Version, dep.Sha); err != nil {
if err := GithubTag(client, githubOrg, repo, manifest.Version, dep.GoVersionEnabled, dep.Sha); err != nil {
return fmt.Errorf("failed to tag repo %v: %v", repo, err)
}
}
Expand Down Expand Up @@ -119,9 +121,18 @@ func GithubUploadReleaseAssets(ctx context.Context, manifest model.Manifest, cli
}

// GithubTag tags a given repo with a version
func GithubTag(client *github.Client, org string, repo string, version string, sha string) error {
func GithubTag(client *github.Client, org string, repo string, version string, goVersionEnabled bool, sha string) error {
ctx := context.Background()

// append `v` in front of the Istio version number to comply with
// Go module versioning convention.
if goVersionEnabled && !strings.HasPrefix(version, "v") {
if _, err := semver.StrictNewVersion(version); err != nil {
return fmt.Errorf("cannot tag %v with invalid semantic version %v: %v", repo, version, err)
}
version = fmt.Sprintf("v%s", version)
}

// First, create a tag
msg := fmt.Sprintf("Istio release %s", version)
tagType := "commit"
Expand Down
1 change: 1 addition & 0 deletions release/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ ${DEPENDENCIES:-$(cat <<EOD
client-go:
git: https://github.com/istio/client-go
branch: release-1.4
goversionenabled: true
gogo-genproto:
git: https://github.com/istio/gogo-genproto
branch: release-1.4
Expand Down
3 changes: 2 additions & 1 deletion test/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fi

DOCKER_HUB=${DOCKER_HUB:-gcr.io/istio-testing}
GCS_BUCKET=${GCS_BUCKET:-istio-build/test}
VERSION="release-builder-$(git rev-parse --short HEAD)"
VERSION="0.0.1-releasebuilder.$(git rev-parse --short HEAD)"

WORK_DIR="$(mktemp -d)/build"
mkdir -p "${WORK_DIR}"
Expand Down Expand Up @@ -60,6 +60,7 @@ dependencies:
client-go:
git: https://github.com/istio/client-go
branch: master
goversionenabled: true
gogo-genproto:
git: https://github.com/istio/gogo-genproto
branch: master
Expand Down