mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
* Rejig the build process During a build, we check and rebuild any dependencies prior to potentially using them. Build: - DIND (this only produces a new docker image, no local code changes) - fnserver (built as part of the testing) On master, if everything works, then we release the built artifacts, if necessary: - DIND (this pushes a docker image and a tag) - fnserver (this builds the docker image and releases it, if necessary). Fnserver is dealt with last by the release script: all previous steps in CI use locally-run go tests rather than a docker file. When a commit happens, we need to know (a) if we need to rebuild a set of tools and artifacts (or whether we can continue to use published ones); and (b) if we need to release new versions of those tools, if all tests pass. We do this by identifying the previous release tag on origin/master (which is the release branch), then checking for changes between that point at the current one. Those changes may appear in various places in the tree: some simple boolean rules work out whether the change means we need to rebuild and rerelease. * Make the fnproject/fnserver build use the latest dind As docker bumps from 17.12.x, use whatever dind we just built. * Use bash
44 lines
1.6 KiB
Bash
Executable File
44 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
# Has a subset of the tree changed since the last tag of a particular kind?
|
|
# (If so, we'll need to rebuild and re-release, assuming the tests pass.)
|
|
|
|
RELEASE_BRANCH=origin/master
|
|
FIRST_COMMIT="$(git rev-list "$RELEASE_BRANCH" | tail -1)"
|
|
|
|
FN_TAG="$(git tag --merged "$RELEASE_BRANCH" --sort='v:refname' '[0-9]*' | tail -1)"
|
|
FN_PREV="$FN_TAG"
|
|
[[ -z "$FN_TAG" ]] && FN_TAG="$FIRST_COMMIT"
|
|
[[ -z "$FN_PREV" ]] && FN_PREV=0.0.0
|
|
|
|
DIND_TAG="$(git tag --merged "$RELEASE_BRANCH" --sort='v:refname' 'dind-*' | tail -1)"
|
|
DIND_PREV="$DIND_TAG"
|
|
[[ -z "$DIND_TAG" ]] && DIND_TAG="$FIRST_COMMIT"
|
|
[[ -z "$DIND_PREV" ]] && DIND_PREV=dind-0.0.0
|
|
|
|
# Which pieces of the tree are changed since to each tag?
|
|
# We are only interested in parts of the tree corresponding to each tag's aegis
|
|
# We are *not* interested in solely-DIND changes if we're considering a release of fnserver
|
|
|
|
# DIND bumps only if there are changes under images/dind.
|
|
[[ -n "$(git diff --dirstat=files,0,cumulative "$DIND_TAG" | awk '$2 ~ /^(images\/dind)\/$/')" ]] && DIND_NEEDED=yes
|
|
|
|
# FN bumps only if there are changes *other* than images/dind/
|
|
[[ -n "$(git diff --dirstat=files,0,cumulative "$FN_TAG" | awk '$2 !~ /^(images\/dind)\/$/')" ]] && FN_NEEDED=yes
|
|
|
|
# Finally, some of these pieces are used as build tools for later ones.
|
|
[[ -n "$DIND_NEEDED" && -z "$FN_NEEDED" ]] && FN_NEEDED=dep
|
|
|
|
cat <<-EOF
|
|
# Change summary: "dep" means a rebuild required due to a dependency change
|
|
DIND_NEEDED=$DIND_NEEDED
|
|
DIND_TAG="$DIND_TAG"
|
|
DIND_PREV="$DIND_PREV"
|
|
|
|
FN_NEEDED=$FN_NEEDED
|
|
FN_TAG="$FN_TAG"
|
|
FN_PREV="$FN_PREV"
|
|
EOF
|