Update build.gradle URLs (#175) #6
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release to Maven Central | |
| on: | |
| # Manual trigger | |
| workflow_dispatch: | |
| inputs: | |
| release_version: | |
| description: "Version to release (if empty, derive from project version)" | |
| required: false | |
| # Automatic trigger on pushing a version tag (e.g., "v1.2.3") | |
| push: | |
| tags: | |
| - "v*" | |
| jobs: | |
| # Corresponds to tests in tests.yml | |
| build-with-docker: | |
| name: Build ${{ matrix.dockcross-only }} (Dockcross) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest] | |
| java-distribution: [adopt] | |
| java-version: [8] | |
| dockcross-only: | |
| [ | |
| "android-arm", | |
| "android-arm64", | |
| "linux-arm64", | |
| "linux-armv5", | |
| "linux-armv7", | |
| "linux-s390x", | |
| "linux-ppc64le", | |
| "linux-x64", | |
| "linux-x86", | |
| "windows-static-x64", | |
| "windows-static-x86", | |
| ] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - uses: actions/setup-java@v2 | |
| with: | |
| distribution: "${{ matrix.java-distribution }}" | |
| java-version: "${{ matrix.java-version }}" | |
| - uses: gradle/actions/setup-gradle@v3 | |
| with: | |
| gradle-version: wrapper | |
| - uses: actions/cache@v4 | |
| id: gradle-cache | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Tests | |
| run: ./gradlew clean test -Ph3SystemPrune=true "-Ph3DockcrossOnly=${{ matrix.dockcross-only }}" | |
| env: | |
| OCI_EXE: docker | |
| - uses: actions/upload-artifact@v4 | |
| name: Upload artifacts | |
| with: | |
| name: docker-built-shared-objects-${{ matrix.dockcross-only }} | |
| path: | | |
| src/main/resources/*/*.so | |
| src/main/resources/*/*.dll | |
| if-no-files-found: error | |
| # Corresponsd to tests-no-docker in tests.yml | |
| build: | |
| name: Build ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [macos-latest] | |
| java-distribution: [adopt] | |
| java-version: [8] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - uses: actions/setup-java@v2 | |
| with: | |
| distribution: "${{ matrix.java-distribution }}" | |
| java-version: "${{ matrix.java-version }}" | |
| - uses: gradle/actions/setup-gradle@v3 | |
| with: | |
| gradle-version: wrapper | |
| - uses: actions/cache@v4 | |
| id: gradle-cache | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Tests | |
| run: ./gradlew clean test | |
| - uses: actions/upload-artifact@v4 | |
| name: Upload Mac OS Artifacts | |
| with: | |
| name: macos-built-shared-objects | |
| path: src/main/resources/*/*.dylib | |
| if-no-files-found: error | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # allow pushing commits/tags | |
| needs: | |
| - build-with-docker | |
| - build | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: "temurin" | |
| java-version: "21" | |
| - name: Determine release version | |
| id: vars | |
| run: | | |
| # Derive the release version (drop "-SNAPSHOT") from Gradle project or input | |
| VERSION_INPUT="${{ github.event.inputs.release_version || '' }}" | |
| if [ -n "$VERSION_INPUT" ]; then | |
| RELEASE_VERSION="$VERSION_INPUT" | |
| else | |
| RELEASE_VERSION=$(grep -E 'version=' gradle.properties | sed -E 's/version=//') | |
| fi | |
| echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV | |
| - name: Remove -SNAPSHOT suffix (prepare release version) | |
| if: ${{ github.event_name == 'workflow_dispatch' }} | |
| run: | | |
| sed -i -E "s/${RELEASE_VERSION}-SNAPSHOT/$RELEASE_VERSION/" gradle.properties || true | |
| git config user.name "github-actions" | |
| git config user.email "[email protected]" | |
| git commit -am "chore: release $RELEASE_VERSION [skip ci]" | |
| - name: Create Git tag for release | |
| if: ${{ github.event_name == 'workflow_dispatch' }} | |
| run: | | |
| git tag -a "v${RELEASE_VERSION}" -m "Release $RELEASE_VERSION" | |
| git push origin HEAD:master --follow-tags | |
| - name: Download Docker binaries | |
| uses: actions/[email protected] | |
| with: | |
| pattern: docker-built-shared-objects-* | |
| merge-multiple: true | |
| path: src/main/resources/ | |
| - name: Download Mac binaries | |
| uses: actions/[email protected] | |
| with: | |
| name: macos-built-shared-objects | |
| path: src/main/resources/ | |
| - name: Download and test | |
| run: | | |
| ./gradlew clean test assemble -Ph3GithubArtifactsUse=true -Ph3GithubArtifactsByRun=true | |
| - name: List files in jars | |
| run: | | |
| ls -lh build/libs | |
| for f in build/libs/*.jar; do | |
| echo "File: $f" | |
| unzip -l "$f" | |
| done | |
| - name: Publish to Sonatype OSSRH (Maven Central) | |
| env: | |
| SIGNING_KEY: ${{ secrets.SIGNING_KEY }} | |
| SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} | |
| SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} | |
| OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
| OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} | |
| OSSRH_STAGING_PROFILE_ID: ${{ secrets.OSSRH_STAGING_PROFILE_ID }} | |
| run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -Ph3GithubArtifactsUse=true -Ph3GithubArtifactsByRun=true | |
| - name: Create GitHub Release (with changelog notes) | |
| # This uses an action to create a release on GitHub | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: "v${{ env.RELEASE_VERSION }}" | |
| name: "${{ env.RELEASE_VERSION }}" | |
| body_path: CHANGELOG.md # assumes changelog contains latest release notes at top | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Bump to next snapshot version | |
| if: ${{ github.event_name != 'workflow_dispatch' }} | |
| run: | | |
| # Bump minor version (for example) and append -SNAPSHOT for continued development | |
| NEXT_VERSION=$(echo $RELEASE_VERSION | awk -F. -v OFS="." '{$NF += 1; print $0}') # increment last segment | |
| NEXT_VERSION="$NEXT_VERSION-SNAPSHOT" | |
| sed -i -E "s/$RELEASE_VERSION/$NEXT_VERSION/" gradle.properties || true | |
| git config user.name "github-actions" | |
| git config user.email "[email protected]" | |
| git commit -am "chore: start next development cycle $NEXT_VERSION [skip ci]" | |
| git push origin HEAD:master |