Release and Deploy

Here are some notes, about how to publish or deploy locally or remotely to github / bintray jcenter Download

Versions

First of all, if you just wanna increment version, you can do it with versions-maven-plugin like so:

mvn build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} versions:commit
1
mvn build-helper:parse-version versions:set -DnewVersion=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.nextIncrementalVersion} versions:commit
1

example

mvn build-helper:parse-version versions:set -DnewVersion=1.2.3-SNAPSHOT versions:commit
1

Publish artifacts locally

NOTE

See ./bin/local-publish.sh script.

./mvnw -P local-publish
# ...
tree ./target/.m2
1
2
3

Artifacts should be found under ./target/m2/repository directory

Release github tag

NOTE

See ./bin/local-release.sh script. In case of failure, see ./bin/local-rollback.sh script.

shorter

./mvnw -Plocal-release -B -s .mvn/settings.xml \
    release:clean release:prepare release:perform
1
2

or more verbosely

./mvnw -DskipTests -Dmaven.deploy.skip=true -B -s .mvn/settings.xml \
  -Darguments="-DskipTests -Dmaven.deploy.skip=true" \
  -Dresume=false -DgenerateReleasePoms=false \
  -DtagNameFormat="@{project.version}" \
  release:prepare release:perform
1
2
3
4
5

Release should be found on github project repo release page

Publish artifacts to github

NOTE

See ./bin/github-publish.sh script.

  • first of all create maven branch on github and remove everything from it. so it will be using as new fresh clean maven repository
  • secondly prepare your .mvn/settings.xml file (see details in it's comments, you need last one: github):
    cp -Rf .mvn/settings.template.xml .mvn/settings.xml
    
    1
  • finally publish artifacts locally, so next we can upload them to github project repo in maven branch:
    ./mvnw -P local-publish
    ./mvnw -P github-publish -pl :sonar-quality-gates-build-breaker -s .mvn/settings.xml 
    
    1
    2
  • To use published artifacts dependencies in your other maven project, add next maven repository in your project pom.xml file:
    <repository>
        <id>github-maven-repo</id>
        <url>https://github.com/daggerok/sonar-quality-gates-build-breaker/tree/maven/</url>
    </repository>
    
    1
    2
    3
    4

NOTE

shorter way (one liner command) do everything we have dome before:

bash ./bin/github-all.sh
1

Upload Github release

./mvnw clean package
./mvnw -P github-release -pl :sonar-quality-gates-build-breaker
1
2

Publish artifacts to bintray jcenter

NOTE

See ./bin/bintray-all.sh script.

Workflow

  • on each tag trigger publish job
  • job should publish artifacts to own bintray jcenter maven repository
  • after it can be released manually in bintray web UI and synced with maven central

gpg

gpg --gen-key
gpg --list-secret-keys
# find: 7D2BAF1CF37B13E2069D6956105BD0E739499BDB in putput
gpg --keyserver hkp://pgp.mit.edu --send-keys 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg --keyserver hkp://pgp.mit.edu --recv-keys 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
1
2
3
4
5

avoid prompting gog passphrase

add according profile

<profile>
    <id>read gpg.passphrase from environment variable</id>
    <activation>
        <property>
            <name>env.GPG_PASSPHRASE</name>
        </property>
    </activation>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>${maven-gpg-plugin.version}</version>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <passphrase>${env.GPG_PASSPHRASE}</passphrase>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

first of all create own bintray jcenter daggerok/maven repository

  • Go to https://bintray.com/daggerok
  • Sign in (with GitHub)
  • Click on top right conor icon -> Edit Profile
  • Click on repositories -> New Repository
  • Enter name: maven
  • Select type: Maven
  • Select default license: MIT
  • Click Create

first time initially (before first publication) you have to create according package for your artifact in your maven repository

  • Goto https://bintray.com/daggerok/maven
  • Click Add New Package
  • Enter Name: sonar-quality-gates-build-breaker
  • Enter description...
  • Select Licences, Tags, Maturity
  • Enter Website: https://daggerok.github.io/sonar-quality-gates-build-breaker/
  • Enter Issues tracker: https://github.com/daggerok/sonar-quality-gates-build-breaker
  • Enter Version control: https://github.com/daggerok/sonar-quality-gates-build-breaker.git
  • Check Make download numbers in stats public
  • Click Create Package
  • Enter GitHub repo (user/repo): daggerok/sonar-quality-gates-build-breaker
  • Click Update Package
  • Enter GitHub release notes file: CHANGELOG.md
  • Click Update Package
  • Verify popup notification: Package sonar-quality-gates-build-breaker was updated

secondly update settings.xml file accordingly: //servers/server/bintray-daggerok-daggerok password => bintray API key

vi .mvn/settings.xml
1

add distributionManagement section in your pom.xml

<distributionManagement>
    <repository>
        <id>bintray-daggerok-maven</id>
        <name>daggerok-maven</name>
        <url>https://api.bintray.com/maven/daggerok/maven/sonar-quality-gates-build-breaker/;publish=1</url>
    </repository>
</distributionManagement>
1
2
3
4
5
6
7

finally, once repository was created and everything else needed has been done, publish artifacts to your personal bintray jcenter maven repository

more verbosely

./mvnw release:prepare release:perform -B -s .mvn/settings.xml \
  -DskipTests -Darguments="-DskipTests" \
  -DtagNameFormat="@{project.version}" \
  -DautoVersionSubmodules=true \
  -DgenerateReleasePoms=false \
  -DpreparationGoals="clean" \
  -DcompletionGoals="clean" \
  -Dresume=false
1
2
3
4
5
6
7
8

easiest way to release locally

GPG_PASSPHRASE=MyGpgPassPhraseForSonarBreaker bash ./bin/bintray-all.sh
1
Last Updated: 9/24/2019, 10:59:16 PM