Skip to content

Commit

Permalink
CI version fixes (#240)
Browse files Browse the repository at this point in the history
* [CI] Fix version string when no suffix.
* [CI] Show built binaries before zipping on windows
* [CI] Explicit macOS image, workaround tar issue in newer images (thanks @altendky)
  • Loading branch information
haorldbchi authored Nov 3, 2022
1 parent cdc10c3 commit 3196955
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 34 deletions.
7 changes: 7 additions & 0 deletions .github/actions/build-asset-unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ bash -eo pipefail ../embed-version.sh
cmake --build . --target bladebit --config Release -j $thread_count
chmod +x ./bladebit

if [[ $OSTYPE == 'msys'* ]] || [[ $OSTYPE == 'cygwin'* ]]; then
ls -la Release
else
ls -la
fi

# Ensure bladebit version matches expected version
bb_version="$(./bladebit --version | xargs)"

Expand All @@ -33,6 +39,7 @@ if [[ "$bb_version" != "$BB_VERSION" ]]; then
exit 1
fi

tar --version
tar -czvf $BB_ARTIFACT_NAME bladebit
mkdir ../bin
mv $BB_ARTIFACT_NAME ../bin/
Expand Down
13 changes: 8 additions & 5 deletions .github/actions/get-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ set -eo pipefail
os=$1
arch=$2

version_cmp=($(./extract-version.sh))
shift $#

ver_maj=${version_cmp[0]}
ver_min=${version_cmp[1]}
ver_rev=${version_cmp[2]}
ver_suffix=${version_cmp[3]}
# version_cmp=($(./extract-version.sh))
. ./extract-version.sh

ver_maj=$bb_ver_maj
ver_min=$bb_ver_min
ver_rev=$bb_ver_rev
ver_suffix=$bb_version_suffix

version="${ver_maj}.${ver_min}.${ver_rev}${ver_suffix}"

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ jobs:
mkdir ../bin
cd Release
ls -la
7z.exe a -tzip ../../bin/${BB_ARTIFACT_NAME} bladebit.exe
ls -la ../../bin
Expand Down Expand Up @@ -203,7 +204,7 @@ jobs:
if-no-files-found: error

build-macos-x86-64:
runs-on: macOS-latest
runs-on: macOS-11
steps:
- name: Cleanup Environment
uses: Chia-Network/actions/clean-workspace@main
Expand Down
13 changes: 7 additions & 6 deletions embed-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
set -eo pipefail
cd "$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"

version=($(./extract-version.sh))
# version=($(./extract-version.sh))
. ./extract-version.sh

ver_maj=${version[0]}
ver_min=${version[1]}
ver_rev=${version[2]}
ver_suffix=${version[3]}
git_commit=${version[4]}
ver_maj=$bb_ver_maj
ver_min=$bb_ver_min
ver_rev=$bb_ver_rev
ver_suffix=$bb_version_suffix
git_commit=$bb_git_commit

echo "Version: $ver_maj.$ver_min.$ver_rev$ver_suffix"
echo "Commit : $git_commit"
Expand Down
47 changes: 25 additions & 22 deletions extract-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,30 @@ ver_component=$1 # The user specified a specified component from the full veris
# See the case switch below.

# Grab version specified in the file
set IFS=
_IFS=IFS
IFS=
version_str=$(cat VERSION | head -n 1 | xargs)
version_suffix=$(cat VERSION | tail -n 1 | xargs)
bb_version_suffix=$(cat VERSION | tail -n 1 | xargs)
version_header='src/Version.h'
IFS=$_IFS

if [[ "$version_str" == "$version_suffix" ]]; then
version_suffix=
if [[ "$version_str" == "$bb_version_suffix" ]]; then
bb_version_suffix=
fi

ver_maj=$(printf $version_str | sed -E -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)/\1/' | xargs)
ver_min=$(printf $version_str | sed -E -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)/\2/' | xargs)
ver_rev=$(printf $version_str | sed -E -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)/\3/' | xargs)
bb_ver_maj=$(printf $version_str | sed -E -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)/\1/' | xargs)
bb_ver_min=$(printf $version_str | sed -E -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)/\2/' | xargs)
bb_ver_rev=$(printf $version_str | sed -E -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)/\3/' | xargs)

git_commit=$GITHUB_SHA
if [[ -z $git_commit ]]; then
bb_git_commit=$GITHUB_SHA
if [[ -z $bb_git_commit ]]; then
set +e
git_commit=$(git rev-parse HEAD)
bb_git_commit=$(git rev-parse HEAD)
set -e
fi

if [[ -z $git_commit ]]; then
git_commit="unknown"
if [[ -z $bb_git_commit ]]; then
bb_git_commit="unknown"
fi

# Check if the user wants a specific component
Expand All @@ -38,23 +40,23 @@ if [[ -n $ver_component ]]; then
case "$ver_component" in

"major")
echo -n $ver_maj
echo -n $bb_ver_maj
;;

"minor")
echo -n $ver_min
echo -n $bb_ver_min
;;

"revision")
echo -n $ver_rev
echo -n $bb_ver_rev
;;

"suffix")
echo -n $version_suffix
echo -n $bb_version_suffix
;;

"commit")
echo -n $git_commit
echo -n $bb_git_commit
;;

*)
Expand All @@ -66,8 +68,9 @@ if [[ -n $ver_component ]]; then
fi

# Emit all version components
echo "$ver_maj"
echo "$ver_min"
echo "$ver_rev"
echo "$version_suffix"
echo "$git_commit"
# echo "$bb_ver_maj"
# echo "$bb_ver_min"
# echo "$bb_ver_rev"
# echo "$bb_version_suffix"
# echo "$bb_git_commit"

0 comments on commit 3196955

Please sign in to comment.