Skip to content

Commit

Permalink
Configure deployment to Maven Central with JReleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Nov 28, 2022
1 parent fa234da commit 14e8a1d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ jobs:
- name: Build
run: |
chmod +x mvnw
./mvnw -B -ntp install
./mvnw -ntp -B install
13 changes: 7 additions & 6 deletions .github/workflows/early-access.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,18 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- uses: n1hility/cancel-previous-runs@v2
- name: Cancel previous run
uses: styfle/cancel-workflow-action@0.11.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Version
id: vars
shell: bash
run: |
chmod +x mvnw
version=$(./mvnw -ntp help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "VERSION=$(echo $version)" >>$GITHUB_OUTPUT
version=$(./mvnw -ntp -B help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "VERSION=$(echo $version)" >> $GITHUB_OUTPUT
release:
name: release
Expand All @@ -72,7 +73,7 @@ jobs:
- name: Build
run: |
chmod +x mvnw
./mvnw -B -ntp install
./mvnw -ntp -B install
- name: Release
env:
Expand All @@ -83,7 +84,7 @@ jobs:
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: |
./mvnw -B -ntp -pl :layrry-aggregator -Pjreleaser jreleaser:release
./mvnw -ntp -B -pl :layrry-aggregator -Pjreleaser jreleaser:release
- name: JReleaser output
if: always()
Expand Down
44 changes: 13 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ jobs:
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRO }}
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Cache Maven
uses: actions/cache@v3
Expand All @@ -58,16 +53,13 @@ jobs:
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: 'Test Build Readiness'
env:
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Test Build Readiness
run: |
export GPG_TTY=$(tty)
./mvnw -ntp --file pom.xml -Dmaven.site.skip=true -Drelease=true verify -e
./mvnw -ntp -B --file pom.xml -Dmaven.site.skip=true -Drelease=true verify -e
./mvnw -ntp -B --file pom.xml clean
- name: 'Set release version'
- name: Set release version
id: version
run: |
chmod +x mvnw
Expand All @@ -86,25 +78,12 @@ jobs:
git commit -a -m "🏁 Releasing version $RELEASE_VERSION"
git push origin HEAD:master
# clean needed to remove previous build
# install needed by tests
# don't @ me <_<
- name: Build
- name: Stage artifacts
run: |
./mvnw -ntp -B clean install -DskipTests=true
- name: 'Release to Maven Central'
env:
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
export GPG_TTY=$(tty)
./mvnw -ntp --file pom.xml \
-Drepository.url=https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git \
-Dmaven.site.skip=true -Drelease=true -DskipTests=true deploy -e
./mvnw -ntp -B --file pom.xml -Ppublication -DaltDeploymentRepository=local::file:target/staging-deploy \
-Dmaven.site.skip=true install deploy -e
- name: 'Release to GitHub'
- name: Release
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_SDKMAN_CONSUMER_KEY: ${{ secrets.JRELEASER_SDKMAN_CONSUMER_KEY }}
Expand All @@ -116,10 +95,13 @@ jobs:
JRELEASER_TWITTER_CONSUMER_SECRET: ${{ secrets.JRELEASER_TWITTER_CONSUMER_SECRET }}
JRELEASER_TWITTER_ACCESS_TOKEN: ${{ secrets.JRELEASER_TWITTER_ACCESS_TOKEN }}
JRELEASER_TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.JRELEASER_TWITTER_ACCESS_TOKEN_SECRET }}
JRELEASER_MASTODON_ACCESS_TOKEN: ${{ secrets.JRELEASER_MASTODON_ACCESS_TOKEN }}
JRELEASER_NEXUS2_MAVEN_CENTRAL_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
JRELEASER_NEXUS2_MAVEN_CENTRAL_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: |
./mvnw -ntp -B -pl :layrry-aggregator -Pjreleaser jreleaser:full-release
- name: 'JReleaser output'
- name: JReleaser output
if: always()
uses: actions/upload-artifact@v3
with:
Expand All @@ -128,7 +110,7 @@ jobs:
target/jreleaser/trace.log
target/jreleaser/output.properties
- name: 'Set next version'
- name: Set next version
run: |
./mvnw -B versions:set versions:commit -DnewVersion=${{ env.NEXT_VERSION }}
git config --global user.email "${{ env.USER_EMAIL }}"
Expand Down
33 changes: 25 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
<plugin>
<groupId>org.jreleaser</groupId>
<artifactId>jreleaser-maven-plugin</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<inherited>false</inherited>
<configuration>
<jreleaser>
Expand Down Expand Up @@ -304,6 +304,25 @@
</changelog>
</github>
</release>
<signing>
<active>ALWAYS</active>
<armored>true</armored>
</signing>
<deploy>
<maven>
<nexus2>
<maven-central>
<active>RELEASE</active>
<url>https://oss.sonatype.org/service/local</url>
<closeRepository>true</closeRepository>
<releaseRepository>true</releaseRepository>
<stagingRepositories>
<stagingRepository>target/staging-deploy</stagingRepository>
</stagingRepositories>
</maven-central>
</nexus2>
</maven>
</deploy>
<distributions>
<layrry>
<sdkman>
Expand Down Expand Up @@ -332,16 +351,14 @@
<active>RELEASE</active>
<status>🚀 Layrry {{projectVersion}} has been released! {{releaseNotesUrl}}</status>
</twitter>
<mastodon>
<active>RELEASE</active>
<host>https://mastodon.social</host>
<status>🚀 Layrry {{projectVersion}} has been released! {{releaseNotesUrl}}</status>
</mastodon>
</announce>
</jreleaser>
</configuration>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Expand Down

0 comments on commit 14e8a1d

Please sign in to comment.