Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
5ac539ab
Commit
5ac539ab
authored
Oct 09, 2015
by
Isaac Hollander McCreery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement branched/versioned ci publishing to GCS.
parent
3a823ed3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
135 additions
and
12 deletions
+135
-12
common.sh
build/common.sh
+126
-6
mark-new-version.sh
build/mark-new-version.sh
+9
-6
No files found.
build/common.sh
View file @
5ac539ab
...
...
@@ -360,6 +360,32 @@ function kube::release::parse_and_validate_release_version() {
}
}
# Validate a ci version
#
# Globals:
# None
# Arguments:
# version
# Returns:
# If version is a valid ci version
# Sets:
# BASH_REMATCH, so you can do something like:
# local -r version_major="${BASH_REMATCH[1]}"
# local -r version_minor="${BASH_REMATCH[2]}"
# local -r version_patch="${BASH_REMATCH[3]}"
# local -r version_prerelease="${BASH_REMATCH[4]}"
# local -r version_alpha_rev="${BASH_REMATCH[5]}"
# local -r version_build_info="${BASH_REMATCH[6]}"
# local -r version_commits="${BASH_REMATCH[7]}"
function
kube::release::parse_and_validate_ci_version
()
{
# Accept things like "v1.2.3-alpha.0.456+abcd789-dirty" or "v1.2.3-beta.456"
local
-r
version_regex
=
"^v(0|[1-9][0-9]*)
\\
.(0|[1-9][0-9]*)
\\
.(0|[1-9][0-9]*)-(beta|alpha
\\
.(0|[1-9][0-9]*))(
\\
.(0|[1-9][0-9]*)
\\
+[-0-9a-z]*)?$"
local
-r
version
=
"
${
1
-
}
"
[[
"
${
version
}
"
=
~
${
version_regex
}
]]
||
{
kube::log::error
"Invalid ci version: '
${
version
}
'"
return
1
}
}
# ---------------------------------------------------------------------------
# Building
...
...
@@ -1039,7 +1065,19 @@ function kube::release::gcs::copy_release_artifacts() {
# Success
function
kube::release::gcs::publish_ci
()
{
kube::release::gcs::verify_release_files
||
return
1
kube::release::gcs::publish
'ci/latest.txt'
||
return
1
kube::release::parse_and_validate_ci_version
"
${
KUBE_GCS_PUBLISH_VERSION
}
"
||
return
1
local
-r
version_major
=
"
${
BASH_REMATCH
[1]
}
"
local
-r
version_minor
=
"
${
BASH_REMATCH
[2]
}
"
local
-r
publish_files
=(
ci/latest.txt ci/latest-
${
version_major
}
.txt ci/latest-
${
version_major
}
.
${
version_minor
}
.txt
)
for
publish_file
in
${
publish_files
[*]
}
;
do
# If there's a version that's above the one we're trying to release, don't
# do anything, and just try the next one.
kube::release::gcs::verify_ci_ge
"
${
publish_file
}
"
||
continue
kube::release::gcs::publish
"
${
publish_file
}
"
||
return
1
done
}
# Publish a new official version, (latest or stable,) but only if the release
...
...
@@ -1130,15 +1168,15 @@ function kube::release::gcs::verify_release_gt() {
local
-r
gcs_version_patch
=
"
${
BASH_REMATCH
[3]
}
"
local
greater
=
true
if
[[
"
${
gcs_version_major
}
"
-gt
"
${
version_major
}
"
]]
;
then
if
[[
"
${
version_major
}
"
-lt
"
${
gcs_
version_major
}
"
]]
;
then
greater
=
false
elif
[[
"
${
gcs_version_major
}
"
-lt
"
${
version_major
}
"
]]
;
then
elif
[[
"
${
version_major
}
"
-gt
"
${
gcs_
version_major
}
"
]]
;
then
:
# fall out
elif
[[
"
${
gcs_version_minor
}
"
-gt
"
${
version_minor
}
"
]]
;
then
elif
[[
"
${
version_minor
}
"
-lt
"
${
gcs_
version_minor
}
"
]]
;
then
greater
=
false
elif
[[
"
${
gcs_version_minor
}
"
-lt
"
${
version_minor
}
"
]]
;
then
elif
[[
"
${
version_minor
}
"
-gt
"
${
gcs_
version_minor
}
"
]]
;
then
:
# fall out
elif
[[
"
${
gcs_version_patch
}
"
-ge
"
${
version_patch
}
"
]]
;
then
elif
[[
"
${
version_patch
}
"
-le
"
${
gcs_
version_patch
}
"
]]
;
then
greater
=
false
fi
...
...
@@ -1154,6 +1192,88 @@ function kube::release::gcs::verify_release_gt() {
fi
}
# Check if the new version is greater than or equal to the version currently
# published on GCS. (Ignore the build; if it's different, overwrite anyway.)
#
# Globals:
# KUBE_GCS_PUBLISH_VERSION
# KUBE_GCS_RELEASE_BUCKET
# Arguments:
# publish_file: the GCS location to look in
# Returns:
# If new version is greater than the GCS version
function
kube::release::gcs::verify_ci_ge
()
{
local
-r
publish_file
=
"
${
1
-
}
"
local
-r
new_version
=
${
KUBE_GCS_PUBLISH_VERSION
}
local
-r
publish_file_dst
=
"gs://
${
KUBE_GCS_RELEASE_BUCKET
}
/
${
publish_file
}
"
kube::release::parse_and_validate_ci_version
"
${
new_version
}
"
||
return
1
local
-r
version_major
=
"
${
BASH_REMATCH
[1]
}
"
local
-r
version_minor
=
"
${
BASH_REMATCH
[2]
}
"
local
-r
version_patch
=
"
${
BASH_REMATCH
[3]
}
"
local
-r
version_prerelease
=
"
${
BASH_REMATCH
[4]
}
"
local
-r
version_alpha_rev
=
"
${
BASH_REMATCH
[5]
}
"
local
-r
version_commits
=
"
${
BASH_REMATCH
[7]
}
"
local
gcs_version
if
gcs_version
=
"
$(
gsutil
cat
"
${
publish_file_dst
}
"
)
"
;
then
kube::release::parse_and_validate_ci_version
"
${
gcs_version
}
"
||
{
kube::log::error
"
${
publish_file_dst
}
contains invalid ci version, can't compare: '
${
gcs_version
}
'"
return
1
}
local
-r
gcs_version_major
=
"
${
BASH_REMATCH
[1]
}
"
local
-r
gcs_version_minor
=
"
${
BASH_REMATCH
[2]
}
"
local
-r
gcs_version_patch
=
"
${
BASH_REMATCH
[3]
}
"
local
-r
gcs_version_prerelease
=
"
${
BASH_REMATCH
[4]
}
"
local
-r
gcs_version_alpha_rev
=
"
${
BASH_REMATCH
[5]
}
"
local
-r
gcs_version_commits
=
"
${
BASH_REMATCH
[7]
}
"
local
greater
=
true
if
[[
"
${
version_major
}
"
-lt
"
${
gcs_version_major
}
"
]]
;
then
greater
=
false
elif
[[
"
${
version_major
}
"
-gt
"
${
gcs_version_major
}
"
]]
;
then
:
# fall out
elif
[[
"
${
version_minor
}
"
-lt
"
${
gcs_version_minor
}
"
]]
;
then
greater
=
false
elif
[[
"
${
version_minor
}
"
-gt
"
${
gcs_version_minor
}
"
]]
;
then
:
# fall out
elif
[[
"
${
version_patch
}
"
-lt
"
${
gcs_version_patch
}
"
]]
;
then
greater
=
false
elif
[[
"
${
version_patch
}
"
-gt
"
${
gcs_version_patch
}
"
]]
;
then
:
# fall out
elif
[[
"
${
version_prerelease
}
"
=
~ alpha.
*
&&
"
${
gcs_version_prerelease
}
"
==
"beta"
]]
;
then
greater
=
false
elif
[[
"
${
version_prerelease
}
"
==
"beta"
&&
"
${
gcs_version_prerelease
}
"
=
~ alpha.
*
]]
;
then
:
# fall out
# Check the alpha revision; if they are both beta, this is just comparing empty strings.
elif
[[
"
${
version_alpha_rev
}
"
-lt
"
${
gcs_version_alpha_rev
}
"
]]
;
then
greater
=
false
elif
[[
"
${
version_alpha_rev
}
"
-gt
"
${
gcs_version_alpha_rev
}
"
]]
;
then
:
# fall out
elif
[[
"
${
version_patch
}
"
-lt
"
${
gcs_version_patch
}
"
]]
;
then
greater
=
false
elif
[[
"
${
version_patch
}
"
-gt
"
${
gcs_version_patch
}
"
]]
;
then
:
# fall out
# If either version_commits is empty, it will be considered less-than, as
# expected, (e.g. 1.2.3-beta < 1.2.3-beta.1).
elif
[[
"
${
version_commits
}
"
-lt
"
${
gcs_version_commits
}
"
]]
;
then
greater
=
false
fi
if
[[
"
${
greater
}
"
!=
"true"
]]
;
then
kube::log::status
"
${
new_version
}
(just uploaded) <
${
gcs_version
}
(latest on GCS), not updating
${
publish_file_dst
}
"
return
1
else
kube::log::status
"
${
new_version
}
(just uploaded) >=
${
gcs_version
}
(latest on GCS), updating
${
publish_file_dst
}
"
fi
else
# gsutil cat failed; file does not exist
kube::log::error
"File '
${
publish_file_dst
}
' does not exist. Continuing."
return
0
fi
}
# Publish a release to GCS: upload a version file, if KUBE_GCS_MAKE_PUBLIC,
# make it public, and verify the result.
#
...
...
build/mark-new-version.sh
View file @
5ac539ab
...
...
@@ -110,28 +110,31 @@ gofmt -s -w "${VERSION_FILE}"
echo
"+++ Committing version change"
git add
"
${
VERSION_FILE
}
"
git commit
-m
"Kubernetes version
$
NEW_VERSION
"
git commit
-m
"Kubernetes version
$
{
NEW_VERSION
}
"
echo
"+++ Tagging version"
git tag
-a
-m
"Kubernetes version
$
NEW_VERSION
"
"
${
NEW_VERSION
}
"
git tag
-a
-m
"Kubernetes version
$
{
NEW_VERSION
}
"
"
${
NEW_VERSION
}
"
# We have to sleep for a bit so that the timestamp of the beta tag is after the
# timestamp of the release version, so that future commits are described as
# beta, and not release versions.
echo
"+++ Waiting for 5 seconds to ensure timestamps are different before continuing"
sleep
5
echo
"+++ Tagging beta tag"
declare
-r
beta_ver
=
"v
${
VERSION_MAJOR
}
.
${
VERSION_MINOR
}
.
$((${
VERSION_PATCH
}
+
1
))
-beta"
git tag
-a
-m
"Kubernetes version
$
beta_ver
"
"
${
beta_ver
}
"
git tag
-a
-m
"Kubernetes version
$
{
beta_ver
}
"
"
${
beta_ver
}
"
newtag
=
$(
git rev-parse
--short
HEAD
)
if
[[
"
${
VERSION_PATCH
}
"
==
"0"
]]
;
then
declare
-r
alpha_ver
=
"v
${
VERSION_MAJOR
}
.
$((${
VERSION_MINOR
}
+
1
))
.0-alpha.0"
git tag
-a
-m
"Kubernetes pre-release branch
${
alpha
-
ver
}
"
"
${
alpha_ver
}
"
"
${
head_commit
}
"
git tag
-a
-m
"Kubernetes pre-release branch
${
alpha
_
ver
}
"
"
${
alpha_ver
}
"
"
${
head_commit
}
"
fi
echo
""
echo
"Success you must now:"
echo
""
echo
"- Push the tag:"
echo
" git push
${
push_url
}
v
${
VERSION_MAJOR
}
.
${
VERSION_MINOR
}
.
${
VERSION_PATCH
}
"
echo
"- Push the tags:"
echo
" git push
${
push_url
}
${
NEW_VERSION
}
"
echo
" git push
${
push_url
}
${
beta_ver
}
"
if
[[
"
${
VERSION_PATCH
}
"
==
"0"
]]
;
then
echo
"- Push the alpha tag:"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment