Skip to content

Commit

Permalink
ci: fix build for openwrt package, enable setting version from env var
Browse files Browse the repository at this point in the history
Fix handling of release version (e.g. "0.11.0") in openwrt package
build. Was only working for intermediate versions, like "0.10.0-32-asdlkjslka".

Allow overwriting the version used for the builds consistently.
Previously there was an envar GIT_VERSION that could do this partially.
Renamed to SCION_VERSION and supported now also fully for the package builds.
Setting this variable in buildkite pipelines should now allow, for
example, building release builds before explicitly tagging the release.
  • Loading branch information
matzf committed May 14, 2024
1 parent 3f4629d commit 40d39ef
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build --stamp
### common options for all subcommands (help, query, build, ...)
common --show_timestamps --enable_platform_specific_config

Expand Down
10 changes: 6 additions & 4 deletions .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ rm -f $HOME/.bazelrc
# --nostamp is required for better caching (only on non-release jobs).
if [ "$BUILDKITE_PIPELINE_SLUG" == "scion" ]; then
echo "build --nostamp" > $HOME/.bazelrc
# Shorten the git version to omit commit information, improving cache reuse.
# The format of git-version is "<tag>-<number-of-commits-since-the-tag>-<commit-short-hash>"
# This will be shortened to "<tag>-modified-ci"
export GIT_VERSION=$(tools/git-version | sed 's/-.*/-modified-ci/')
if [ -z ${SCION_VERSION+x} ]; then
# Shorten the git version to omit commit information, improving cache reuse.
# The format of git-version is "<tag>-<number-of-commits-since-the-tag>-<commit-short-hash>"
# This will be shortened to "<tag>-modified-ci"
export SCION_VERSION=$(tools/git-version | sed 's/-.*/-modified-ci/')
fi
else
echo "build --stamp" > $HOME/.bazelrc
fi
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ steps:
- wait
- label: "Package :debian: :openwrt:"
command:
- version="$(tools/git-version)"
- version=${SCION_VERSION:-$(tools/git-version)}
- make dist-deb BFLAGS="--file_name_version=${version}"
- make dist-openwrt BFLAGS="--file_name_version=${version}"
- cd installables;
Expand Down
5 changes: 3 additions & 2 deletions dist/openwrt/ipk.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ def _ipk_impl(ctx):
r"scripts/feeds install -a -p scion",
r"make IB=1 defconfig", # IB=1 bypasses various unnecessary prerequisites
r"IFS='-' read tag count commit dirty < ${execroot_abspath}/$5",
r"pkgver=${tag}",
r'pkgrel=${count}${dirty:+".dirty$(date +%s)"}',
r"make package/feeds/scion/${2}/compile EXECROOT=${execroot_abspath}" +
' PKG_VERSION="${tag}" PKG_RELEASE="${pkgrel}"',
r"cp bin/packages/${6}/scion/${2}_${tag}-${pkgrel}_${6}.ipk ${execroot_abspath}/${4}",
' PKG_VERSION="${pkgver}" PKG_RELEASE="${pkgrel}"',
r"cp bin/packages/${6}/scion/${2}_${pkgver}${pkgrel:+-}${pkgrel}_${6}.ipk ${execroot_abspath}/${4}",
]),
)

Expand Down
5 changes: 2 additions & 3 deletions tools/bazel-build-env
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

ROOTDIR=$(dirname "$0")/..

# When building inside a docker container GIT_VERSION is set by the creator of the container.
# When building locally, use the version reported by git.
VERSION=${GIT_VERSION:-$($ROOTDIR/tools/git-version)}
# Use the version reported by git, unless SCION_VERSION is set to override this.
VERSION=${SCION_VERSION:-$($ROOTDIR/tools/git-version)}

echo "STABLE_GIT_VERSION $VERSION"

0 comments on commit 40d39ef

Please sign in to comment.