diff --git a/scripts/packaging/homebrew_release.sh b/scripts/packaging/homebrew_release.sh index 8ff2d48a15115471b45cd3bbb50c37b0a2143c8b..cd8981651de27a91ec21faf8103d2b2ac8bf2526 100755 --- a/scripts/packaging/homebrew_release.sh +++ b/scripts/packaging/homebrew_release.sh @@ -12,59 +12,48 @@ set -ue # be set accordingly but the CI. BUCKET="$GCP_LINUX_PACKAGES_BUCKET" -# set version - -. ./scripts/version.sh -. ./scripts/ci/octez-release.sh - # fetch tags for releases git fetch -q --tags -if [ -n "${gitlab_release_no_v:-}" ]; then - VERSION=$gitlab_release_no_v -elif [ -n "${CI_COMMIT_TAG:-}" ]; then - VERSION=$(date +'%Y%m%d%H%M')+$CI_COMMIT_TAG +if [ -z "${CI:-}" ]; then + TIMESTAMP=$(date '+%Y%m%d%H%M') + CI_COMMIT_SHORT_SHA=$(git rev-parse --short HEAD) + CI_COMMIT_REF_NAME=$(git rev-parse --abbrev-ref HEAD) + CI_COMMIT_TAG=$(git describe --exact-match --tags 2> /dev/null || git rev-parse --short HEAD) else - VERSION=$(date +'%Y%m%d%H%M')+$CI_COMMIT_SHORT_SHA + TIMESTAMP="$(date -d "$CI_PIPELINE_CREATED_AT" '+%Y%m%d%H%M')" fi -# prepare target dir - -if [ -n "${gitlab_release_no_v:-}" ]; then - # if it's a release tag, then it can be a RC release or a final release - if [ -n "${gitlab_release_rc_version}" ]; then - # Release candidate - TARGETDIR="public/homebrew/RC/Formula" - else - # Release - TARGETDIR="public/homebrew/Formula" - fi -else - if [ "$CI_COMMIT_REF_PROTECTED" = "false" ]; then - if [ "$CI_COMMIT_REF_NAME" = "RC" ]; then - echo "Cannot create a repository for a branch named 'RC'" - exit 1 - else - # Branch is not protected, this is for testing ordinary MRs - TARGETDIR="public/homebrew/$CI_COMMIT_REF_NAME/Formula" - fi - else - # For protected branches that are not release, we allow - # a repository only for master. - if [ "$CI_COMMIT_REF_NAME" = "master" ]; then - TARGETDIR="public/homebrew/master/Formula" - else - if [ -n "${CI_COMMIT_TAG:-}" ]; then - TARGETDIR="public/homebrew/${CI_COMMIT_TAG}/Formula" - else - echo "Cannot create a repository for a protected branch that is not associated to a tag or master" - exit 1 - fi - fi - fi -fi +# set $VERSION ( for release* branches ) and $RELEASETYPE +. scripts/ci/octez-packages-version.sh + +case "$RELEASETYPE" in +ReleaseCandidate | TestReleaseCandidate) + TARGETDIR="public/homebrew/RC/Formula" + ;; +Release | TestRelease) + TARGETDIR="public/homebrew/Formula" + ;; +Master) + VERSION="$TIMESTAMP+$CI_COMMIT_SHORT_SHA" + TARGETDIR="public/homebrew/master/Formula" + ;; +SoftRelease) + VERSION="$TIMESTAMP+${CI_COMMIT_TAG:-}" + TARGETDIR="public/homebrew/${CI_COMMIT_TAG}/Formula" + ;; +TestBranch) + VERSION="$TIMESTAMP+$CI_COMMIT_SHORT_SHA" + TARGETDIR="public/homebrew/$CI_COMMIT_REF_NAME/Formula" + ;; +*) + echo "Cannot create a repository for this branch" + exit 1 + ;; +esac # prepare formula +echo "Preparing homebrew formula $VERSION -> $TARGETDIR" mkdir -p "$TARGETDIR" diff --git a/scripts/packaging/test_homebrew_install.sh b/scripts/packaging/test_homebrew_install.sh index 261f7beef42f76e5e3286f647b6ca10bc7c46da9..e20bf855cf194841477dcc1f37d58af48314d2f3 100755 --- a/scripts/packaging/test_homebrew_install.sh +++ b/scripts/packaging/test_homebrew_install.sh @@ -12,46 +12,28 @@ set -ue # be set accordingly but the CI. BUCKET="$GCP_LINUX_PACKAGES_BUCKET" -# set version - -. scripts/version.sh -. scripts/ci/octez-release.sh - -# prepare target dir - -if [ -n "${gitlab_release_no_v:-}" ]; then - # if it's a release tag, then it can be a RC release or a final release - if [ -n "${gitlab_release_rc_version}" ]; then - # Release candidate - TARGETDIR="homebrew/RC/Formula" - else - # Release - TARGETDIR="homebrew/Formula" - fi -else - if [ "$CI_COMMIT_REF_PROTECTED" = "false" ]; then - if [ "$CI_COMMIT_REF_NAME" = "RC" ]; then - echo "Cannot create a repository for a branch named 'RC'" - exit 1 - else - # Branch is not protected, this is for testing ordinary MRs - TARGETDIR="homebrew/$CI_COMMIT_REF_NAME/Formula" - fi - else - # For protected branches that are not release, we allow - # a repository only for master. - if [ "$CI_COMMIT_REF_NAME" = "master" ]; then - TARGETDIR="homebrew/master/Formula" - else - if [ -n "${CI_COMMIT_TAG}" ]; then - TARGETDIR="homebrew/${CI_COMMIT_TAG}/Formula" - else - echo "Cannot create a repository for a protected branch that is not associated to a tag or master" - exit 1 - fi - fi - fi -fi +. scripts/ci/octez-packages-version.sh +case "$RELEASETYPE" in +ReleaseCandidate | TestReleaseCandidate) + TARGETDIR="homebrew/RC/Formula" + ;; +Release | TestRelease) + TARGETDIR="homebrew/Formula" + ;; +Master) + TARGETDIR="homebrew/master/Formula" + ;; +SoftRelease) + TARGETDIR="homebrew/${CI_COMMIT_TAG}/Formula" + ;; +TestBranch) + TARGETDIR="homebrew/$CI_COMMIT_REF_NAME/Formula" + ;; +*) + echo "Cannot create a repository for this branch" + exit 1 + ;; +esac echo "installing formula from https://$BUCKET.storage.googleapis.com/$TARGETDIR/octez.rb"