Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP #16339

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

WIP #16339

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions buildkite/scripts/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

set -eo pipefail

source "./buildkite/scripts/export-git-env-vars.sh"

([ -z ${DUNE_PROFILE+x} ] || [ -z ${MINA_DEB_CODENAME+x} ]) && echo "required env vars were not provided" && exit 1

source ~/.profile

echo "--- Bundle all packages for Debian ${MINA_DEB_CODENAME}"
./buildkite/scripts/build-artifact.sh

echo "--- Bundle all packages for Debian ${MINA_DEB_CODENAME}"
echo " Includes mina daemon, archive-node, rosetta, generate keypair for devnet"
[[ ${MINA_BUILD_MAINNET} ]] && echo " MINA_BUILD_MAINNET is true so this includes the mainnet and devnet packages for mina-daemon as well"


echo "--- Prepare debian packages"
BRANCH_NAME="$BUILDKITE_BRANCH" ./scripts/debian/build.sh $@
./scripts/debian/build.sh $@

echo "--- Git diff after build is complete:"
git diff --exit-code -- .
65 changes: 7 additions & 58 deletions buildkite/scripts/export-git-env-vars.sh
Original file line number Diff line number Diff line change
@@ -1,65 +1,14 @@
#!/bin/bash

echo "Exporting Variables: "
# This script should be never run outside buildkite agent

export MINA_REPO="https://github.com/MinaProtocol/mina.git"
source ./scripts/export-git-env-vars.sh

function find_most_recent_numeric_tag() {
# We use the --prune flag because we've had problems with buildkite agents getting conflicting results here
git fetch --tags --prune --prune-tags --force
TAG=$(git describe --always --abbrev=0 $1 | sed 's!/!-!g; s!_!-!g; s!#!-!g')
if [[ $TAG != [0-9]* ]]; then
TAG=$(find_most_recent_numeric_tag $TAG~)
fi
echo $TAG
}
# Always prefer buildkite branch even if ./scripts/export-git-env-vars.sh
# calculate GITBRANCH on its own
export GITBRANCH=$BUILDKITE_BRANCH

export GITHASH=$(git rev-parse --short=7 HEAD)

export THIS_COMMIT_TAG=$(git tag --points-at HEAD)
export PROJECT="mina"

set +u
export BUILD_NUM=${BUILDKITE_BUILD_NUM}
export BUILD_NUM=${BUILDKITE_BUILD_NUMBER}
export BUILD_URL=${BUILDKITE_BUILD_URL}
set -u

export MINA_DEB_CODENAME=${MINA_DEB_CODENAME:=bullseye}
if [[ -n "$BUILDKITE_BRANCH" ]]; then
export GITBRANCH=$(echo "$BUILDKITE_BRANCH" | sed 's!/!-!g; s!_!-!g; s!#!-!g')
else
export GITBRANCH=$(git name-rev --name-only $GITHASH | sed "s/remotes\/origin\///g" | sed 's!/!-!g; s!_!-!g; s!#!-!g' )
fi



export RELEASE=unstable

if [ "${BUILDKITE_REPO}" != "${MINA_REPO}" ]; then
# Abort if `BUILDKITE_REPO` doesn't have the expected format
echo ${BUILDKITE_REPO} | grep -P '^.*github.com[:\/](.*)\.git$' > /dev/null || \
(echo "BUILDKITE_REPO does not have the expected format" && false)

# We don't want to allow some operations on fork repository which should be done on main repo only.
# Publish to docker hub or publish to unstable debian channel should be exclusive to main repo as it can override
# packages from main repo (by using the same commit and the same branch from forked repository)

# We don't want to use tags (as this can replace our dockers/debian packages). Instead we are using repo name
# For example: for given repo 'https://github.com/dkijania/mina.git' we convert it to 'dkijania_mina'
export GITTAG=1.0.0$(echo ${BUILDKITE_REPO} | sed -e 's/^.*github.com[:\/]\(.*\)\.git$/\1/' -e 's/\//-/')
export THIS_COMMIT_TAG=""

else
# GITTAG is the closest tagged commit to this commit, while THIS_COMMIT_TAG only has a value when the current commit is tagged
export GITTAG=$(find_most_recent_numeric_tag HEAD)
fi


export MINA_DEB_VERSION="${GITTAG}-${GITBRANCH}-${GITHASH}"
export MINA_DOCKER_TAG="$(echo "${MINA_DEB_VERSION}-${MINA_DEB_CODENAME}" | sed 's!/!-!g; s!_!-!g')"
export RELEASE=unstable

