Don't publish nightlies if they are unchanged since the last nightly. (#12411)
This skips publishing nightlies if the last commit that modified `packaging/version` is also the latest commit on the master branch _and_ the version listed in `packaging/version` ends in `-nightly`. If both conditions are met, then there have been no changes since the last nightly build, thus we don0t need to publish a new nightly build. This check is limited to runs that occur as part of the `schedule` trigger, to ensure that manually triggered builds can be still be done without having to worry about changes.
Austin S. Hemmelgarn committed
Mar 17, 2022 at 09:02 UTC
ef56269168a23a872d48a2ee47307482ee95cf45
1 file changed
+14
-7
.github/scripts/prepare-release-base.sh
+14
-7
@@ -102,13 +102,20 @@ elif [ "${EVENT_NAME}" = 'schedule' ] || [ "${EVENT_TYPE}" = 'nightly' ]; then
102
LAST_TAG=$(git describe --abbrev=0 --tags)
103
COMMITS_SINCE_RELEASE=$(git rev-list "${LAST_TAG}"..HEAD --count)
104
NEW_VERSION="${LAST_TAG}-$((COMMITS_SINCE_RELEASE + 1))-nightly"
105
- echo "${NEW_VERSION}" > packaging/version || exit 1
106
- echo "::set-output name=run::true"
107
- echo "::set-output name=message::Update changelog and version for nightly build: ${NEW_VERSION}."
108
- echo "::set-output name=ref::master"
109
- echo "::set-output name=type::nightly"
110
- echo "::set-output name=branch::master"
111
- echo "::set-output name=version::nightly"
105
+ LAST_VERSION_COMMIT="$(git rev-list -1 HEAD packaging/version)"
106
+ HEAD_COMMIT="$(git rev-parse HEAD)"
107
+ if [ "${EVENT_NAME}" = 'schedule' ] && [ "${LAST_VERSION_COMMIT}" = "${HEAD_COMMIT}" ] && grep -qE '.*-nightly$' packaging/version; then
108
+ echo "::notice::No commits since last nightly build, not publishing a new nightly build."
109
+ echo "::set-output name=run::false"
110
+ else
111
+ echo "${NEW_VERSION}" > packaging/version || exit 1
112
+ echo "::set-output name=run::true"
113
+ echo "::set-output name=message::Update changelog and version for nightly build: ${NEW_VERSION}."
114
+ echo "::set-output name=ref::master"
115
+ echo "::set-output name=type::nightly"
116
+ echo "::set-output name=branch::master"
117
+ echo "::set-output name=version::nightly"
118
+ fi
119
elif [ "${EVENT_TYPE}" = 'patch' ] && [ "${EVENT_VERSION}" != "nightly" ]; then
120
echo "::notice::Preparing a patch release build."
121
check_version_format || exit 1