diff --git a/buildjob b/buildjob
index acc68685b6dd968c328cc1de708462cd533313d3..9ef459e0884166abdb7f6c98c53a861787e52091 100755
--- a/buildjob
+++ b/buildjob
@@ -3,10 +3,12 @@ set -e
 #set -x
 
 ## This runs a default build job.  The following variables are noteworthy:
-## - $OPAM_PINS:  Space-separated list of packages to pin in opam, in the format
+## - $MAIN_BRANCH: The "main branch" this current branch comes from (usually
+##   master)
+## - $OPAM_PINS: Space-separated list of packages to pin in opam, in the format
 ##   "PACKAGE KIND TARGET   PACKAGE KIND TARGET   ..."
 ## - $VALIDATE: If non-empty, run `make validate`
-## - $OPAM_UPDATE_SECRET, $OPAM_PKG, $OPAM_PKG_BRANCH: IF $OPAM_PKG is
+## - $OPAM_UPDATE_SECRET, $OPAM_PKG: IF $OPAM_PKG is
 ##   non-empty, release this commit as a new package on opam when done.
 ##   Requires the $OPAM_UPDATE_SECRET variable to be set.  This only happens if
 ##   the current branch is $OPAM_PKG_BRANCH, or master if that variable is
@@ -31,10 +33,7 @@ if [[ -n "$VALIDATE" ]]; then
 fi
 
 # maybe create opam package
-if [[ -z "$OPAM_PKG_BRANCH" ]]; then
-    OPAM_PKG_BRANCH=master
-fi
-if [[ -n "$OPAM_PKG" && "$CI_COMMIT_REF_NAME" == "$OPAM_PKG_BRANCH" ]]; then
+if [[ -n "$OPAM_PKG" && "$CI_COMMIT_REF_NAME" == "$MAIN_BRANCH" ]]; then
     echo_color "$BOLDGREEN" "[buildjob] Releasing package on opam"
     # determine package name prefix
     if [[ "$CI_COMMIT_REF_NAME" == master ]]; then