-
Notifications
You must be signed in to change notification settings - Fork 40
changes the means to compute the version for packages #499
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
0.3.0 5fa37a13fac2749b1a6a43039ed2bee16d6cc70e | ||
0.2.0 90884c67bf6c1445f96e068c5c06904a89de2411 | ||
0.1.0 cd993a69cd5955ebfe5a9e74b37e26c1b479ddce |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright 2018 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Add a new version to the version file. The version file is a tab separated list of version numbers | ||
# and git commit hashes in reverse order (newest is at the top of the file). The version may contain | ||
# a short description as well. | ||
|
||
import argparse | ||
import datetime | ||
import os | ||
import pathlib | ||
import subprocess | ||
cmickeyb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
pdo_source_root=pathlib.Path(__file__).parent.parent | ||
version_file = pdo_source_root / 'VERSION' | ||
|
||
parser = argparse.ArgumentParser() | ||
|
||
parser.add_argument( | ||
'--version-file', '-f', | ||
help=f'File where version information is stored (default: {version_file})', | ||
type=str) | ||
|
||
parser.add_argument( | ||
'--version', '-v', | ||
help='Version to commit, form <major>.<minor>.<patch> (default: increment minor version by one and reset patch level)', | ||
type=str) | ||
|
||
parser.add_argument( | ||
'--description', '-d', | ||
help='Optional description to add to the version', | ||
type=str) | ||
|
||
parser.add_argument( | ||
'--commit', '-c', | ||
help='Hash of the git commit to associate with the version (default: commit at HEAD)', | ||
type=str) | ||
|
||
options = parser.parse_args() | ||
|
||
# Get the VERSION file and current source path | ||
if options.version_file : | ||
version_file = pathlib.Path(options.version_file) | ||
pdo_source_root = version_file.parent | ||
|
||
# Compute the new version, by default the version will increment the minor version of the most | ||
g2flyer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# recent version and reset the patch level. the version is of the form x.y.z, there may be an | ||
# optional 'v' at the beginning of the version string | ||
if options.version : | ||
version = options.version | ||
(major, minor, patch) = version.strip('v').split('.') | ||
|
||
major = int(major) | ||
minor = int(minor) | ||
patch = int(patch) | ||
|
||
else : | ||
# get the current version information from the version file | ||
with open(version_file, 'r') as vf : | ||
(version, commit, *rest) = vf.readline().strip().split('\t') | ||
|
||
(major, minor, patch) = version.strip('v').split('.') | ||
|
||
major = int(major) | ||
minor = int(minor) + 1 | ||
patch = 0 | ||
|
||
# Compute the commit to associate with the new version | ||
if options.commit : | ||
command = ['git', 'rev-parse', options.commit] | ||
else : | ||
command = ['git', 'rev-parse', 'HEAD'] | ||
|
||
output = subprocess.run(command, cwd=pdo_source_root, capture_output=True, text=True) | ||
output.check_returncode() | ||
commit = output.stdout.strip() | ||
|
||
description = str(datetime.date.today()) | ||
if options.description : | ||
description += f' {options.description}' | ||
|
||
# Finally write the new version out to the VERSION file | ||
version_entry = f'{major}.{minor}.{patch}\t{commit}\t{description}' | ||
with open(version_file, 'r+') as vf : | ||
content = vf.read() | ||
vf.seek(0,0) | ||
vf.write(version_entry + '\n' + content) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, according to our docs, 20.04 is still the default. If we change it here maybe we should change it also there? And if change, why not change straight away to the latest LTS, 24.04?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remember that this is the version only used for building the docker images. nothing else runs here. so its not actually related to our documented default version. i could go for a jump to 24.04 if that actually makes a difference. only wanted this for improved docker commands.