Skip to content

Commit d5cbcc1

Browse files
committed
first
0 parents  commit d5cbcc1

26 files changed

+1751
-0
lines changed

.gitattributes

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# Linux start script should use lf
5+
/gradlew text eol=lf
6+
7+
# These are Windows script files and should use crlf
8+
*.bat text eol=crlf
9+
10+
# Binary files should be left untouched
11+
*.jar binary
12+

.github/workflows/build.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Build and Publish
2+
3+
on:
4+
push:
5+
pull_request:
6+
release:
7+
types: [published]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
id-token: write
16+
pages: write
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v3
21+
22+
- name: Set up JDK 21
23+
uses: actions/setup-java@v3
24+
with:
25+
java-version: '21'
26+
distribution: 'temurin'
27+
cache: 'gradle'
28+
29+
- name: Grant execute permission for gradlew
30+
run: chmod +x gradlew
31+
32+
- name: Build
33+
if: github.event_name != 'pull_request'
34+
run: |
35+
export VERSION=""
36+
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
37+
export VERSION=${GITHUB_REF#refs/tags/}
38+
echo "Publishing release $VERSION"
39+
else
40+
echo "Publishing snapshot"
41+
fi
42+
export GITHUB_REGISTRY=${{ github.repository }}
43+
export GITHUB_USERNAME=${{ github.actor }}
44+
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
45+
./gradlew --no-daemon build javadoc
46+
47+
48+
- name: Publish Snapshot
49+
if: github.event_name != 'pull_request' && github.event_name != 'release'
50+
env:
51+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
52+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
53+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
54+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
55+
run: |
56+
./gradlew --no-daemon publishAllPublicationsToDistFolder publishToSonatype --info
57+
58+
- name: Publish Release
59+
if: github.event_name != 'pull_request' && github.event_name == 'release'
60+
env:
61+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
62+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
63+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
64+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
65+
run: |
66+
export VERSION=""
67+
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
68+
export VERSION=${GITHUB_REF#refs/tags/}
69+
echo "Publishing release $VERSION"
70+
fi
71+
./gradlew --no-daemon publishAllPublicationsToDistFolder publishToSonatype closeAndReleaseSonatypeStagingRepository --info
72+
73+
74+
- name: Upload build artifacts
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: build-artifacts
78+
path: dist
79+
80+
- name: Upload pages artifact
81+
uses: actions/upload-pages-artifact@v3
82+
with:
83+
path: 'dist/javadoc'
84+
85+
- name: Deploy to GitHub Pages
86+
if: github.event_name == 'release'
87+
id: deployment
88+
uses: actions/deploy-pages@v4
89+
90+
91+

.github/workflows/format.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Format Code
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
paths-ignore:
8+
- '.github/workflows/**'
9+
10+
jobs:
11+
format:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v3
19+
20+
- name: Set up JDK 21
21+
uses: actions/setup-java@v3
22+
with:
23+
java-version: '21'
24+
distribution: 'temurin'
25+
cache: 'gradle'
26+
27+
- name: Grant execute permission for gradlew
28+
run: chmod +x gradlew
29+
30+
- name: Format code with Spotless
31+
run: ./gradlew spotlessApply
32+
33+
- name: Check for changes
34+
id: git-check
35+
run: |
36+
git diff --exit-code || echo "changes=true" >> $GITHUB_OUTPUT
37+
38+
- name: Commit changes
39+
if: steps.git-check.outputs.changes == 'true'
40+
run: |
41+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
42+
git config --local user.name "GitHub Actions"
43+
git add --all
44+
git commit -m "[Automated] Code formatting with Spotless"
45+
git push

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Ignore Gradle project-specific cache directory
2+
.gradle
3+
4+
# Ignore Gradle build output directory
5+
build
6+
7+
**/bin
8+
dist

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"java.configuration.updateBuildConfiguration": "automatic"
3+
}

LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2025, Riccardo Balbo
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Bech32 for Java
2+
3+
A pure java implementation of the Bech32 encoding, that is heavily optimized to reduce memory copying and allocations.
4+
5+
6+
## Usage
7+
8+
```java
9+
ByteBuffer data = ...; // Your byte data
10+
byte hrp[] = "npub".getBytes(StandardCharsets.UTF_8); // hrp prefix you want to use
11+
12+
String encoded = Bech32.bech32Encode(hrp, data);
13+
System.out.println("Encoded: " + encoded);
14+
15+
ByteBuffer decoded = Bech32.bech32Decode(encoded);
16+
```

0 commit comments

Comments
 (0)