Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 50 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ on:
push:
tags:
- 'v*'
release:
types:
- published

jobs:
build-and-release:
runs-on: ubuntu-22.04
permissions:
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v7.0.1
Expand All @@ -20,7 +23,21 @@ jobs:

- name: Extract version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
env:
TAG_NAME: ${{ github.event.release.tag_name || github.ref_name }}
run: echo "VERSION=${TAG_NAME#v}" >> $GITHUB_OUTPUT

- name: Skip duplicate run (release created by this workflow)
id: skip_duplicate
env:
RELEASE_AUTHOR: ${{ github.event.release.author.login || '' }}
run: |
if [ "${{ github.event_name }}" = "release" ] && [ "$RELEASE_AUTHOR" = "github-actions[bot]" ]; then
echo "Release was created by the tag-push run itself - skipping duplicate publish"
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi

- name: Set version from tag
env:
Expand Down Expand Up @@ -48,6 +65,7 @@ jobs:
run: ./gradlew build --write-verification-metadata sha256

- name: Validate Maven Central credentials
if: steps.skip_duplicate.outputs.skip != 'true'
run: |
if [ -z "${{ secrets.MAVEN_CENTRAL_TOKEN }}" ]; then
echo "❌ MAVEN_CENTRAL_TOKEN secret is not set"
Expand All @@ -58,25 +76,30 @@ jobs:
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}

- name: Check curl version
if: steps.skip_duplicate.outputs.skip != 'true'
run: curl --version

- name: Publish to Maven Central
if: steps.skip_duplicate.outputs.skip != 'true'
run: ./gradlew publishToMavenCentral --write-verification-metadata sha256
env:
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

- name: Generate SBOM
if: steps.skip_duplicate.outputs.skip != 'true'
run: ./gradlew cyclonedxBom --write-verification-metadata sha256

- name: Update README version
if: steps.skip_duplicate.outputs.skip != 'true'
run: |
VERSION=${{ steps.get_version.outputs.VERSION }}
sed -i "s/jtoon:[0-9]\+\.[0-9]\+\.[0-9]\+/jtoon:$VERSION/g" README.md
sed -i "s/<version>[0-9]\+\.[0-9]\+\.[0-9]\+<\/version>/<version>$VERSION<\/version>/g" README.md

- name: Commit README and verification metadata changes
if: steps.skip_duplicate.outputs.skip != 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
Expand All @@ -86,25 +109,39 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create GitHub Release
uses: softprops/action-gh-release@v3.0.3
with:
files: |
build/libs/*.jar
build/reports/jtoon-bom.json
generate_release_notes: true
draft: false
prerelease: ${{ contains(steps.get_version.outputs.VERSION, '-') }}
- name: Create GitHub Release (if not exists)
if: steps.skip_duplicate.outputs.skip != 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="v${{ steps.get_version.outputs.VERSION }}"
if gh release view "$TAG" --json tagName >/dev/null 2>&1; then
echo "Release $TAG already exists - skipping creation"
else
ARGS=()
if [[ "${{ steps.get_version.outputs.VERSION }}" == *-* ]]; then
ARGS+=(--prerelease)
fi
gh release create "$TAG" --generate-notes "${ARGS[@]}"
fi

- name: Upload release assets
if: steps.skip_duplicate.outputs.skip != 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="v${{ steps.get_version.outputs.VERSION }}"
gh release upload "$TAG" build/libs/*.jar build/reports/jtoon-bom.json --clobber

- name: Generate JaCoCo Badge
if: steps.skip_duplicate.outputs.skip != 'true'
uses: cicirello/jacoco-badge-generator@v2.12.1
with:
generate-branches-badge: true
jacoco-csv-file: build/customJacocoReportDir/test/jacocoTestReport.csv

- name: Commit and push the badge
if: steps.skip_duplicate.outputs.skip != 'true'
uses: EndBug/add-and-commit@v11.1.1
with:
default_author: github_actions
Expand All @@ -120,4 +157,4 @@ jobs:
build/libs/*.jar
build/reports/tests/test/
build/reports/jtoon-bom.json
retention-days: 30
retention-days: 30
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ dependencies {
compileOnly 'com.github.spotbugs:spotbugs-annotations:4.10.4'

// NullAway + Error Prone for compile-time null safety
errorprone 'com.uber.nullaway:nullaway:0.14.0'
errorprone 'com.uber.nullaway:nullaway:0.14.1'
// Pin error_prone_core to 2.42.0 (Java 17 compatible; 2.50.0+ requires Java 21)
errorprone('com.google.errorprone:error_prone_core:2.42.0') {
version {
Expand Down
11 changes: 11 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,17 @@
<sha256 value="6eaa90b9d1890ffdaf895211a685a0b96f39474d540725b6cf89f3dc1b39da52" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.uber.nullaway" name="nullaway" version="0.14.1">
<artifact name="nullaway-0.14.1.jar">
<sha256 value="a74a5fb5a047537a4bdc362f9c1821279d7122d9d36aa2e6a72b79832fab7e4d" origin="Generated by Gradle"/>
</artifact>
<artifact name="nullaway-0.14.1.module">
<sha256 value="52ae1f985ea899afe54483c07588d13ab6b7ac15b5da8cbe80537a6ab26c4066" origin="Generated by Gradle"/>
</artifact>
<artifact name="nullaway-0.14.1.pom">
<sha256 value="206d23dc74b79418cad0f545ea77674a79588263909022d60abf9297b61e8c52" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="commons-beanutils" name="commons-beanutils" version="1.9.4">
<artifact name="commons-beanutils-1.9.4.jar">
<sha256 value="7d938c81789028045c08c065e94be75fc280527620d5bd62b519d5838532368a" origin="Generated by Gradle"/>
Expand Down
Loading