Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
emilymclean committed Jun 7, 2024
2 parents b046fd5 + 750db2c commit ad5797e
Show file tree
Hide file tree
Showing 16 changed files with 427 additions and 4 deletions.
133 changes: 133 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Build
'on':
pull_request:
branches:
- main
- develop
push:
branches:
- main
- develop
- release/**
permissions:
contents: write
jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.gitversion.outputs.semVer }}
versionCode: ${{ steps.run_number.outputs.versionCode }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.6
with:
versionSpec: 5.x
- id: gitversion
name: Use GitVersion
uses: gittools/actions/gitversion/execute@v0.9.6
with:
useConfigFile: true
configFilePath: ./gitversion.yml
- name: Display SemVer
run: 'echo "SemVer: ${{ steps.gitversion.outputs.semVer }}"'
build:
needs:
- version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: temurin
- name: Build with Gradle
env:
ORG_GRADLE_PROJECT_version: ${{ needs.version.outputs.version }}
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: build
- name: Rename AAR
run: mv ./build/libs/jlemmy-${{ needs.version.outputs.version }}.jar ./jlemmy.jar
- uses: actions/upload-artifact@master
with:
name: jlemmy-jar
path: ./jlemmy.jar
release:
permissions:
contents: write
needs:
- version
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: create_release
name: Create Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: v${{ needs.version.outputs.version }}
name: Release ${{ needs.version.outputs.version }}
draft: false
prerelease: ${{ github.ref != 'refs/heads/main' }}
publish-release:
needs:
- version
- release
- build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@master
with:
name: jlemmy-jar
path: ./
- name: Upload Artifact to Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ./jlemmy.jar
asset_name: jlemmy-v${{ needs.version.outputs.version }}.jar
asset_content_type: application/zip
publish-sonatype:
permissions:
contents: read
needs:
- version
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: temurin
- name: Build with Gradle
env:
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.PGP_SECRET }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.PGP_PASSPHRASE }}
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: |-
-Pversion=${{ needs.version.outputs.version }}
-Ppom.url="https://github.com/${{ github.repository }}"
-Ppom.scm.connection="scm:git:git://github.com/${{ github.repository }}"
-Ppom.scm.developerConnection="scm:git:ssh://github.com/${{ github.repository }}"
-Ppom.scm.url="https://github.com/${{ github.repository }}"
publishToCentralPortal --no-daemon
1 change: 1 addition & 0 deletions .github/workflows/pkl
Submodule pkl added at 34d941
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Test
'on':
pull_request:
branches:
- main
- develop
push:
branches:
- main
- develop
- release/**
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: temurin
- name: Test with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: test
62 changes: 62 additions & 0 deletions .github/workflows/update-types.pkl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
extends "pkl/src/base.pkl"
import "pkl/src/common.pkl"

name = "Update"

on = new On {
schedule = new Schedule {
cron = "* * * * Sun"
}
workflow_dispatch = new WorkflowDispatch {}
}

permissions = new Mapping {
["contents"] = "write"
}

jobs = new Mapping {
["update-types"] = new Job {
steps = new Listing {
common.checkout
new CommandStep {
name = "Update submodules"
run = """
git pull --recurse-submodules
git submodule update --remote --recursive type-generator/lemmy-js-client
"""
}
new ActionStep {
name = "Setup python"
uses = "actions/setup-python@v3"
with = new Mapping {
["python-version"] = "3.11"
}
}
new CommandStep {
name = "Install dependencies"
run = """
pip install -r requirements.txt
"""
}
new CommandStep {
name = "Build new types"
run = """
python type-generator/main.py
"""
}
new CommandStep {
id = "date"
name = "Get current date"
run = "echo \"::set-output name=date::$(date +'%Y%m%d-%s')\""
}
new ActionStep {
name = "Create pull request"
uses = "peter-evans/create-pull-request@v6"
with = new Mapping {
["branch"] = "update-types/feature/update-types-${{ steps.date.outputs.date }}"
["name"] = "Update types from source"
}
}
}
}
}.toMap().filter((k,v) -> v != null).toMapping()
34 changes: 34 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Update
'on':
schedule:
- cron: '* * * * Sun'
workflow_dispatch: {}
permissions:
contents: write
jobs:
update-types:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Update submodules
run: |-
git pull --recurse-submodules
git submodule update --remote --recursive type-generator/lemmy-js-client
- name: Setup python
uses: actions/setup-python@v3
with:
python-version: '3.11'
- name: Install dependencies
run: pip install -r requirements.txt
- name: Build new types
run: python type-generator/main.py
- id: date
name: Get current date
run: echo "::set-output name=date::$(date +'%Y%m%d-%s')"
- name: Create pull request
uses: peter-evans/create-pull-request@v6
with:
branch: update-types/feature/update-types-${{ steps.date.outputs.date }}
name: Update types from source
9 changes: 9 additions & 0 deletions .github/workflows/workflows.pkl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
amends "pkl/render.pkl"

workflows = new Listing {
(import("pkl/build.pkl")) {
projectName = "jlemmy"
}
import("pkl/test.pkl")
import("update-types.pkl")
}
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
Expand All @@ -23,5 +22,6 @@
hs_err_pid*

.idea/
.gradle/
.DS_Store
build/
.gradle/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "type-generator/lemmy-js-client"]
path = type-generator/lemmy-js-client
url = https://github.com/LemmyNet/lemmy-js-client.git
[submodule ".github/workflows/pkl"]
path = .github/workflows/pkl
url = git@github.com:ComposeComponents/actions-java.git
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

The MIT License (MIT)

Copyright (c) 2024 Ben McLean
Copyright (c) 2024 Emily McLean

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# jlemmy

A Java client for Lemmy
2 changes: 2 additions & 0 deletions build-pkl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pkl eval -m .github/workflows .github/workflows/workflows.pkl
pkl eval -f yaml -o gitversion.yml gitversion.pkl
35 changes: 34 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
plugins {
id 'java'
id 'net.thebugmc.gradle.sonatype-central-portal-publisher' version '1.2.3'
}

group = 'cl.emilym'
version = '1.0-SNAPSHOT'
description = "A Java Lemmy client"

repositories {
mavenCentral()
Expand All @@ -19,4 +20,36 @@ dependencies {

test {
useJUnitPlatform()
}

centralPortal {
username = findProperty("sonatypeUsername")
password = findProperty("sonatypePassword")
name = "jlemmy"
pom {
url = findProperty("pom.url")
licenses {
license {
name = findProperty("pom.license.name")
url = findProperty("pom.license.url")
}
}
developers {
developer {
name = findProperty("pom.developer.name")
email = findProperty("pom.developer.email")
}
}
scm {
connection = findProperty("pom.scm.connection")
developerConnection = findProperty("pom.scm.developerConnection")
url = findProperty("pom.scm.url")
}
}
}

signing {
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
}
1 change: 1 addition & 0 deletions gitversion.pkl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
amends "package://github.com/BenMMcLean/pkl-gitversion/releases/download/v0.1.1/pkl-gitversion@0.1.1#/default.pkl"
Loading

0 comments on commit ad5797e

Please sign in to comment.