This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
/
promote-nightly-to-release
executable file
·117 lines (101 loc) · 3.15 KB
/
promote-nightly-to-release
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
#
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
set -e
NIGHTLY="$1"
VERSION="$2"
if [ -z "$NIGHTLY" -o -z "$VERSION" -o "$1" == "--help" ]; then
echo "Usage: $0 YYYY.MM.DD MAJOR.MINOR"
exit 1
fi
if ! echo "$VERSION" | grep -q -e '^[0-9]\+\.[0-9]\+$'; then
echo "Only specify MAJOR.MINOR version, not MAJOR.MINOR.RELEASE"
exit 1
fi
if [ "$(<.git/HEAD)" != "ref: refs/heads/master" ]; then
echo "Run from master branch."
exit 1
fi
if ! git diff --exit-code >/dev/null; then
echo "Uncommitted changes, bailing out."
exit 1
fi
echo "Fetching any updates to packaging repo..."
git fetch >/dev/null
if ! git diff --exit-code origin/master..HEAD >/dev/null; then
echo "Current branch is out of sync with origin/master, bailing out."
exit 1
fi
MAJOR=$(echo "$VERSION" | cut -f1 -d.)
MINOR=$(echo "$VERSION" | cut -f2 -d.)
SED=$(if [ "$(uname -s)" == "Darwin" ]; then echo gsed; else echo sed; fi)
if ! which $SED >/dev/null; then
echo "'$SED' is required."
if [ "$SED" == "gsed" ]; then
echo "Try: brew install gnu-sed"
fi
exit 1
fi
PKGDIR="$(pwd)"
if [ ! -e "$PKGDIR/bin/$(basename $0)" ]; then
echo "This script must be ran from the root of the packaging repository."
exit 1
fi
GIT_ORIGIN="$(git remote get-url origin)"
if [ "$GIT_ORIGIN" != "git@github.com:hhvm/packaging.git" ]; then
echo "Git origin must be set to hhvm/packaging (not a fork)."
exit 1
fi
function statusline() {
# green background, back foreground
tput setab 2
tput setaf 0
echo "$@"
# reset
tput sgr0
}
statusline "Creating packaging branch..."
git checkout -b "HHVM-${VERSION}"
statusline "Marking support for new DISTRO apt repo.."
echo "DISTRO-${MAJOR}.${MINOR}" >> DEBIAN_REPOSITORIES
git commit DEBIAN_REPOSITORIES -m "Adding DISTRO-${MAJOR}.${MINOR} apt repositories"
statusline "Pushing packaging branch..."
git push -u origin "HEAD:HHVM-${VERSION}"
SCRATCHDIR="$(mktemp -dt hhvm.XXXXXXXX)"
statusline "Working in ${SCRATCHDIR}..."
cd "$SCRATCHDIR"
statusline "Cloning hhvm..."
git clone git@github.com:hhvm/hhvm-staging.git hhvm-${VERSION}
(
statusline "Tagging and pushing HHVM..."
cd hhvm-$VERSION
git remote add staging git@github.com:hhvm/hhvm-staging.git
git checkout -b "HHVM-${VERSION}"
git reset --hard "nightly-${NIGHTLY}"
"$PKGDIR/bin/hhvm-tag-and-push" "${VERSION}.0"
)
statusline "Cloning hhvm-docker..."
git clone git@github.com:hhvm/hhvm-docker.git
(
cd hhvm-docker
statusline "Removing 'latest' from previous release branch tags..."
git checkout "HHVM-${MAJOR}.$(($MINOR - 1))"
$SED -i '/^latest$/d' EXTRA_TAGS
git commit EXTRA_TAGS -m "Removing 'latest' tag"
git push
statusline "Creating branch for new release..."
git checkout master
git checkout -b "HHVM-$VERSION"
echo latest > EXTRA_TAGS
echo "${VERSION}-latest" >> EXTRA_TAGS
git commit EXTRA_TAGS -m "Update tags for ${VERSION} release"
git push -u origin "HEAD:HHVM-${VERSION}"
)
statusline "Triggering Linux builds..."
"$PKGDIR/bin/build-on-aws" "${VERSION}.0"
statusline "Cleaning up..."
rm -rf "${SCRATCHDIR}"