echo "Publishing on release channel \"${RELEASE}\""
[[ -n ${THIS_COMMIT_TAG} ]] && export MINA_COMMIT_TAG="${THIS_COMMIT_TAG}"

export MINA_DEB_RELEASE="${RELEASE}"
source ./buildkite/scripts/handle-fork.sh
14 changes: 14 additions & 0 deletions buildkite/scripts/handle-fork.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,18 @@ else
git fetch mina
export REMOTE="mina"
export FORK=1

# Abort if `BUILDKITE_REPO` doesn't have the expected format
echo ${BUILDKITE_REPO} | grep -P '^.*github.com[:\/](.*)\.git$' > /dev/null || \
(echo "BUILDKITE_REPO does not have the expected format" && false)

# We don't want to allow some operations on fork repository which should be done on main repo only.
# Publish to docker hub or publish to unstable debian channel should be exclusive to main repo as it can override
# packages from main repo (by using the same commit and the same branch from forked repository)

# We don't want to use tags (as this can replace our dockers/debian packages). Instead we are using repo name
# For example: for given repo 'https://github.com/dkijania/mina.git' we convert it to 'dkijania_mina'
export GITTAG=1.0.0$(echo ${BUILDKITE_REPO} | sed -e 's/^.*github.com[:\/]\(.*\)\.git$/\1/' -e 's/\//-/')
export THIS_COMMIT_TAG=""
export MINA_DEB_VERSION="${GITTAG}-${GITBRANCH}-${GITHASH}"
fi
12 changes: 2 additions & 10 deletions scripts/debian/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,10 @@ set -eox pipefail

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"

# In case of running this script on detached head, script has difficulties in finding out
# what is the current branch.
if [[ -n "$BRANCH_NAME" ]]; then
BRANCH_NAME="$BRANCH_NAME" source ${SCRIPTPATH}/../export-git-env-vars.sh
else
source ${SCRIPTPATH}/../export-git-env-vars.sh
fi

echo "after export"
source ${SCRIPTPATH}/../export-git-env-vars.sh

source ${SCRIPTPATH}/builder-helpers.sh

if [ $# -eq 0 ]
then
echo "No arguments supplied. Building all known debian packages"
Expand Down
27 changes: 5 additions & 22 deletions scripts/export-git-env-vars.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
#!/bin/bash
set -euo pipefail
set -x


# In case of running this script on detached head, script has difficulties in finding out
# what is the current
echo "Exporting Git Variables: "

git fetch
set -euox pipefail

function find_most_recent_numeric_tag() {
# We use the --prune flag because we've had problems with buildkite agents getting conflicting results here
Expand All @@ -20,19 +12,10 @@ function find_most_recent_numeric_tag() {
}

export GITHASH=$(git rev-parse --short=7 HEAD)
export THIS_COMMIT_TAG=$(git tag --points-at HEAD)

if [[ -n "$BRANCH_NAME" ]]; then
export GITBRANCH=$(echo "$BRANCH_NAME" | sed 's!/!-!g; s!_!-!g; s!#!-!g')
else
export GITBRANCH=$(git name-rev --name-only $GITHASH | sed "s/remotes\/origin\///g" | sed 's!/!-!g; s!_!-!g; s!#!-!g' )
fi

export GITBRANCH=$(git name-rev --name-only $GITHASH | sed "s/remotes\/origin\///g" | sed 's!/!-!g; s!_!-!g; s!#!-!g' )
export GITTAG=$(find_most_recent_numeric_tag HEAD)

export MINA_DEB_VERSION="${GITTAG}-${GITBRANCH}-${GITHASH}"
export MINA_DOCKER_TAG="$(echo "${MINA_DEB_VERSION}-${MINA_DEB_CODENAME}" | sed 's!/!-!g; s!_!-!g')"

[[ -n ${THIS_COMMIT_TAG} ]] && export MINA_COMMIT_TAG="${THIS_COMMIT_TAG}"

echo "after commit tag"
export MINA_DEB_RELEASE="unstable"
export MINA_DEB_CODENAME=${MINA_DEB_CODENAME:=bullseye}
export MINA_DOCKER_TAG="$(echo "${MINA_DEB_VERSION}-${MINA_DEB_CODENAME}" | sed 's!/!-!g; s!_!-!g')"