Skip to content

Commit 01de0c2

Browse files
committed
wip
Signed-off-by: Dmitry Dygalo <[email protected]>
1 parent 3b8f466 commit 01de0c2

File tree

4 files changed

+159
-17
lines changed

4 files changed

+159
-17
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
- master
88
schedule: [cron: "40 1 * * *"]
99

10+
env:
11+
JAVA_VERSION: "21"
12+
1013
jobs:
1114
commitsar:
1215
name: Verify commit messages
@@ -439,8 +442,6 @@ jobs:
439442
yarn test
440443
441444
test-java:
442-
env:
443-
JAVA_VERSION: "21"
444445
strategy:
445446
fail-fast: false
446447
matrix:

.github/workflows/java-release.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,66 @@ jobs:
161161
162162
javac -cp "$JAR_FILE" Test.java
163163
java -cp "$JAR_FILE${CLASSPATH_SEP}." Test
164+
165+
publish-github-packages:
166+
name: Publish to GitHub Packages
167+
runs-on: ubuntu-22.04
168+
needs: [build-jar, test-jar]
169+
if: startsWith(github.ref, 'refs/tags/java-v')
170+
permissions:
171+
contents: read
172+
packages: write
173+
steps:
174+
- uses: actions/checkout@v4
175+
176+
- name: Set up Java
177+
uses: actions/setup-java@v4
178+
with:
179+
distribution: "temurin"
180+
java-version: ${{ env.JAVA_VERSION }}
181+
182+
- name: Download JAR artifact
183+
uses: actions/download-artifact@v4
184+
with:
185+
name: java-jar
186+
path: build/libs
187+
188+
- name: Extract version
189+
run: echo "version=${GITHUB_REF#refs/tags/java-v}" >> $GITHUB_ENV
190+
191+
- name: Publish to GitHub Packages
192+
working-directory: bindings/java
193+
run: |
194+
# Copy the pre-built JAR to the expected location
195+
mkdir -p build/libs
196+
cp ../../build/libs/*.jar build/libs/
197+
198+
# Publish using the existing JAR
199+
gradle publish -Pversion=${{ env.version }}
200+
env:
201+
GITHUB_ACTOR: ${{ github.actor }}
202+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
203+
VERSION: ${{ env.version }}
204+
205+
release:
206+
name: Create GitHub Release
207+
runs-on: ubuntu-22.04
208+
needs: [build-jar, test-jar, publish-github-packages]
209+
if: startsWith(github.ref, 'refs/tags/java-v')
210+
steps:
211+
- name: Download JAR
212+
uses: actions/download-artifact@v4
213+
with:
214+
name: java-jar
215+
path: dist
216+
217+
- name: Extract version
218+
run: echo "version=${GITHUB_REF#refs/tags/java-v}" >> $GITHUB_ENV
219+
220+
- name: GitHub Release
221+
uses: softprops/action-gh-release@v2
222+
with:
223+
make_latest: false
224+
draft: true
225+
name: "[Java] Release ${{ env.version }}"
226+
files: dist/*.jar

bindings/java/README.md

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# css-inline
22

33
[<img alt="build status" src="https://img.shields.io/github/actions/workflow/status/Stranger6667/css-inline/build.yml?style=flat-square&labelColor=555555&logo=github" height="20">](https://github.com/Stranger6667/css-inline/actions/workflows/build.yml)
4-
[<img alt="maven central" src="https://img.shields.io/maven-central/v/org.css-inline/css-inline.svg?style=flat-square&color=fc8d62&logo=apachemaven" height="20">](#installation)
5-
[<img alt="javadoc" src="https://img.shields.io/badge/javadoc-css--inline-66c2a5?style=flat-square&labelColor=555555" height="20">](https://javadoc.io/badge2/org.css-inline/css-inline/javadoc.svg)
4+
[<img alt="github packages" src="https://img.shields.io/badge/github%20packages-css--inline-66c2a5?style=flat-square&labelColor=555555&logo=github" height="20">](https://github.com/Stranger6667/css-inline/packages)
65

76
Java bindings for the high-performance `css-inline` library that inlines CSS into HTML 'style' attributes.
87

@@ -44,20 +43,49 @@ into:
4443

4544
## Installation
4645

47-
**Maven:**
48-
```xml
49-
<dependency>
50-
<groupId>org.css-inline</groupId>
51-
<artifactId>css-inline</artifactId>
52-
<version>0.15.0</version>
53-
</dependency>
54-
```
46+
This package is available on [GitHub Packages](https://github.com/Stranger6667/css-inline/packages).
47+
48+
### Setup
49+
50+
GitHub Packages requires authentication even for public packages. See the [GitHub documentation](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry#authenticating-to-github-packages) for authentication setup.
5551

5652
**Gradle:**
5753
```gradle
58-
implementation 'org.css-inline:css-inline:0.15.0'
54+
repositories {
55+
maven {
56+
url = uri("https://maven.pkg.github.com/Stranger6667/css-inline")
57+
credentials {
58+
username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
59+
password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
60+
}
61+
}
62+
}
63+
64+
dependencies {
65+
implementation 'org.css-inline:css-inline:0.15.0'
66+
}
5967
```
6068

69+
**Maven:**
70+
```xml
71+
<repositories>
72+
<repository>
73+
<id>github</id>
74+
<url>https://maven.pkg.github.com/Stranger6667/css-inline</url>
75+
</repository>
76+
</repositories>
77+
78+
<dependencies>
79+
<dependency>
80+
<groupId>org.css-inline</groupId>
81+
<artifactId>css-inline</artifactId>
82+
<version>0.15.0</version>
83+
</dependency>
84+
</dependencies>
85+
```
86+
87+
See [GitHub's Maven documentation](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry) for Maven authentication setup.
88+
6189
### Platform Support
6290

6391
This JAR includes native libraries for the following platforms:
@@ -142,7 +170,7 @@ public class FragmentExample {
142170
p {
143171
color: red;
144172
}
145-
173+
146174
h1 {
147175
color: blue;
148176
}

bindings/java/build.gradle

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,63 @@
11
plugins {
2-
id 'java'
2+
id 'java-library'
3+
id 'maven-publish'
34
id 'me.champeau.jmh' version '0.7.3'
45
}
56

67
group = 'org.css-inline'
78
version = System.getenv('VERSION') ?: '0.15.0-SNAPSHOT'
89

9-
repositories {
10-
mavenCentral()
10+
java {
11+
withJavadocJar()
12+
withSourcesJar()
13+
sourceCompatibility = JavaVersion.VERSION_11
14+
targetCompatibility = JavaVersion.VERSION_11
15+
}
16+
17+
publishing {
18+
repositories {
19+
maven {
20+
name = "GitHubPackages"
21+
url = uri("https://maven.pkg.github.com/Stranger6667/css-inline")
22+
credentials {
23+
username = System.getenv("GITHUB_ACTOR")
24+
password = System.getenv("GITHUB_TOKEN")
25+
}
26+
}
27+
}
28+
29+
publications {
30+
maven(MavenPublication) {
31+
from components.java
32+
33+
pom {
34+
name = 'CSS Inline Java'
35+
description = 'Java bindings for css-inline - a high-performance CSS inlining library'
36+
url = 'https://css-inline.org'
37+
38+
licenses {
39+
license {
40+
name = 'MIT License'
41+
url = 'https://opensource.org/licenses/MIT'
42+
}
43+
}
44+
45+
developers {
46+
developer {
47+
id = 'stranger6667'
48+
name = 'Dmitry Dygalo'
49+
50+
}
51+
}
52+
53+
scm {
54+
connection = 'scm:git:git://github.com/Stranger6667/css-inline.git'
55+
developerConnection = 'scm:git:ssh://github.com:Stranger6667/css-inline.git'
56+
url = 'https://github.com/Stranger6667/css-inline/tree/master'
57+
}
58+
}
59+
}
60+
}
1161
}
1262

1363
dependencies {

0 commit comments

Comments
 (0)