Skip to content

Commit

Permalink
Feature release management (#1)
Browse files Browse the repository at this point in the history
Add GitHub deploy actions
  • Loading branch information
RagedUnicorn authored Jul 20, 2022
1 parent 0e91db8 commit ea4669f
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 76 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/github_package_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,27 @@ on: [workflow_dispatch]
jobs:
github-package-release-job:
runs-on: ubuntu-latest
name: GitHub Package Release
steps:
- name: dummy step
- name: Checkout
uses: actions/checkout@v2
- name: Set up Java and Maven
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: 'maven'
- name: Cache Local Maven Repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Publish Package to GitHub
run: |
mvn --batch-mode --no-transfer-progress \
deploy \
-P release-github-package
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 changes: 24 additions & 1 deletion .github/workflows/github_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,28 @@ on: [workflow_dispatch]
jobs:
github-release-job:
runs-on: ubuntu-latest
name: GitHub Release
steps:
- name: dummy step
- name: Checkout
uses: actions/checkout@v2
- name: Set up Java and Maven
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: 'maven'
- name: Cache Local Maven Repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Create GitHub Release
run: |
mvn --batch-mode --no-transfer-progress \
deploy \
-P release-github \
-D github.auth-token=$GITHUB_TOKEN
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 changes: 33 additions & 1 deletion .github/workflows/ossrh_package_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,37 @@ on: [workflow_dispatch]
jobs:
ossrh-package-release-job:
runs-on: ubuntu-latest
name: OSSRH Package Release
steps:
- name: dummy step
- name: Checkout
uses: actions/checkout@v2
- name: Set up Java and Maven
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: 'maven'
server-id: ossrh
server-username: SONATYPE_USERNAME
server-password: SONATYPE_PASSWORD
- name: Cache Local Maven Repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Install GPG Secret Key
run: |
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
- name: Publish Package to OSSRH
run: |
mvn --batch-mode --no-transfer-progress \
deploy \
-P release-ossrh-package \
-D gpg.passphrase=$OSSRH_GPG_SECRET_KEY_PASSWORD
env:
SONATYPE_USERNAME: ${{ secrets.OSSRH_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
OSSRH_GPG_SECRET_KEY_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
41 changes: 10 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,45 +120,24 @@ clean install

#### Create a Release

In maven `settings.xml` configure the ossrh account
This project has GitHub action profiles for different Devops related work such as deployments to different places. See .github folder for details.
The project is deployed to three different places. Each deployment has its own Maven profile for configuration.

```
<server>
<id>ossrh</id>
<username></username>
<password></password>
</server>
```

#### Build and Release

```
mvn clean deploy -P deploy
```
##### GitHub Release

#### Move Staging to Release
`.github/workflows/github_release.yaml` - Creates a tag and release on GitHub

If `autoReleaseAfterClose` is set to false in the `nexus-staging-maven-plugin` plugin an additional step is required to move the deployment from staging to release.
##### GitHub Package Release

```
mvn nexus-staging:release
```

Or if the deployment didn't work out you can drop the artifact from the staging repository.

```
mvn nexus-staging:drop
```
`.github/workflows/github_package_release.yaml` - Releases a package on GitHub

**Note:** On MacOS the error `gpg: signing failed: Inappropriate ioctl for device` can be solved by setting the tty export variable for gpg.
##### OSSRH Package Release

```
export GPG_TTY=$(tty)
```
`.github/workflows/ossrh_package_release.yaml` - Releases a package on OSSRH (Sonatype)

If you are using the IntelliJ console this might need to be set directly in that console.
All steps are required to make a full release of the plugin but can be done independently of each other. The workflows have to be manually invoked on GitHub.

##### Run Example
#### Run Example

The example can be used for testing of the plugin during development. It requires some manual setup on GitHub before it can be run.

Expand Down
24 changes: 9 additions & 15 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
# Release

> This document explains how a new release is created for wago-release-maven-plugin
> This document explains how a new release is created for sql-execute-maven-plugin
* Remove snapshot from version and commit
* Create a new git tag and push it
* `git tag vx.x.x`
* `git push origin --tags`
* Draft new GitHub release with description
* Title should be the version e.g. vx.x.x
* Short description of what changed
* Deploy release artifact to OSSRH
* mvn clean deploy -P deploy
* mvn nexus-staging:release when autoReleaseAfterClose is set to false
* Increase project version and add SNAPSHOT then commit (after a release the version should always be a snapshot version)
* Don't forget to update the example and the test pom with the same version

**Note:** Snapshot versions can be deployed with the same command `mvn clean deploy -P deploy`
* Remove snapshot from version for plugin and example then commit
* Update `src/main/resources/release-notes.md` with changes
* Invoke GitHub Action `GitHub Release`
* Invoke GitHub Action `GitHub Package Release`
* This can also be used to deploy snapshot versions
* Invoke GitHub Action `OSSRH Package Release`
* This can also be used to deploy snapshot versions
* Increase project version and add SNAPSHOT for plugin and example then commit (after a release the version should always be a snapshot version)
114 changes: 87 additions & 27 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,8 @@
<url>https://github.com/RagedUnicorn/wago-release-maven-plugin/tree/master</url>
</scm>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
</distributionManagement>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<gpg.keyname>488C9072D9E5426B</gpg.keyname>
<checkstyle.config.location>checkstyle.xml</checkstyle.config.location>
<checkstyle.header.location>LICENSE.txt</checkstyle.header.location>
</properties>
Expand All @@ -77,23 +65,96 @@
<skip.sign.gpg>true</skip.sign.gpg>
<skip.package.javadoc>true</skip.package.javadoc>
<skip.package.sources>true</skip.package.sources>
<skip.deploy>true</skip.deploy>
</properties>
</profile>
<profile>
<id>release</id>
<id>release-ossrh-package</id>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<name>Sonatype Apache Maven Snapshots Packages</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<name>Sonatype Apache Maven Packages</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
</distributionManagement>
<properties>
<skip.sign.gpg>true</skip.sign.gpg>
<skip.package.javadoc>true</skip.package.javadoc>
<skip.package.sources>true</skip.package.sources>
<skip.sign.gpg>false</skip.sign.gpg>
<skip.package.javadoc>false</skip.package.javadoc>
<skip.package.sources>false</skip.package.sources>
<skip.deploy>true</skip.deploy>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>deploy</id>
<id>release-github-package</id>
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub RagedUnicorn Apache Maven Packages</name>
<url>https://maven.pkg.github.com/ragedunicorn/wago-release-maven-plugin</url>
</repository>
</distributionManagement>
<properties>
<skip.sign.gpg>false</skip.sign.gpg>
<skip.sign.gpg>true</skip.sign.gpg>
<skip.package.javadoc>false</skip.package.javadoc>
<skip.package.sources>false</skip.package.sources>
<skip.deploy>false</skip.deploy>
</properties>
</profile>
<profile>
<id>release-github</id>
<properties>
<skip.sign.gpg>true</skip.sign.gpg>
<skip.package.javadoc>true</skip.package.javadoc>
<skip.package.sources>true</skip.package.sources>
<skip.deploy>true</skip.deploy>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.ragedunicorn.tools.maven</groupId>
<artifactId>github-release-maven-plugin</artifactId>
<version>1.0.4</version>
<executions>
<execution>
<id>default-cli</id>
<phase>deploy</phase>
<goals>
<goal>github-release</goal>
</goals>
<configuration>
<owner>ragedunicorn</owner>
<repository>wago-release-maven-plugin</repository>
<!--suppress UnresolvedMavenProperty -->
<authToken>${github.auth-token}</authToken>
<tagName>v${project.version}</tagName>
<name>v${project.version}</name>
<releaseNotes>src/main/resources/release-notes.md</releaseNotes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

Expand Down Expand Up @@ -125,9 +186,11 @@
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
<skip>${skip.sign.gpg}</skip>
<keyname>${gpg.keyname}</keyname>
<passphraseServerId>${gpg.keyname}</passphraseServerId>
</configuration>
</execution>
</executions>
Expand Down Expand Up @@ -165,14 +228,11 @@
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
<skip>${skip.deploy}</skip>
</configuration>
</plugin>
<plugin>
Expand Down
Empty file.

0 comments on commit ea4669f

Please sign in to comment.