Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.6.1 with automation #296

Merged
merged 5 commits into from
May 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</ul>
]]>
</change-notes>
<version>1.6.0</version>
<version>1.6.1</version>
<vendor>Twitter, Inc.</vendor>

<!--if you are changing since-build don't forget to change it in .travis.yml file as well-->
Expand Down
34 changes: 25 additions & 9 deletions scripts/deploy/deploy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python

import argparse
import logging
import os
import subprocess
Expand All @@ -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__)
Expand All @@ -29,22 +31,36 @@ 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='',
help='If tag exists, this script will release to {} channel, otherwise {} channel.'
.format(CHANNEL_STABLE, CHANNEL_BLEEDING_EDGE))
args = parser.parse_args()

sha = get_head_sha()
logger.info('Append git sha {} to plugin version'.format(sha))
# 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)
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_STABLE
else:
channel = CHANNEL_BLEEDING_EDGE

sha = get_head_sha()
logger.info('Append current 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)

Expand Down Expand Up @@ -81,7 +97,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,
Expand Down
5 changes: 3 additions & 2 deletions scripts/deploy/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash
if [ "$TRAVIS_BRANCH" == "master" ]; then
# 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
./scripts/deploy/deploy.py --tag="$TRAVIS_TAG"
else
echo "Not on master. Skip deployment."
fi