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
scionproto#4523)

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".

Fix variable interpolation issue for package builds; need to use
`$${version}` to ensure interpolation of this variable at "runtime" with
bash; otherwise buildkite attempts to interpolate this when creating the
pipeline jobs. See
https://buildkite.com/docs/pipelines/environment-variables#runtime-variable-interpolation.

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 authored May 16, 2024
1 parent 3f4629d commit c1222ec
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
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
20 changes: 10 additions & 10 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ steps:
timeout_in_minutes: 10
- wait
- label: "Package :debian: :openwrt:"
command:
- version="$(tools/git-version)"
- make dist-deb BFLAGS="--file_name_version=${version}"
- make dist-openwrt BFLAGS="--file_name_version=${version}"
- cd installables;
- tar -chaf scion-deb-amd64.tar.gz *_${version}_amd64.deb
- tar -chaf scion-deb-arm64.tar.gz *_${version}_arm64.deb
- tar -chaf scion-deb-i386.tar.gz *_${version}_i386.deb
- tar -chaf scion-deb-armel.tar.gz *_${version}_armel.deb
- tar -chaf scion-openwrt-x86_64.tar.gz *_${version}_x86_64.ipk
command: |
version=${SCION_VERSION:-$(tools/git-version)}
make dist-deb BFLAGS="--file_name_version=$${version}"
make dist-openwrt BFLAGS="--file_name_version=$${version}"
cd installables;
tar -chaf scion-deb-amd64.tar.gz *_$${version}_amd64.deb
tar -chaf scion-deb-arm64.tar.gz *_$${version}_arm64.deb
tar -chaf scion-deb-i386.tar.gz *_$${version}_i386.deb
tar -chaf scion-deb-armel.tar.gz *_$${version}_armel.deb
tar -chaf scion-openwrt-x86_64.tar.gz *_$${version}_x86_64.ipk
artifact_paths:
- "installables/scion-*.tar.gz"
plugins:
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 c1222ec

Please sign in to comment.