Compare commits
17 Commits
conflux@1.
...
release@1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
1e8fdb52dd
|
|||
|
3d2cf37a17
|
|||
|
e2d08d7b70
|
|||
|
e8e6a24065
|
|||
|
ad8c2a6752
|
|||
|
c2c1e26a7c
|
|||
|
5d8e533eff
|
|||
|
432b705327
|
|||
|
4968cc516d
|
|||
|
02cd2acd6e
|
|||
|
90d4e063af
|
|||
|
288fbfe0cc
|
|||
|
8172b1dbff
|
|||
|
c079f2a843
|
|||
|
7a97f94c39
|
|||
|
ae90e43a72
|
|||
|
6ebbbc80af
|
13
.classpath
13
.classpath
@@ -6,12 +6,6 @@
|
||||
<attribute name="gradle_used_by_scope" value="main,test"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="bin/main" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="gradle_scope" value="main"/>
|
||||
<attribute name="gradle_used_by_scope" value="main,test"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="bin/test" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="gradle_scope" value="test"/>
|
||||
@@ -19,13 +13,6 @@
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="bin/test" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="gradle_scope" value="test"/>
|
||||
<attribute name="gradle_used_by_scope" value="test"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21/"/>
|
||||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||
<classpathentry kind="output" path="bin/default"/>
|
||||
|
||||
89
.gitea/workflows/release.yml
Normal file
89
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,89 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'release@*'
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Java 21
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 21
|
||||
|
||||
- name: Cache Gradle
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-
|
||||
|
||||
- name: Build and publish to Gitea Maven
|
||||
run: ./gradlew clean publish --no-daemon -PgiteaToken=${{ secrets.CI_PUBLISH_TOKEN }}
|
||||
|
||||
- name: Upload built JAR
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: conflux
|
||||
path: build/libs/*.jar
|
||||
|
||||
- name: Generate release notes
|
||||
id: notes
|
||||
run: |
|
||||
current_tag="${{ github.ref_name }}"
|
||||
|
||||
# strip the prefix for sorting, keep prefix for matching
|
||||
prefix="release@"
|
||||
|
||||
# get all matching tags, strip prefix, sort them
|
||||
all_versions=$(git tag --list "${prefix}*" | sed "s/^${prefix}//" | sort -V)
|
||||
|
||||
# find previous version
|
||||
previous_tag=""
|
||||
for v in $all_versions; do
|
||||
if [[ "$prefix$v" == "$current_tag" ]]; then
|
||||
break
|
||||
fi
|
||||
previous_tag="$prefix$v"
|
||||
done
|
||||
|
||||
if [[ -z "$previous_tag" ]]; then
|
||||
range=""
|
||||
else
|
||||
range="$previous_tag..$current_tag"
|
||||
fi
|
||||
|
||||
echo "Comparing range: $range"
|
||||
|
||||
body="## What's New"
|
||||
|
||||
for category in "feat: Features" "fix: Bug Fixes" "docs: Documentation" "chore: Chores"; do
|
||||
prefix="${category%%:*}"
|
||||
title="${category##*: }"
|
||||
entries=$(git log $range --pretty=format:"- %s" --grep="^$prefix" --no-merges)
|
||||
# echo -e "Found:\n\n$entries\n\n"
|
||||
if [[ -n "$entries" ]]; then
|
||||
body="$body\n\n### $title\n$entries"
|
||||
fi
|
||||
done
|
||||
|
||||
echo -e "$body" > /tmp/release_notes.md
|
||||
|
||||
- name: Create Gitea Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: build/libs/*.jar
|
||||
body_path: /tmp/release_notes.md
|
||||
65
.gitea/workflows/tag.yml
Normal file
65
.gitea/workflows/tag.yml
Normal file
@@ -0,0 +1,65 @@
|
||||
name: Tag version
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
bump:
|
||||
description: "Which part to bump?"
|
||||
required: true
|
||||
default: "patch"
|
||||
type: choice
|
||||
options:
|
||||
- major
|
||||
- minor
|
||||
- patch
|
||||
|
||||
jobs:
|
||||
tag:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Configure git
|
||||
run: |
|
||||
echo "${{ secrets.CI_BOT_GPG_PRIVATE_KEY }}" | gpg --import --batch --yes
|
||||
# set trust non-interactively
|
||||
echo "${{ secrets.CI_BOT_GPG_FINGERPRINT }}:5:" | gpg --import-ownertrust
|
||||
git config --global user.signingkey $GPG_KEY_ID
|
||||
git config --global commit.gpgSign true
|
||||
git config --global tag.gpgSign true
|
||||
git config user.name "Gitea CI"
|
||||
git config user.email "gitea-ci@hq.egothor.org"
|
||||
git remote set-url origin https://ci-bot:${GITEA_PUSH_TOKEN}@gitea.egothor.org/Egothor/conflux.git
|
||||
env:
|
||||
GITEA_PUSH_TOKEN: ${{ secrets.CI_PUSH_TOKEN }}
|
||||
GPG_KEY_ID: ${{ secrets.CI_BOT_GPG_KEY_ID }}
|
||||
|
||||
- name: Bump version and tag
|
||||
run: |
|
||||
latest=$(git tag --list 'conflux@*' | sed 's/conflux@//' | sort -V | tail -n 1)
|
||||
if [[ -z "$latest" ]]; then
|
||||
latest="0.0.0"
|
||||
fi
|
||||
echo "Latest: $latest"
|
||||
IFS='.' read -r major minor patch <<<"$latest"
|
||||
case "${{ github.event.inputs.bump }}" in
|
||||
major)
|
||||
major=$((major+1)); minor=0; patch=0 ;;
|
||||
minor)
|
||||
minor=$((minor+1)); patch=0 ;;
|
||||
patch)
|
||||
patch=$((patch+1)) ;;
|
||||
*)
|
||||
echo "Invalid bump type"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
next="$major.$minor.$patch"
|
||||
new_tag="conflux@$next"
|
||||
git tag -s $new_tag -m "Release $new_tag"
|
||||
git push origin $new_tag
|
||||
echo "Tagged $new_tag"
|
||||
@@ -8,7 +8,7 @@ values and react to their changes in a clean and decoupled way.
|
||||
|
||||
## Key Features
|
||||
|
||||
- Shared context for storing and retrieving named values
|
||||
- Publish/subscribe event bus for listening to value changes
|
||||
- Simple API for easy integration into existing projects
|
||||
- Enables modular design by decoupling components through events
|
||||
- Shared context for storing and retrieving named values
|
||||
- Publish/subscribe event bus for listening to value changes
|
||||
- Simple API for easy integration into existing projects
|
||||
- Enables modular design by decoupling components through events
|
||||
|
||||
47
build.gradle
47
build.gradle
@@ -6,7 +6,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'org.egothor'
|
||||
version gitVersion(prefix:'conflux@')
|
||||
version gitVersion(prefix:'release@')
|
||||
|
||||
repositories {
|
||||
// Use Maven Central for resolving dependencies.
|
||||
@@ -25,6 +25,9 @@ java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(21)
|
||||
}
|
||||
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
javadoc {
|
||||
@@ -36,27 +39,35 @@ tasks.named('test') {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
name = "GiteaMaven"
|
||||
url = uri("https://gitea.egothor.org/api/packages/Egothor/maven")
|
||||
|
||||
credentials(HttpHeaderCredentials) {
|
||||
name = "Authorization"
|
||||
value = "token ${giteaToken}"
|
||||
}
|
||||
tasks.withType(Javadoc).configureEach {
|
||||
options.bottom = "Copyright © 2025 Egothor"
|
||||
}
|
||||
|
||||
authentication {
|
||||
header(HttpHeaderAuthentication)
|
||||
if (project.hasProperty('giteaToken') && project.giteaToken) {
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
name = "GiteaMaven"
|
||||
url = uri("https://gitea.egothor.org/api/packages/Egothor/maven")
|
||||
|
||||
credentials(HttpHeaderCredentials) {
|
||||
name = "Authorization"
|
||||
value = "token ${giteaToken}"
|
||||
}
|
||||
|
||||
authentication {
|
||||
header(HttpHeaderAuthentication)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
println "No giteaToken defined - skipping publishing configuration"
|
||||
}
|
||||
|
||||
gradle.taskGraph.whenReady { taskGraph ->
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
# This file was generated by the Gradle 'init' task.
|
||||
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format
|
||||
|
||||
[versions]
|
||||
commons-math3 = "3.6.1"
|
||||
guava = "33.1.0-jre"
|
||||
junit-jupiter = "5.10.2"
|
||||
|
||||
[libraries]
|
||||
commons-math3 = { module = "org.apache.commons:commons-math3", version.ref = "commons-math3" }
|
||||
guava = { module = "com.google.guava:guava", version.ref = "guava" }
|
||||
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }
|
||||
|
||||
@@ -57,7 +57,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
* Usage:
|
||||
*
|
||||
* <pre>
|
||||
* Key<Integer> COUNT = Key.of("count", Integer.class);
|
||||
* Key<Integer> COUNT = Key.of("count", Integer.class);
|
||||
* Ctx.INSTANCE.put(COUNT, 42);
|
||||
* int v = Ctx.INSTANCE.get(COUNT);
|
||||
* </pre>
|
||||
|
||||
32
src/main/java/conflux/package-info.java
Normal file
32
src/main/java/conflux/package-info.java
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Provides a lightweight, type-safe, application-wide context mechanism for
|
||||
* sharing strongly typed data among otherwise decoupled classes.
|
||||
* <p>
|
||||
* The {@link conflux.Ctx} class acts as a central, generic context storage
|
||||
* supporting key-based put/get operations. Each {@link conflux.Key} defines a
|
||||
* unique, strongly typed entry in the context, ensuring type consistency and
|
||||
* preventing misuse. {@link conflux.Listener} interfaces allow clients to
|
||||
* observe value changes for specific keys. Listeners are held with weak
|
||||
* references to avoid memory leaks.
|
||||
* <p>
|
||||
* Typical usage involves defining {@link conflux.Key} instances with explicit
|
||||
* types, storing values through {@code Ctx.INSTANCE.put()}, and retrieving them
|
||||
* with {@code Ctx.INSTANCE.get()}. Listeners can be attached via
|
||||
* {@code Ctx.INSTANCE.addListener()} to react to context changes in a decoupled
|
||||
* and thread-safe manner. Values and listeners can be removed individually or
|
||||
* the entire context can be cleared.
|
||||
* <p>
|
||||
* <b>Best Practices:</b>
|
||||
* <ul>
|
||||
* <li>Define keys as constants to maintain consistency and avoid
|
||||
* collisions.</li>
|
||||
* <li>Remove listeners when no longer needed (although weak references help
|
||||
* prevent leaks).</li>
|
||||
* <li>Use unique key names to ensure no accidental type conflicts.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @see conflux.Ctx
|
||||
* @see conflux.Key
|
||||
* @see conflux.Listener
|
||||
*/
|
||||
package conflux;
|
||||
Reference in New Issue
Block a user