-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix local build with pbuild.sh script (#171)
This allows the pbuild.sh script to build correctly again, so that you can do local builds and get .deb packages without needing to create a PR, and without blowing away uncommitted work in your local Git repo.
- Loading branch information
Showing
4 changed files
with
133 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 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,80 @@ | ||
#!/bin/bash | ||
|
||
echo Start | ||
REV=${GITHUB_REF:-$(git rev-parse --symbolic-full-name HEAD)} | ||
DESCRIBE=$(git describe --long --match "v*") | ||
MAJOR=$(echo "$DESCRIBE" | sed -E 's/^v([0-9]+)\.([0-9]+)\.([0-9]+).*$/\1/') | ||
MINOR=$(echo "$DESCRIBE" | sed -E 's/^v([0-9]+)\.([0-9]+)\.([0-9]+).*$/\2/') | ||
PATCH=$(echo "$DESCRIBE" | sed -E 's/^v([0-9]+)\.([0-9]+)\.([0-9]+).*$/\3/') | ||
# TODO: Detect need for minor/major updates and increment those instead of PATCH | ||
COMMIT_COUNT=$(echo "$DESCRIBE" | sed -E 's/^[^-]+-([^-]+)-.*$/\1/') | ||
COMMIT_HASH=$(echo "$DESCRIBE" | sed -E 's/^[^-]+-[^-]+-g(.*)$/\1/') | ||
if [ -n "$COMMIT_COUNT" -a "$COMMIT_COUNT" -gt 0 ]; then | ||
# If we're building from a tagged version, rebuild precisely that version | ||
PATCH=$((${PATCH} + 1)) | ||
fi | ||
echo "Build number before: $BUILD_NUMBER" | ||
export BUILD_NUMBER=${BUILD_NUMBER:-${COMMIT_COUNT}} | ||
echo "Build number after: $BUILD_NUMBER" | ||
export MajorMinorPatch="${MAJOR}.${MINOR}.${PATCH}" | ||
export AssemblySemVer="${MajorMinorPatch}.${BUILD_NUMBER}" | ||
export AssemblySemFileVer="${MajorMinorPatch}.0" | ||
export InformationalVersion="${DESCRIBE}" | ||
echo "Calculating name from ${REV}" | ||
if [ -z ${REV} ]; then | ||
echo Failed to get a meaningful commit name | ||
fi | ||
echo Got commit name ${REV} | ||
RESULT=notfound | ||
if echo "${REV}" | grep -E '^refs/pull/'; then | ||
echo Found PR | ||
RESULT=$(echo "${REV}" | sed -E 's/^refs\/pull\/([0-9]+)\/merge/\1/') | ||
fi | ||
if echo "${REV}" | grep -E '^refs/heads/'; then | ||
echo Found branch | ||
RESULT=$(echo "${REV}" | sed -E 's/^refs\/heads\///') | ||
fi | ||
if echo "${REV}" | grep -E '^refs/tags/'; then | ||
echo Found tag | ||
RESULT=$(echo "${REV}" | sed -E 's/^refs\/tags\///') | ||
fi | ||
echo Will calculate version from "${RESULT}" and "${MAJOR}.${MINOR}.${PATCH} with $COMMIT_COUNT commits since then, and current hash $COMMIT_HASH" | ||
|
||
case "$REV" in | ||
refs/heads/master | refs/heads/fieldworks8-master) | ||
PRERELEASE="~alpha.${BUILD_NUMBER}" | ||
;; | ||
|
||
refs/heads/qa | refs/heads/fieldworks8-qa) | ||
PRERELEASE="~beta.${BUILD_NUMBER}" | ||
;; | ||
|
||
refs/heads/live | refs/heads/fieldworks8-live) | ||
PRERELEASE= | ||
;; | ||
|
||
refs/pull/*) | ||
PR_NUMBER=$(echo "${REV}" | sed -E 's/^refs\/pull\/([0-9]+)\/merge/\1/') | ||
PRERELEASE="~PR${PR_NUMBER}.${BUILD_NUMBER}" | ||
;; | ||
|
||
refs/heads/*) | ||
BRANCH=$(echo "${REV##refs/heads/}" | sed 's/\//-/') | ||
PRERELEASE="~${BRANCH}.${BUILD_NUMBER}" | ||
;; | ||
|
||
*) | ||
echo "Could not determine version number from ${REV}" | ||
echo "::error ::Could not determine version number from ${REV}" | ||
exit 1 | ||
|
||
esac | ||
export DebPackageVersion=${MAJOR}.${MINOR}.${PATCH}${PRERELEASE} | ||
export MsBuildVersion=$(echo "${DebPackageVersion}" | sed 's/~/-/') | ||
echo "Will build package version ${DebPackageVersion}" | ||
echo "::set-output name=DebPackageVersion::${DebPackageVersion}" | ||
echo "::set-output name=MsBuildVersion::${MsBuildVersion}" | ||
echo "::set-output name=MajorMinorPatch::${MajorMinorPatch}" | ||
echo "::set-output name=AssemblySemVer::${AssemblySemVer}" | ||
echo "::set-output name=AssemblySemFileVer::${AssemblySemFileVer}" | ||
echo "::set-output name=InformationalVersion::${InformationalVersion}" |
This file contains 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 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