Skip to content

Commit 8d32087

Browse files
authored
Merge pull request #402 from CraveFood/github-releases
GitHub releases
2 parents 4d4d2f8 + bb7177a commit 8d32087

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ before_install:
1111
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.3.2
1212
- export PATH="$HOME/.yarn/bin:$PATH"
1313
- export BRANCH="${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"
14+
- export TZ="America/Sao_Paulo"
1415
- git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
1516
- git fetch --all
1617
- git checkout "$BRANCH"
@@ -44,6 +45,8 @@ after_success:
4445
git add docs;
4546
git commit -m "chore(docs): [ci skip] gallery update";
4647
git push origin "$BRANCH";
48+
source ./bin/github_get_release_id.sh;
49+
./bin/github_publish_release.sh;
4750
else
4851
lerna publish --canary --yes || travis_terminate 1;
4952
fi

bin/github_get_release_id.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
if [ -z "$GH_TOKEN" ]; then
4+
echo "Missing Github token";
5+
exit 1;
6+
fi
7+
8+
RELEASE_NAME="master"
9+
10+
export RELEASE_ID=$(
11+
curl https://api.github.com/repos/CraveFood/farmblocks/releases \
12+
-H "Authorization: token $GH_TOKEN"\
13+
-H "Accept: application/vnd.github.v3+json"\
14+
| jq ".[] | select(.name == \"$RELEASE_NAME\") | .id"
15+
)
16+
17+
echo $RELEASE_ID

bin/github_publish_release.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
if [ -z "$GH_TOKEN" ]; then
4+
echo "Missing Github token";
5+
exit 1;
6+
fi
7+
8+
if [ -z "$RELEASE_ID" ]; then
9+
echo "Missing release ID";
10+
exit 1;
11+
fi
12+
13+
DRAFT_STATUS="false"
14+
RELEASE_NAME=$(date '+%Y-%m-%d.%H%M')
15+
16+
curl "https://api.github.com/repos/CraveFood/farmblocks/releases/$RELEASE_ID" \
17+
-H "Accept: application/vnd.github.v3+json"\
18+
-H "Authorization: token $GH_TOKEN"\
19+
-X PATCH \
20+
--data "{\"name\": \"$RELEASE_NAME\", \"tag_name\": \"$RELEASE_NAME\", \"draft\": $DRAFT_STATUS}"
21+

0 commit comments

Comments
 (0)