From 9d6831b86e15fadf119d991d9f26c386c847ec14 Mon Sep 17 00:00:00 2001 From: wisechengyi Date: Mon, 8 May 2017 21:02:17 -0700 Subject: [PATCH 1/5] 1.6.1 --- resources/META-INF/plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index 6b2bbf67a..59e68bec4 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -12,7 +12,7 @@ ]]> - 1.6.0 + 1.6.1 Twitter, Inc. From e1a3846b120fb4523c077dd3a9adc60c5c61507a Mon Sep 17 00:00:00 2001 From: wisechengyi Date: Mon, 8 May 2017 21:38:14 -0700 Subject: [PATCH 2/5] ding --- scripts/deploy/deploy.py | 30 +++++++++++++++++++++--------- scripts/deploy/deploy.sh | 2 +- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/scripts/deploy/deploy.py b/scripts/deploy/deploy.py index 65d3cc30f..76ffbc6fa 100755 --- a/scripts/deploy/deploy.py +++ b/scripts/deploy/deploy.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import argparse import logging import os import subprocess @@ -8,7 +9,8 @@ PLUGIN_XML = 'resources/META-INF/plugin.xml' PLUGIN_ID = 7412 PLUGIN_JAR = 'dist/intellij-pants-plugin-publish.jar' -CHANNEL = 'BleedingEdge' +CHANNEL_BLEEDING_EDGE = 'BleedingEdge' +CHANNEL_STABLE = 'Stable' REPO = 'https://plugins.jetbrains.com/plugin/7412' logger = logging.getLogger(__name__) @@ -29,22 +31,32 @@ def get_head_sha(): if __name__ == "__main__": - subprocess.check_output('git checkout {}'.format(PLUGIN_XML), shell=True) + parser = argparse.ArgumentParser() + parser.add_argument('--tag', type=str, default='') + args = parser.parse_args() - sha = get_head_sha() - logger.info('Append git sha {} to plugin version'.format(sha)) + subprocess.check_output('git checkout {}'.format(PLUGIN_XML), shell=True) tree = ET.parse(PLUGIN_XML) root = tree.getroot() - - # Find the `version` tag then append the head sha to it. version = root.find('version') + if version is None: logger.error("version tag not found in {}".format(PLUGIN_XML)) exit(1) - version.text = "{}.{}".format(version.text, sha) - tree.write(PLUGIN_XML) + if args.tag: + channel = CHANNEL_BLEEDING_EDGE + else: + channel = CHANNEL_STABLE + + sha = get_head_sha() + logger.info('Append git sha {} to plugin version'.format(sha)) + version.text = "{}.{}".format(version.text, sha) + + tree.write(PLUGIN_XML) + + logger.info('Releasing {} to {} channel'.format(version.text, channel)) zip_name = 'pants_{}.zip'.format(version.text) @@ -81,7 +93,7 @@ def get_head_sha(): '-password \'{password}\' ' \ '-plugin {plugin_id} ' \ '-file {zip}' \ - .format(channel=CHANNEL, + .format(channel=channel, username=os.environ['USERNAME'], password=os.environ['PASSWORD'], plugin_id=PLUGIN_ID, diff --git a/scripts/deploy/deploy.sh b/scripts/deploy/deploy.sh index b21feb9f7..a38adda5c 100755 --- a/scripts/deploy/deploy.sh +++ b/scripts/deploy/deploy.sh @@ -1,7 +1,7 @@ #!/bin/bash if [ "$TRAVIS_BRANCH" == "master" ]; then source scripts/prepare-ci-environment.sh - ./scripts/deploy/deploy.py + ./scripts/deploy/deploy.py --tag="$TRAVIS_TAG" else echo "Not on master. Skip deployment." fi From 07c5f15bbf340898186c4aee016e4a2d9b8048ac Mon Sep 17 00:00:00 2001 From: wisechengyi Date: Mon, 8 May 2017 21:50:12 -0700 Subject: [PATCH 3/5] correct channel --- scripts/deploy/deploy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/deploy/deploy.py b/scripts/deploy/deploy.py index 76ffbc6fa..e861bf528 100755 --- a/scripts/deploy/deploy.py +++ b/scripts/deploy/deploy.py @@ -46,9 +46,9 @@ def get_head_sha(): exit(1) if args.tag: - channel = CHANNEL_BLEEDING_EDGE - else: channel = CHANNEL_STABLE + else: + channel = CHANNEL_BLEEDING_EDGE sha = get_head_sha() logger.info('Append git sha {} to plugin version'.format(sha)) From 6bb318d4fba5384bce74a3b502a169ffdaa9e1e4 Mon Sep 17 00:00:00 2001 From: wisechengyi Date: Mon, 8 May 2017 22:17:55 -0700 Subject: [PATCH 4/5] or tag --- scripts/deploy/deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/deploy/deploy.sh b/scripts/deploy/deploy.sh index a38adda5c..ed690b541 100755 --- a/scripts/deploy/deploy.sh +++ b/scripts/deploy/deploy.sh @@ -1,5 +1,5 @@ #!/bin/bash -if [ "$TRAVIS_BRANCH" == "master" ]; then +if [ "$TRAVIS_BRANCH" == "master" ] || [ ! -z "$TRAVIS_TAG" ]; then source scripts/prepare-ci-environment.sh ./scripts/deploy/deploy.py --tag="$TRAVIS_TAG" else From 6ae0ff3d7b2f7a49eceea4f7019fb029cbffdcc0 Mon Sep 17 00:00:00 2001 From: wisechengyi Date: Tue, 9 May 2017 10:45:53 -0700 Subject: [PATCH 5/5] comemnts --- scripts/deploy/deploy.py | 8 ++++++-- scripts/deploy/deploy.sh | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/deploy/deploy.py b/scripts/deploy/deploy.py index e861bf528..3c62172c2 100755 --- a/scripts/deploy/deploy.py +++ b/scripts/deploy/deploy.py @@ -32,9 +32,13 @@ def get_head_sha(): if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument('--tag', type=str, default='') + parser.add_argument('--tag', type=str, default='', + help='If tag exists, this script will release to {} channel, otherwise {} channel.' + .format(CHANNEL_STABLE, CHANNEL_BLEEDING_EDGE)) args = parser.parse_args() + # Make sure the $PLUGIN_XML is not modified after multiple runs, + # since the workflow below may do so. subprocess.check_output('git checkout {}'.format(PLUGIN_XML), shell=True) tree = ET.parse(PLUGIN_XML) @@ -51,7 +55,7 @@ def get_head_sha(): channel = CHANNEL_BLEEDING_EDGE sha = get_head_sha() - logger.info('Append git sha {} to plugin version'.format(sha)) + logger.info('Append current git sha, {}, to plugin version'.format(sha)) version.text = "{}.{}".format(version.text, sha) tree.write(PLUGIN_XML) diff --git a/scripts/deploy/deploy.sh b/scripts/deploy/deploy.sh index ed690b541..cf3a16f27 100755 --- a/scripts/deploy/deploy.sh +++ b/scripts/deploy/deploy.sh @@ -1,4 +1,5 @@ #!/bin/bash +# Trigger deploy process if travis ci build is on master or on a tag. if [ "$TRAVIS_BRANCH" == "master" ] || [ ! -z "$TRAVIS_TAG" ]; then source scripts/prepare-ci-environment.sh ./scripts/deploy/deploy.py --tag="$TRAVIS_TAG"