Skip to content

Commit 96cade6

Browse files
committed
automate github release from travis
1 parent 3a65169 commit 96cade6

File tree

6 files changed

+70
-25
lines changed

6 files changed

+70
-25
lines changed

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ Changelog.md
88
Makefile
99
docker-compose.yml
1010
docs
11-
dist
11+
dist
12+
release

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ selenium-debug.log
1717
.npm
1818
.config
1919
/tests/unit/coverage/
20+
release

.travis.yml

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,34 +33,40 @@ jobs:
3333
include:
3434
- stage: run on pull requests
3535
script:
36-
- docker run $ci_env -v `pwd`:/home:rw mew-build-container /bin/bash -c "npm install && npm run lint && npm run codecov && ROUTER_MODE=history npm run build"
36+
- docker run $ci_env -v `pwd`:/home:rw mew-build-container /bin/bash -c "npm install
37+
&& npm run lint && npm run codecov && ROUTER_MODE=history npm run build"
3738
- stage: add to codecov
3839
script:
39-
- docker run $ci_env -v `pwd`:/home:rw mew-build-container /bin/bash -c "npm install && npm run codecov"
40+
- docker run $ci_env -v `pwd`:/home:rw mew-build-container /bin/bash -c "npm install
41+
&& npm run codecov"
4042
- stage: add to mewbuilds staging
4143
before_script:
42-
- docker run -v `pwd`:/home:rw mew-build-container /bin/bash -c "npm install && ROUTER_MODE=history npm run build"
44+
- docker run -v `pwd`:/home:rw mew-build-container /bin/bash -c "npm install &&
45+
ROUTER_MODE=history npm run build"
4346
- pip install --user awscli
4447
script:
4548
- aws s3 rm s3://mewbuilds/staging/ --recursive
4649
- aws s3 sync --acl public-read dist/ s3://mewbuilds/staging/
4750
- stage: add to mewbuilds develop
4851
before_script:
49-
- docker run -v `pwd`:/home:rw mew-build-container /bin/bash -c "npm install && ROUTER_MODE=history npm run build"
52+
- docker run -v `pwd`:/home:rw mew-build-container /bin/bash -c "npm install &&
53+
ROUTER_MODE=history npm run build"
5054
- pip install --user awscli
5155
script:
5256
- aws s3 rm s3://mewbuilds/develop/ --recursive
5357
- aws s3 sync --acl public-read dist/ s3://mewbuilds/develop/
5458
- stage: add to mewbuilds
5559
before_script:
56-
- docker run -v `pwd`:/home:rw mew-build-container /bin/bash -c "npm install && ROUTER_MODE=hash npm run build"
60+
- docker run -v `pwd`:/home:rw mew-build-container /bin/bash -c "npm install &&
61+
ROUTER_MODE=hash npm run build"
5762
- pip install --user awscli
5863
- ssh-keyscan -H $IPFS_NODE >> $HOME/.ssh/known_hosts
5964
script:
6065
- openssl aes-256-cbc -K $encrypted_2bd32a0810e2_key -iv $encrypted_2bd32a0810e2_iv
6166
-in ipfs-host.pem.enc -out ipfs-host.pem -d
6267
- chmod 400 ipfs-host.pem
63-
- hashOut=`tar -cjvf - -C dist/ . | ssh -i ipfs-host.pem ubuntu@$IPFS_NODE ./ipfs-publish.sh --`
68+
- hashOut=`tar -cjvf - -C dist/ . | ssh -i ipfs-host.pem ubuntu@$IPFS_NODE ./ipfs-publish.sh
69+
--`
6470
- HASH=`echo $hashOut | sed -n 's:.*<hash>\(.*\)</hash>.*:\1:p'`
6571
- aws s3 sync --acl public-read dist/ s3://mewbuilds/build/$TRAVIS_COMMIT
6672
after_success:
@@ -73,25 +79,19 @@ jobs:
7379
script: skip
7480
before_deploy:
7581
- docker run -v `pwd`:/home:rw mew-build-container /bin/bash -c "npm install && ROUTER_MODE=hash npm run build"
76-
- sudo mkdir deploy
77-
- ls -a /dist | sort
78-
- |
79-
PACKAGE_VERSION=$(cat package.json \
80-
| grep version \
81-
| head -1 \
82-
| awk -F: '{ print $2 }' \
83-
| sed 's/[",]//g' \
84-
| tr -d '[[:space:]]'); sudo zip -r ./deploy/release-"$PACKAGE_VERSION".zip ./dist; git tag v$PACKAGE_VERSION
82+
- openssl aes-256-cbc -K $encrypted_2bd32a0810e2_key -iv $encrypted_2bd32a0810e2_iv -in mew_sec.gpg.enc -out mew.gpg -d
83+
- gpg --allow-secret-key-import --import mew.gpg
8584
deploy:
86-
provider: releases
87-
api_key: '$GITHUB_TOKEN'
88-
file: deploy/*
89-
file_glob: true
85+
provider: script
86+
script: bash ./release.sh $TRAVIS_TAG $GITHUB_TOKEN $TRAVIS_REPO_SLUG true
9087
skip_cleanup: true
88+
on:
89+
tags: true
90+
branch: master
9191
- stage: deploy to production
9292
script: skip
9393
before_deploy:
94-
- bash ./deploy.sh
94+
- docker run -v `pwd`:/home:rw mew-build-container /bin/bash -c "npm install && ROUTER_MODE=hash npm run build"
9595
deploy:
9696
provider: pages
9797
skip-cleanup: true
@@ -100,4 +100,5 @@ jobs:
100100
local-dir: './dist'
101101
on:
102102
branch: master
103+
tags: true
103104
target-branch: gh-pages

deploy.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

mew_sec.gpg.enc

6.45 KB
Binary file not shown.

release.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/sh
2+
RELEASE="$1"
3+
GITHUB_TOKEN="$2"
4+
REPO="$3"
5+
CHANGELOG=`awk -v version="$RELEASE" '/### Release / {printit = $3 == version}; printit;' 'CHANGELOG.md'`
6+
mkdir release
7+
cd dist && zip -r ../release/MyEtherWallet-$RELEASE.zip * && cd ..
8+
if [ -n "$4" ]; then
9+
for f in release/*; do
10+
gpg --output $f.sig --detach-sig $f
11+
done
12+
fi
13+
cd release && sha256sum * > MyEtherWallet-$RELEASE-CHECKSUM-SHA256 && cd ..
14+
GH_API="https://api.github.com"
15+
GH_REPO="$GH_API/repos/$REPO"
16+
AUTH="Authorization: token ${GITHUB_TOKEN}"
17+
GH_TAGS="$GH_REPO/releases/tags/$RELEASE"
18+
payload=$(
19+
jq --null-input \
20+
--arg tag "$RELEASE" \
21+
--arg name "MyEtherWallet $RELEASE" \
22+
--arg body "$CHANGELOG" \
23+
'{ tag_name: $tag, name: $name, body: $body, draft: false }'
24+
)
25+
26+
response=$(
27+
curl -H "$AUTH" \
28+
--fail \
29+
--silent \
30+
--location \
31+
--data "$payload" \
32+
"https://api.github.com/repos/${REPO}/releases"
33+
)
34+
upresponse=$(curl -sH "$AUTH" $GH_TAGS)
35+
eval $(echo "$upresponse" | grep -m 1 "id.:" | grep -w id | tr : = | tr -cd '[[:alnum:]]=')
36+
[ "$id" ] || { echo "Error: Failed to get release id for tag: $RELEASE"; echo "$upresponse" | awk 'length($0)<100' >&2; exit 1; }
37+
38+
for file in ./release/*; do
39+
curl -H "$AUTH" \
40+
--header "Content-Type: application/octet-stream" \
41+
--data-binary "@$file" \
42+
--fail \
43+
--silent \
44+
--location \
45+
"https://uploads.github.com/repos/${REPO}/releases/$id/assets?name=$(basename $file)"
46+
done

0 commit comments

Comments
 (0)