-
Notifications
You must be signed in to change notification settings - Fork 79
Semver2 #625
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
Semver2 #625
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
859c34b
pass semver to get_version.sh script
5e5ea47
make branch artifacts accessible as prereleases
78e9677
make flatpak build more verbose to understand version numbering
4f6128b
Pass SEMVER to flatpak build if set
9272a91
fix missing version attribute in flatpak
e1e150a
added double brackets
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
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 |
|---|---|---|
| @@ -1,19 +1,18 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Calculates the Oolite version number if not passed via env variables. | ||
| # Output goes into the OOLITE_VERSION.txt file and to stdout. | ||
| # | ||
|
|
||
| SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) | ||
| pushd "$SCRIPT_DIR" > /dev/null | ||
|
|
||
| mkdir -p ../../build | ||
| cd ../../build | ||
|
|
||
| VERSION=$(cat ../src/Cocoa/oolite-version.xcconfig | cut -d '=' -f 2) | ||
| VER_MAJ=$(echo "$VERSION" | cut -d. -f1) | ||
| VER_MIN=$(echo "$VERSION" | cut -d. -f2) | ||
| VER_REV=$(echo "$VERSION" | cut -d. -f3) | ||
| if [ "" == "$VER_REV" ]; then | ||
| VER_REV="0" | ||
| fi | ||
| # Timestamp of last commit/push | ||
| TIMESTAMP=$(git log -1 --format=%ct) | ||
|
|
||
| # Date conversions use UTC for consistency | ||
| # Convert to __DATE__ format (e.g., Feb 20 2026) | ||
| CPP_DATE=$(date -u -d "@$TIMESTAMP" +"%b %e %Y") | ||
|
|
@@ -22,14 +21,29 @@ APP_DATE=$(date -u -d "@$TIMESTAMP" +"%Y-%m-%d") | |
| # Convert to YYMMDD format (e.g., 260313) | ||
| VER_DATE=$(date -u -d "@$TIMESTAMP" +"%y%m%d") | ||
|
|
||
| VER_GITREV=$(git rev-list --count HEAD) | ||
| VER_GITHASH=$(git rev-parse --short=7 HEAD) | ||
| VER_FULL="$VER_MAJ.$VER_MIN.$VER_REV.$VER_GITREV-$VER_DATE-$VER_GITHASH" | ||
| BUILDTIME=$(date "+%Y.%m.%d %H:%M") | ||
|
|
||
| if [[ -z "${SEMVER}" ]] || [[ -z "${PROJECTNAME}" ]] | ||
| then | ||
| # Variables not passed in. Calculate the classic way. | ||
|
|
||
| VERSION=$(cat ../src/Cocoa/oolite-version.xcconfig | cut -d '=' -f 2) | ||
| VER_MAJ=$(echo "$VERSION" | cut -d. -f1) | ||
| VER_MIN=$(echo "$VERSION" | cut -d. -f2) | ||
| VER_REV=$(echo "$VERSION" | cut -d. -f3) | ||
| if [[ "" == "$VER_REV" ]]; then | ||
| VER_REV="0" | ||
| fi | ||
|
|
||
| VER_GITREV=$(git rev-list --count HEAD) | ||
| VER_GITHASH=$(git rev-parse --short=7 HEAD) | ||
| VER_FULL="$VER_MAJ.$VER_MIN.$VER_REV.$VER_GITREV-$VER_DATE-$VER_GITHASH" | ||
| BUILDTIME=$(date "+%Y.%m.%d %H:%M") | ||
| else | ||
| # Variables passed in. Make use of them. | ||
|
|
||
| VER_FULL="${SEMVER}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. simplify to "$SEMVER" |
||
| fi | ||
|
|
||
| echo "OOLITE_VERSION=$VER_FULL" > OOLITE_VERSION.txt | ||
|
|
||
| echo "$VER_FULL" | ||
|
|
||
| popd > /dev/null | ||
| popd > /dev/null | ||
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
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
Oops, something went wrong.
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.
Single Brackets (Dangerous):
if [ $name == "Bob" ]
If $name is empty, Bash sees: if [ == "Bob" ], which is a syntax error.
Double Brackets (Safe):
if [[ $name == "Bob" ]]
Even if $name is empty, Bash handles it gracefully without requiring extra quotes.
I try to stick to double brackets everywhere for consistency.