Skip to content

Commit 23981fb

Browse files
hub fix
1 parent 490be96 commit 23981fb

File tree

2 files changed

+57
-16
lines changed

2 files changed

+57
-16
lines changed

.github/workflows/swift.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,6 @@ jobs:
9595
- uses: maxim-lobanov/setup-xcode@v1
9696
with:
9797
xcode-version: 14.1.0
98-
- uses: actions/checkout@v2
99-
with:
100-
# You should create a personal access token and store it in your repository
101-
token: ${{ secrets.CI_USER_TOKEN }}
102-
repository: 'optimizely/travisci-tools'
103-
path: 'home/runner/travisci-tools'
104-
ref: 'master'
105-
- name: Install hub
106-
shell: bash
107-
env:
108-
HOME: 'home/runner'
109-
run: |
110-
# installs hub to ~/bin
111-
$HOME/travisci-tools/release_github/install_hub.sh
11298
- name: Push to cocoapods.org
11399
env:
114100
HOME: 'home/runner'
@@ -119,5 +105,4 @@ jobs:
119105
COCOAPODS_VERSION: '1.12.1'
120106
run: |
121107
gem install cocoapods -v $COCOAPODS_VERSION
122-
$HOME/travisci-tools/release_github/install_hub.sh
123108
Scripts/run_release.sh

Scripts/run_release.sh

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,61 @@ set -e
99

1010
MYREPO=${HOME}/workdir/${REPO_SLUG}
1111

12+
ARCH="amd64"
13+
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
14+
case "$OS" in
15+
mingw* | msys* ) OS=windows ;;
16+
esac
17+
18+
[[ $OS == 'windows' ]] && windows=1
19+
20+
download() {
21+
case "$OS" in
22+
windows )
23+
WINDOWS_URL=$(curl -u $GITHUB_USER:$GITHUB_TOKEN https://api.github.com/repos/$1/$2/releases/latest 2>/dev/null | jq -r '.assets[] | select(.browser_download_url | contains("windows-amd64")) | .browser_download_url')
24+
echo "$WINDOWS_URL"
25+
curl -fsSLO "$WINDOWS_URL"
26+
unzip "$(basename "$WINDOWS_URL")" bin/hub.exe
27+
rm -f "$(basename "$WINDOWS_URL")"
28+
;;
29+
darwin )
30+
DARWIN_URL=$(curl -u $GITHUB_USER:$GITHUB_TOKEN https://api.github.com/repos/$1/$2/releases/latest 2>/dev/null | jq -r '.assets[] | select(.browser_download_url | contains("darwin-amd64")) | .browser_download_url')
31+
curl -fsSL "$DARWIN_URL" -o - | tar xz --strip-components=1 '*/bin/hub'
32+
;;
33+
* )
34+
LINUX_URL=$(curl -u $GITHUB_USER:$GITHUB_TOKEN https://api.github.com/repos/$1/$2/releases/latest 2>/dev/null | jq -r '.assets[] | select(.browser_download_url | contains("linux-amd64")) | .browser_download_url')
35+
curl -fsSL "$LINUX_URL" | tar xz --strip-components=1 --wildcards '*/bin/hub'
36+
;;
37+
esac
38+
}
39+
40+
function install_binary {
41+
mkdir -p ~/bin
42+
43+
# https://code-maven.com/create-temporary-directory-on-linux-using-bash
44+
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
45+
46+
cd $tmp_dir
47+
48+
download $1 $2
49+
50+
if [ ! -f "$tmp_dir/bin/hub${windows:+.exe}" ]; then
51+
echo "Failed to obtain $tmp_dir/bin/hub${windows:+.exe}"
52+
exit 1
53+
fi
54+
mkdir -p ~/bin/
55+
mv $tmp_dir/bin/hub${windows:+.exe} ~/bin/
56+
57+
chmod +x ~/bin/hub${windows:+.exe}
58+
59+
# verify
60+
~/bin/hub${windows:+.exe} version
61+
62+
# cleanup
63+
rm -rf $tmp_dir
64+
}
65+
66+
1267
function prep_workspace {
1368
rm -rf ${MYREPO}
1469
mkdir -p ${MYREPO}
@@ -37,7 +92,8 @@ function release_github {
3792
LAST_VERSION=$(grep '^## \d\+\.\d\+.\d\+' ${CHANGELOG} | awk 'NR==2')
3893

3994
DESCRIPTION=$(awk "/^${NEW_VERSION}$/,/^${LAST_VERSION:-nothingmatched}$/" ${CHANGELOG} | grep -v "^${LAST_VERSION:-nothingmatched}$")
40-
95+
install_binary mislav hub
96+
hub version
4197
hub release create v${VERSION} -m "Release ${VERSION}" -m "${DESCRIPTION}" -t "${BRANCH}"
4298
}
4399

0 commit comments

Comments
 (0)