Skip to content
This repository was archived by the owner on Feb 16, 2022. It is now read-only.

Commit a55c575

Browse files
authored
Merge pull request #6 from yinonavraham/deploy-to-bintray
Deploy release version artifacts to Bintray
2 parents 4f020ca + d53a9e2 commit a55c575

5 files changed

Lines changed: 113 additions & 8 deletions

File tree

.travis.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ dist: precise
55
jdk:
66
- oraclejdk7
77
before_install:
8-
# Enable using aliases in a non-interactive bash script
9-
# See: https://github.com/travis-ci/travis-ci/issues/2552
10-
- shopt -s expand_aliases
11-
# Since using JDK7 - prevent error downloading from Maven Central: Received fatal alert: protocol_version
12-
# See: https://central.sonatype.org/articles/2018/May/04/discontinued-support-for-tlsv11-and-below/
13-
- alias mvn='mvn -Dhttps.protocols=TLSv1.2'
14-
script: mvn verify -B
8+
- chmod +x .travis/mvn
9+
install: .travis/mvn install -DskipTests=true -Dmaven.javadoc.skip=true
10+
script: .travis/mvn verify
1511
after_success:
1612
# -- Codacy --
17-
- mvn codacy:coverage -B
13+
- .travis/mvn codacy:coverage
14+
deploy:
15+
provider: script
16+
script: .travis/mvn deploy -s .travis/bintray-settings.xml -DskipTests
17+
skip_cleanup: true
18+
on:
19+
tags: true

.travis/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Travis-CI Integration
2+
3+
## File Descriptions
4+
5+
* [`.travis.yml`](../.travis.yml)
6+
The travis job configuration file
7+
* [`.travis/bintray-settings.xml`](bintray-settings.xml)
8+
Maven settings file specifically for the deployment phase to Bintray (see [Deployment](#deployment))
9+
* [`.travis/mvn`](mvn)
10+
A wrapper script with options and flags for `mvn` command line tool which are commonly used in Travis-CI
11+
12+
## Job Phases
13+
14+
### Install
15+
16+
Build the code, skip tests and such
17+
18+
### Test (i.e. `script`)
19+
20+
Run tests and collect code coverage.
21+
22+
### After Success
23+
24+
Upload code coverage to Codacy.
25+
26+
**Environment Variables**
27+
28+
| Name | Required | Secure | Description |
29+
| ---------------------- | :------: | :----: | ----------- |
30+
| `CODACY_PROJECT_TOKEN` | YES | YES | The token that identifies the target project in Codacy |
31+
32+
### Deployment
33+
34+
Deploy release artifacts to [Bintray](https://bintray.com).
35+
This phase should be executed only when a tag is pushed.
36+
Also, since Bintray supports only release versions, if the tag references a snapshot version, this phase will fail.
37+
38+
**Environment Variables**
39+
40+
| Name | Required | Secure | Description |
41+
| ------------------- | :------: | :----: | ----------- |
42+
| `BINTRAY_REPO_SLUG` | YES | NO | The slug of the target repository in Bintray. Expected format: `<subject>/<repo>` |
43+
| `BINTRAY_USER` | YES | NO | The user to use for authentication when uploading the artifacts |
44+
| `BINTRAY_API_KEY` | YES | YES | The API key of the user, used for authentication |
45+
| `BINTRAY_PUBLISH` | NO | NO | Whether to publish the artifacts after they were uploaded successfully. Values: `0,1`, default: `0` |
46+
| `BINTRAY_OVERRIDE` | NO | NO | Whether to override existing artifacts (if any) when uploading. Values: `0,1`, default: `0` |
47+

.travis/bintray-settings.xml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
5+
6+
<servers>
7+
<server>
8+
<id>bintray-maven-repo</id>
9+
<username>${env.BINTRAY_USER}</username>
10+
<password>${env.BINTRAY_API_KEY}</password>
11+
</server>
12+
</servers>
13+
14+
<profiles>
15+
<profile>
16+
<id>default-bintray-publish</id>
17+
<!-- Set default value for the BINTRAY_PUBLISH env variable if not defined -->
18+
<activation>
19+
<property>
20+
<name>!env.BINTRAY_PUBLISH</name>
21+
</property>
22+
</activation>
23+
<properties>
24+
<env.BINTRAY_PUBLISH>0</env.BINTRAY_PUBLISH>
25+
</properties>
26+
</profile>
27+
<profile>
28+
<id>default-bintray-override</id>
29+
<!-- Set default value for the BINTRAY_OVERRIDE env variable if not defined -->
30+
<activation>
31+
<property>
32+
<name>!env.BINTRAY_OVERRIDE</name>
33+
</property>
34+
</activation>
35+
<properties>
36+
<env.BINTRAY_OVERRIDE>0</env.BINTRAY_OVERRIDE>
37+
</properties>
38+
</profile>
39+
</profiles>
40+
41+
</settings>

.travis/mvn

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
# mvn command wrapper script - with commonly used options and flags
4+
5+
# Since using JDK7 - prevent error downloading from Maven Central: Received fatal alert: protocol_version
6+
# See: https://central.sonatype.org/articles/2018/May/04/discontinued-support-for-tlsv11-and-below/
7+
mvn -Dhttps.protocols=TLSv1.2 -B -V $@

pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,12 @@
152152
</plugins>
153153
</build>
154154

155+
<distributionManagement>
156+
<repository>
157+
<id>bintray-maven-repo</id>
158+
<!--suppress MavenModelInspection -->
159+
<url>https://api.bintray.com/maven/${env.BINTRAY_REPO_SLUG}/commands-cli/;publish=${env.BINTRAY_PUBLISH};override=${env.BINTRAY_OVERRIDE}</url>
160+
</repository>
161+
</distributionManagement>
162+
155163
</project>

0 commit comments

Comments
 (0)