From ea4669fca104f2e672d3ffc0a7f7ed2ad4c8f8c1 Mon Sep 17 00:00:00 2001 From: Raged Unicorn Date: Wed, 20 Jul 2022 18:08:04 +0200 Subject: [PATCH] Feature release management (#1) Add GitHub deploy actions --- .github/workflows/github_package_release.yaml | 24 +++- .github/workflows/github_release.yaml | 25 +++- .github/workflows/ossrh_package_release.yaml | 34 +++++- README.md | 41 ++----- RELEASE.md | 24 ++-- pom.xml | 114 +++++++++++++----- src/main/resources/release-notes.md | 0 7 files changed, 186 insertions(+), 76 deletions(-) create mode 100644 src/main/resources/release-notes.md diff --git a/.github/workflows/github_package_release.yaml b/.github/workflows/github_package_release.yaml index 1c6ebc3..f105120 100644 --- a/.github/workflows/github_package_release.yaml +++ b/.github/workflows/github_package_release.yaml @@ -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 }} \ No newline at end of file diff --git a/.github/workflows/github_release.yaml b/.github/workflows/github_release.yaml index 80812e3..6a48a9d 100644 --- a/.github/workflows/github_release.yaml +++ b/.github/workflows/github_release.yaml @@ -4,5 +4,28 @@ on: [workflow_dispatch] jobs: github-release-job: runs-on: ubuntu-latest + name: GitHub Release steps: - - name: dummy step \ No newline at end of file + - 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 }} \ No newline at end of file diff --git a/.github/workflows/ossrh_package_release.yaml b/.github/workflows/ossrh_package_release.yaml index a41bdf3..f17dafa 100644 --- a/.github/workflows/ossrh_package_release.yaml +++ b/.github/workflows/ossrh_package_release.yaml @@ -4,5 +4,37 @@ on: [workflow_dispatch] jobs: ossrh-package-release-job: runs-on: ubuntu-latest + name: OSSRH Package Release steps: - - name: dummy step \ No newline at end of file + - 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 }} \ No newline at end of file diff --git a/README.md b/README.md index 43d8d44..60c10b0 100644 --- a/README.md +++ b/README.md @@ -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. -``` - - ossrh - - - -``` - -#### 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. diff --git a/RELEASE.md b/RELEASE.md index 586ee88..aba9f18 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -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) \ No newline at end of file diff --git a/pom.xml b/pom.xml index 86d50af..bb808e2 100644 --- a/pom.xml +++ b/pom.xml @@ -49,20 +49,8 @@ https://github.com/RagedUnicorn/wago-release-maven-plugin/tree/master - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2 - - - UTF-8 - 488C9072D9E5426B checkstyle.xml LICENSE.txt @@ -77,23 +65,96 @@ true true true + true - release + release-ossrh-package + + + ossrh + Sonatype Apache Maven Snapshots Packages + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + Sonatype Apache Maven Packages + https://oss.sonatype.org/service/local/staging/deploy/maven2 + + - true - true - true + false + false + false + true + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.8 + true + + ossrh + https://oss.sonatype.org/ + true + + + + - deploy + release-github-package + + + github + GitHub RagedUnicorn Apache Maven Packages + https://maven.pkg.github.com/ragedunicorn/wago-release-maven-plugin + + - false + true false false + false + + + + release-github + + true + true + true + true + + + + com.ragedunicorn.tools.maven + github-release-maven-plugin + 1.0.4 + + + default-cli + deploy + + github-release + + + ragedunicorn + wago-release-maven-plugin + + ${github.auth-token} + v${project.version} + v${project.version} + src/main/resources/release-notes.md + + + + + + @@ -125,9 +186,11 @@ sign + + --pinentry-mode + loopback + ${skip.sign.gpg} - ${gpg.keyname} - ${gpg.keyname} @@ -165,14 +228,11 @@ - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.8 - true + org.apache.maven.plugins + maven-deploy-plugin + 2.7 - ossrh - https://oss.sonatype.org/ - false + ${skip.deploy} diff --git a/src/main/resources/release-notes.md b/src/main/resources/release-notes.md new file mode 100644 index 0000000..e69de29