Skip to content

Commit

Permalink
Merge branch '0.14.x-1.20.x' into 0.15.x-1.20.x
Browse files Browse the repository at this point in the history
I forgot to pull before working on the port :/
  • Loading branch information
Kneelawk committed Apr 26, 2024
2 parents 23d1b7d + 06c9919 commit f7882a8
Show file tree
Hide file tree
Showing 2 changed files with 170 additions and 2 deletions.
122 changes: 122 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Publish

on: [workflow_dispatch] # Manual trigger

jobs:
prep:
runs-on: ubuntu-latest
name: 'Work'
outputs:
did_tasks: ${{ steps.tasks.conclusion }}
did_license: ${{ steps.license.conclusion }}
did_test: ${{ steps.test.conclusion }}
did_javadoc: ${{ steps.javadoc.conclusion }}
did_build: ${{ steps.build.conclusion }}
did_publish: ${{ steps.publish.conclusion }}
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
distribution: 'adopt-hotspot'
java-version: '17'
- id: tasks
name: 'Setup'
run: './gradlew tasks'
- id: 'license'
name: 'Check License'
run: './gradlew checkLicense'
- id: 'test'
name: 'Test'
run: './gradlew test'
- id: 'javadoc'
name: 'Javadoc'
run: './gradlew javadoc'
- id: 'build'
name: 'Build'
run: './gradlew build'
- id: 'publish'
name: 'Build'
run: './gradlew publish uploadJavadoc'
env:
UPLOAD_MAVEN_URL: ${{ secrets.UPLOAD_MAVEN_URL }}
UPLOAD_PASSWORD: ${{ secrets.UPLOAD_PASSWORD }}
UPLOAD_USERNAME: ${{ secrets.UPLOAD_USERNAME }}
output_tasks:
name: 'Check Buildscript'
runs-on: ubuntu-latest
needs: prep
if: always()
steps:
- name: 'Check Tasks'
run: |
echo "${{ needs.prep.outputs.did_tasks }}"
if [[ ${{ needs.prep.outputs.did_tasks }} != "success" ]]; then
echo "Look at the 'Work' job to see what went wrong!"
exit 1
fi
output_license:
name: 'Check License'
runs-on: ubuntu-latest
needs: [prep, output_tasks]
if: always()
steps:
- name: 'Check License'
run: |
echo "${{ needs.prep.outputs.did_license }}"
if [[ ${{ needs.prep.outputs.did_license }} != "success" ]]; then
echo "Look at the 'Work' job to see what went wrong!"
exit 1
fi
output_test:
name: 'Run Tests'
runs-on: ubuntu-latest
needs: [prep, output_license]
if: always()
steps:
- name: 'Check Test'
run: |
echo "${{ needs.prep.outputs.did_test }}"
if [[ ${{ needs.prep.outputs.did_test }} != "success" ]]; then
echo "Look at the 'Work' job to see what went wrong!"
exit 1
fi
output_javadoc:
name: 'Generate Javadoc'
runs-on: ubuntu-latest
needs: [prep, output_test]
if: always()
steps:
- name: 'Check Javadocs'
run: |
echo "${{ needs.prep.outputs.did_javadoc }}"
if [[ ${{ needs.prep.outputs.did_javadoc }} != "success" ]]; then
echo "Look at the 'Work' job to see what went wrong!"
exit 1
fi
output_build:
name: 'Build Jars'
runs-on: ubuntu-latest
needs: [prep, output_javadoc]
if: always()
steps:
- name: 'Check Build'
run: |
echo "${{ needs.prep.outputs.did_build }}"
if [[ ${{ needs.prep.outputs.did_build }} != "success" ]]; then
echo "Look at the 'Work' job to see what went wrong!"
exit 1
fi
output_publish:
name: 'Publish Jars'
runs-on: ubuntu-latest
needs: [prep, output_build]
if: always()
steps:
- name: 'Check Publishing'
run: |
echo "${{ needs.prep.outputs.did_publish }}"
if [[ ${{ needs.prep.outputs.did_publish }} != "success" ]]; then
echo "Look at the 'Work' job to see what went wrong!"
exit 1
fi
50 changes: 48 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,56 @@ test {
workingDir = "run/"
}

import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

if (System.getenv("UPLOAD_MAVEN_URL") != null) {
task packageJavadoc(type: Zip, dependsOn: javadoc) {
from javadoc.destinationDir
archiveFileName = "libnetworkstack-javadoc-" + version + ".zip"
}

task uploadJavadoc(dependsOn: packageJavadoc) {
doLast {
HttpClient cl = HttpClient.newBuilder().authenticator(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(System.getenv("UPLOAD_USERNAME"), System.getenv("UPLOAD_PASSWORD").toCharArray());
}
}).build();
java.io.File file = packageJavadoc.outputs.files.singleFile;
java.nio.file.Path path = file.toPath();
HttpRequest put = HttpRequest.newBuilder()
.PUT(HttpRequest.BodyPublishers.ofFile(path))
.uri(new URI(System.getenv("UPLOAD_MAVEN_URL") + "/tmp-javadocs/" + file.getName()))
.build();
HttpResponse<String> response = cl.send(put, HttpResponse.BodyHandlers.ofString());
if ((int)(response.statusCode() / 100) != 2) {
println(response.statusCode());
println(response.body());
throw new Error("Upload Javadoc Zip Failed!");
}
}
}
}

publishing {
repositories {
maven {
url System.getenv("MAVEN_DIR") ?: "$projectDir/build/maven"
if (System.getenv("UPLOAD_MAVEN_URL") != null) {
maven {
url System.getenv("UPLOAD_MAVEN_URL");
credentials {
username System.getenv("UPLOAD_USERNAME");
password System.getenv("UPLOAD_PASSWORD");
}
}
} else {
maven {
url System.getenv("MAVEN_DIR") ?: "$projectDir/build/maven"
}
}
}
}
Expand Down

0 comments on commit f7882a8

Please sign in to comment.