Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Release to Maven Central

on:
push:
tags:
- 'v*'
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up JDK 8
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '8'

- name: Import GPG key
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: |
echo "$GPG_PRIVATE_KEY" | gpg --batch --import

- name: Configure Maven settings
env:
CENTRAL_TOKEN_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }}
CENTRAL_TOKEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
mkdir -p ~/.m2
cat > ~/.m2/settings.xml <<EOF
<settings>
<servers>
<server>
<id>central</id>
<username>${CENTRAL_TOKEN_USERNAME}</username>
<password>${CENTRAL_TOKEN_PASSWORD}</password>
</server>
<server>
<id>EBFD22439E5C59D664D0CFC750617B51F61187C2</id>
<passphrase>${GPG_PASSPHRASE}</passphrase>
</server>
</servers>
</settings>
EOF

- name: Publish to Maven Central
run: mvn --batch-mode clean deploy
32 changes: 13 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ If you are using Maven, add the following to your `pom.xml` file:
<dependency>
<groupId>org.hsluv</groupId>
<artifactId>hsluv</artifactId>
<version>1.0</version>
<version>1.0.1</version>
</dependency>

# Usage
Expand Down Expand Up @@ -73,37 +73,31 @@ var color = android.graphics.Color.rgb(r, g, b);

Docs:

- https://central.sonatype.org/publish/publish-maven/
- https://central.sonatype.org/publish/publish-portal-maven/
- https://central.sonatype.org/publish/requirements/gpg/
- https://central.sonatype.org/publish/generate-portal-token/

Set `~/m2/settings.xml`:
Generate a Portal token at https://central.sonatype.com, then set `~/.m2/settings.xml`:

```xml
<settings>
<servers>
<server>
<id>ossrh</id>
<username>hsluv</username>
<password>REDACTEDREDACTEDREDACTED</password>
<id>central</id>
<username><!-- your token username --></username>
<password><!-- your token password --></password>
</server>
<server>
<id>EBFD22439E5C59D664D0CFC750617B51F61187C2</id>
<passphrase><!-- your GPG key passphrase --></passphrase>
</server>
</servers>
<profiles>
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.passphrase>REDACTEDREDACTEDREDACTED</gpg.passphrase>
</properties>
</profile>
</profiles>
</settings>
```

Then run:

```bash
mvn versions:set -DnewVersion=0.3 # bump version
mvn clean deploy -P release
mvn versions:set -DnewVersion=1.0.1 # bump version
mvn clean deploy
```
22 changes: 7 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>org.hsluv</groupId>
<artifactId>hsluv</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<version>1.0.1</version>

<name>hsluv</name>
<description>Human-friendly HSL</description>
Expand Down Expand Up @@ -57,25 +57,17 @@
</dependency>
</dependencies>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

<build>
<plugins>
<!-- https://central.sonatype.org/publish/publish-maven/ -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.11.0</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<publishingServerId>central</publishingServerId>
<autoPublish>true</autoPublish>
<waitUntil>published</waitUntil>
</configuration>
</plugin>
<plugin>
Expand Down