File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,12 @@ publishPackage() {
38
38
commitAuthorEmail=$( git --no-pager show -s --format=' %ae' HEAD)
39
39
commitMessage=$( git log --oneline -n 1)
40
40
41
- buildVersionName=" ${buildVersion} -${commitSha} "
41
+ # Note that we cannot store the commit SHA in its own version segment
42
+ # as it will not comply with the semver specification. For example:
43
+ # 1.0.0-00abcdef will break since the SHA starts with zeros. To fix this,
44
+ # we create a new version segment with the following format: "1.0.0-sha-00abcdef".
45
+ # See issue: https://jubianchi.github.io/semver-check/#/^8.0.0/8.2.2-0462599
46
+ buildVersionName=" ${buildVersion} -sha-${commitSha} "
42
47
buildTagName=" ${branchName} -${commitSha} "
43
48
buildCommitMessage=" ${branchName} - ${commitMessage} "
44
49
@@ -89,7 +94,7 @@ publishPackage() {
89
94
90
95
# Replace the version in every file recursively with a more specific version that also includes
91
96
# the SHA of the current build job. Normally this "sed" call would just replace the version
92
- # placeholder, but the version placeholders have been replaced by the release task already.
97
+ # placeholder, but the version placeholders have been replaced by "npm_package" already.
93
98
sed -i " s/${buildVersion} /${buildVersionName} /g" $( find . -type f -not -path ' *\/.*' )
94
99
95
100
echo " Updated the build version in every file to include the SHA of the latest commit."
Original file line number Diff line number Diff line change @@ -42,7 +42,12 @@ commitAuthorEmail=$(git --no-pager show -s --format='%ae' HEAD)
42
42
commitMessage=$( git log --oneline -n 1)
43
43
commitTag=" ${buildVersion} -${commitSha} "
44
44
45
- buildVersionName=" ${buildVersion} -${commitSha} "
45
+ # Note that we cannot store the commit SHA in its own version segment
46
+ # as it will not comply with the semver specification. For example:
47
+ # 1.0.0-00abcdef will break since the SHA starts with zeros. To fix this,
48
+ # we create a new version segment with the following format: "1.0.0-sha-00abcdef".
49
+ # See issue: https://jubianchi.github.io/semver-check/#/^8.0.0/8.2.2-0462599
50
+ buildVersionName=" ${buildVersion} -sha-${commitSha} "
46
51
buildTagName=" ${branchName} -${commitSha} "
47
52
buildCommitMessage=" ${branchName} - ${commitMessage} "
48
53
@@ -86,6 +91,11 @@ if [[ $(git ls-remote origin "refs/tags/${buildTagName}") ]]; then
86
91
exit 0
87
92
fi
88
93
94
+ # Replace the version in every file recursively with a more specific version that also includes
95
+ # the SHA of the current build job. Normally this "sed" call would just replace the version
96
+ # placeholder, but the version placeholders have been replaced by "npm_package" already.
97
+ sed -i " s/${buildVersion} /${buildVersionName} /g" $( find . -type f -not -path ' *\/.*' )
98
+
89
99
# Setup the Git configuration
90
100
git config user.name " $commitAuthorName "
91
101
git config user.email " $commitAuthorEmail "
You can’t perform that action at this time.
0 commit comments