Documentation updates and allowing for no-publish workflows. #2
3 changed files with 109 additions and 18 deletions
|
@ -34,12 +34,21 @@ jobs:
|
||||||
export GS_RELEASE_TYPE="minor"
|
export GS_RELEASE_TYPE="minor"
|
||||||
elif [[ "$latest_commit_message" == *"(patch)"* ]]; then
|
elif [[ "$latest_commit_message" == *"(patch)"* ]]; then
|
||||||
export GS_RELEASE_TYPE="patch"
|
export GS_RELEASE_TYPE="patch"
|
||||||
|
elif [[ "$latest_commit_message" == *"(docs)"* ]]; then
|
||||||
|
export GS_RELEASE_TYPE="norelease"
|
||||||
|
elif [[ "$latest_commit_message" == *"(norelease)"* ]]; then
|
||||||
|
export GS_RELEASE_TYPE="norelease"
|
||||||
else
|
else
|
||||||
export GS_RELEASE_TYPE="patch"
|
export GS_RELEASE_TYPE="norelease"
|
||||||
fi
|
fi
|
||||||
|
echo "GS_RELEASE_TYPE=$GS_RELEASE_TYPE" >> $GITHUB_ENV
|
||||||
echo "Previous Git Tag: $latest_git_tag"
|
echo "Previous Git Tag: $latest_git_tag"
|
||||||
echo "Latest Commit: $latest_commit_message ($GS_RELEASE_TYPE) (SNAPSHOT)"
|
echo "Latest Commit: $latest_commit_message ($GS_RELEASE_TYPE) (SNAPSHOT)"
|
||||||
sbtn -Dsnapshot=true -Drelease="$GS_RELEASE_TYPE" semVerInfo
|
if [ "$GS_RELEASE_TYPE" = "norelease" ]; then
|
||||||
|
sbtn -Dsnapshot=true -Drelease="patch" semVerInfo
|
||||||
|
else
|
||||||
|
sbtn -Dsnapshot=true -Drelease="$GS_RELEASE_TYPE" semVerInfo
|
||||||
|
fi
|
||||||
- name: 'Unit Tests and Code Coverage'
|
- name: 'Unit Tests and Code Coverage'
|
||||||
run: |
|
run: |
|
||||||
sbtn clean
|
sbtn clean
|
||||||
|
@ -48,5 +57,10 @@ jobs:
|
||||||
sbtn coverageReport
|
sbtn coverageReport
|
||||||
- name: 'Publish Snapshot'
|
- name: 'Publish Snapshot'
|
||||||
run: |
|
run: |
|
||||||
sbtn clean
|
echo "Testing env var propagation = ${{ env.GS_RELEASE_TYPE }}"
|
||||||
sbtn publish
|
if [ "${{ env.GS_RELEASE_TYPE }}" = "norelease" ]; then
|
||||||
|
echo "Skipping publish due to GS_RELEASE_TYPE=norelease"
|
||||||
|
else
|
||||||
|
sbtn clean
|
||||||
|
sbtn publish
|
||||||
|
fi
|
||||||
|
|
|
@ -35,26 +35,49 @@ jobs:
|
||||||
export GS_RELEASE_TYPE="minor"
|
export GS_RELEASE_TYPE="minor"
|
||||||
elif [[ "$latest_commit_message" == *"(patch)"* ]]; then
|
elif [[ "$latest_commit_message" == *"(patch)"* ]]; then
|
||||||
export GS_RELEASE_TYPE="patch"
|
export GS_RELEASE_TYPE="patch"
|
||||||
|
elif [[ "$latest_commit_message" == *"(docs)"* ]]; then
|
||||||
|
export GS_RELEASE_TYPE="norelease"
|
||||||
|
elif [[ "$latest_commit_message" == *"(norelease)"* ]]; then
|
||||||
|
export GS_RELEASE_TYPE="norelease"
|
||||||
else
|
else
|
||||||
export GS_RELEASE_TYPE="patch"
|
export GS_RELEASE_TYPE="norelease"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "GS_RELEASE_TYPE=$GS_RELEASE_TYPE" >> $GITHUB_ENV
|
||||||
echo "Previous Git Tag: $latest_git_tag"
|
echo "Previous Git Tag: $latest_git_tag"
|
||||||
echo "Latest Commit: $latest_commit_message"
|
echo "Latest Commit: $latest_commit_message"
|
||||||
echo "Selected Release Type: '$GS_RELEASE_TYPE'"
|
echo "Selected Release Type: '$GS_RELEASE_TYPE'"
|
||||||
sbtn -Drelease="$GS_RELEASE_TYPE" semVerInfo
|
|
||||||
|
if [ "$GS_RELEASE_TYPE" = "norelease" ]; then
|
||||||
|
echo "Skipping all versioning for 'norelease' commit."
|
||||||
|
else
|
||||||
|
sbtn -Drelease="$GS_RELEASE_TYPE" semVerInfo
|
||||||
|
fi
|
||||||
- name: 'Unit Tests and Code Coverage'
|
- name: 'Unit Tests and Code Coverage'
|
||||||
run: |
|
run: |
|
||||||
sbtn clean
|
if [ "${{ env.GS_RELEASE_TYPE }}" = "norelease" ]; then
|
||||||
sbtn coverage
|
echo "Skipping build/test for 'norelease' commit."
|
||||||
sbtn test
|
else
|
||||||
sbtn coverageReport
|
sbtn clean
|
||||||
|
sbtn coverage
|
||||||
|
sbtn test
|
||||||
|
sbtn coverageReport
|
||||||
|
fi
|
||||||
- name: 'Publish Release'
|
- name: 'Publish Release'
|
||||||
run: |
|
run: |
|
||||||
sbtn clean
|
if [ "${{ env.GS_RELEASE_TYPE }}" = "norelease" ]; then
|
||||||
sbtn semVerWriteVersionToFile
|
echo "Skipping publish for 'norelease' commit."
|
||||||
sbtn publish
|
else
|
||||||
|
sbtn clean
|
||||||
|
sbtn semVerWriteVersionToFile
|
||||||
|
sbtn publish
|
||||||
|
fi
|
||||||
- name: 'Create Git Tag'
|
- name: 'Create Git Tag'
|
||||||
run: |
|
run: |
|
||||||
selected_version="$(cat .version)"
|
if [ "${{ env.GS_RELEASE_TYPE }}" = "norelease" ]; then
|
||||||
git tag "$selected_version"
|
echo "Skipping Git tag for 'norelease' commit."
|
||||||
git push origin "$selected_version"
|
else
|
||||||
|
selected_version="$(cat .version)"
|
||||||
|
git tag "$selected_version"
|
||||||
|
git push origin "$selected_version"
|
||||||
|
fi
|
||||||
|
|
58
README.md
58
README.md
|
@ -1,13 +1,20 @@
|
||||||
# gs-hex
|
# gs-hex
|
||||||
|
|
||||||
[License (Apache 2.0)](./LICENSE)
|
[GS Open Source](https://garrity.co/oss.html) |
|
||||||
|
[License (MIT)](./LICENSE)
|
||||||
|
|
||||||
Hexadecimal conversions for Scala 3. Provides support for standard types.
|
Hexadecimal conversions for Scala 3. Provides support for standard types.
|
||||||
|
|
||||||
- [Usage](#usage)
|
- [Usage](#usage)
|
||||||
|
- [Dependency](#dependency)
|
||||||
|
- [Byte Array Conversion](#byte-array-conversion)
|
||||||
|
- [Type Classes](#type-classes)
|
||||||
|
- [Donate](#donate)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
### Dependency
|
||||||
|
|
||||||
This artifact is available in the Garrity Software Maven repository.
|
This artifact is available in the Garrity Software Maven repository.
|
||||||
|
|
||||||
```scala
|
```scala
|
||||||
|
@ -15,5 +22,52 @@ externalResolvers +=
|
||||||
"Garrity Software Releases" at "https://maven.garrity.co/releases"
|
"Garrity Software Releases" at "https://maven.garrity.co/releases"
|
||||||
|
|
||||||
val GsHex: ModuleID =
|
val GsHex: ModuleID =
|
||||||
"gs" %% "gs-hex-v0" % "0.1.0"
|
"gs" %% "gs-hex-v0" % "$VERSION"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Byte Array Conversion
|
||||||
|
|
||||||
|
This library is based on two functions: `Hex.toHexString(Array[Byte])` and
|
||||||
|
`Hex.fromHexString(String)`.
|
||||||
|
|
||||||
|
```scala
|
||||||
|
import gs.hex.v0.Hex
|
||||||
|
|
||||||
|
val data: Array[Byte] = ???
|
||||||
|
val encoded: String = Hex.toHexString(data)
|
||||||
|
val decoded: Option[Array[Byte]] = Hex.fromHexString(encoded)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Type Classes
|
||||||
|
|
||||||
|
This library provides `HexEncode[A]` and `HexDecode[A]` for encoding and
|
||||||
|
decoding arbitrary types as Hexadecimal strings. The types `Array[Byte]`,
|
||||||
|
`String`, `Boolean`, `Int` and `Long` are supported by default.
|
||||||
|
|
||||||
|
#### Example Type Class Implementations
|
||||||
|
|
||||||
|
```scala
|
||||||
|
given HexEncode[Array[Byte]] = new HexEncode[Array[Byte]] {
|
||||||
|
def toHexString(data: Array[Byte]): String = Hex.toHexString(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
given HexDecode[Array[Byte]] = new HexDecode[Array[Byte]] {
|
||||||
|
def fromHexString(data: String): Option[Array[Byte]] =
|
||||||
|
Hex.fromHexString(data)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Example Type Class Usage
|
||||||
|
|
||||||
|
```scala
|
||||||
|
def encode[A](data: A)(using HexEncode[A]): String =
|
||||||
|
data.toHex()
|
||||||
|
|
||||||
|
def decode[A](data: String)(using HexDecode[A]): Option[A] =
|
||||||
|
data.fromHex()
|
||||||
|
```
|
||||||
|
|
||||||
|
## Donate
|
||||||
|
|
||||||
|
Enjoy this project or want to help me achieve my [goals](https://garrity.co)?
|
||||||
|
Consider [Donating to Pat on Ko-fi](https://ko-fi.com/gspfm).
|
||||||
|
|
Loading…
Add table
Reference in a new issue