add plugin configuration in deploy phase:
<build>
<plugins>
<plugin>
<groupId>de.jutzig</groupId>
<artifactId>github-release-plugin</artifactId>
<version>1.1.1</version>
<!-- publish release on deploy phase -->
<executions>
<execution>
<id>release</id>
<phase>deploy</phase>
</execution>
</executions>
<configuration>
<releaseName>v${project.version}</releaseName>
<tag>${project.version}</tag>
<!-- re-release same version (not fail if relase exists) -->
<overwriteArtifact>true</overwriteArtifact>
<!-- in fileSets add all files you wanna release: -->
<fileSets>
<fileSet>
<directory>${project.basedir}/scripts</directory>
<includes>
<include>application*.bash</include>
<include>application*.cmd</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/modules/docker/postgres</directory>
<includes>
<include>docker-compose.yml</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/modules/apps/file-items-service/build/libs</directory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/modules/apps/file-server/build/libs</directory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
</configuration>
</plugin>
</plugins>
</build>
important: add to
pom.xml
file proper configurations (connection url proto must be https, not git if you are using username / password credentials):<scm>
<!-- important! must be https if you ganna push using github username/password creds -->
<connection>scm:git:https://github.com/daggerok/streaming-file-server.git</connection>
<url>https://github.com/daggerok/streaming-file-server.git</url>
<developerConnection>scm:git:git@github.com:daggerok/streaming-file-server.git</developerConnection>
<tag>HEAD</tag>
</scm>
finally update your
~/.m2/settings.xml
file: put here your github credentials for server github
<settings>
<servers>
<server>
<id>github</id>
<username>GITHUB_USERNAME</username>
<password>GITHUB_PASSWORD</password>
</server>
</servers>
</settings>
we need maven goal
de.jutzig:github-release-plugin:1.1.1:release
./mvnw de.jutzig:github-release-plugin:1.1.1:release
to simplify command just add default goal, so maven will execute it for you automatically
<defaultGoal>exec:exec de.jutzig:github-release-plugin:1.1.1:release</defaultGoal>
now, for release you can just use maven wrapper with no arguments, like so:
./mvnw
set username / password for publishing release to gituhb:
./mvnw -Dusername=ololo -Dpassword=trololo
Lets assume for project build we are isong different commands / shell scripts for different systems, such as windows, linux, mac os x…
windows
gradlew.bat clean build
non windows (linux, mac, etc…)
./gradlew clean build
so before release we need build project with there commands depends on OS we are working. to do so we can introduse maven profiles and use proper scripts bor build refore release:
pom.xml
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>compile-gradle</id>
<phase>initialize</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${gradle.executable}</executable>
<arguments>
<argument>clean</argument>
<argument>build</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>de.jutzig</groupId>
<artifactId>github-release-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>release</id>
<phase>deploy</phase>
</execution>
</executions>
<configuration>
<overwriteArtifact>true</overwriteArtifact>
<description>${project.artifactId} release</description>
<releaseName>v${project.version}</releaseName>
<tag>${project.version}</tag>
<fileSets>
<fileSet>
<directory>${project.basedir}/scripts</directory>
<includes>
<include>application*.bash</include>
<include>application*.cmd</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/modules/docker/postgres</directory>
<includes>
<include>docker-compose.yml</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/modules/apps/file-items-service/build/libs</directory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/modules/apps/file-server/build/libs</directory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>win</id>
<activation>
<os>
<family>Windows</family>
</os>
</activation>
<properties>
<gradle.executable>gradlew.bat</gradle.executable>
</properties>
</profile>
<profile>
<id>nix</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<properties>
<gradle.executable>./gradlew</gradle.executable>
</properties>
</profile>
</profiles>
links: