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
64 changes: 53 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,78 @@

# This workflow will publish a Java project with Gradle
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-java-packages-with-gradle
# Inspired by https://github.com/dzikoysk/reposilite/blob/main/.github/workflows/publish-release.yml

name: Publish Release to Maven Central
name: Publish Release

on:
release:
types: [published]
on: workflow_dispatch

jobs:
build:

github:
runs-on: ubuntu-22.04
permissions:
contents: write
outputs:
version: ${{ steps.version.outputs.version }}
steps:

- name: Checkout repository
uses: actions/checkout@v3 # TODO: with... bot?
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: adopt

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1.1.0

- name: Setup Gradle
uses: gradle/gradle-build-action@v2.7.0

- name: Release new version
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
./gradlew release

# The previous "Release new version" step increases the version. We need this version for the publishing job. The
# currentVersion command gets this value, which we store in the "version" variable for following jobs.
- name: Get current version
id: version
run: echo "version=$(./gradlew -q -Prelease.quiet currentVersion)" >> "$VERSION"

maven:
runs-on: ubuntu-22.04
needs: [ github ]
steps:
- uses: actions/checkout@v3

- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: refs/tags/${{ needs.github.outputs.VERSION }}

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: adopt

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1.1.0

- name: Setup Gradle
uses: gradle/gradle-build-action@v2.7.0
- name: Mark next version
run: ./gradlew markNextVersion -Prelease.version=${{ github.event.release.tag_name }}
- name: Release
run: ./gradlew release

- name: Publish to Maven Central
run: ./gradlew publish
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
DD_CLIENT_VERSION: ${{ github.event.release.tag_name }}
20 changes: 12 additions & 8 deletions .github/workflows/ci.yml → .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,36 @@
# For gradle wrapper validation see: https://github.com/marketplace/actions/gradle-wrapper-validation
# For gradle build see: https://github.com/marketplace/actions/gradle-build-action

name: Publish Snapshot to Maven Central
name: Publish Snapshot

on:
push:
branches:
- 'main'
branches: ['main']

jobs:
build:
publish-snapshot:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: adopt

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1.1.0

- name: Setup Gradle
uses: gradle/gradle-build-action@v2.7.0
- name: Release
run: ./gradlew release

- name: Publish to Maven Central
run: ./gradlew publish
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
DD_CLIENT_VERSION: ${{ github.event.release.tag_name }}
36 changes: 22 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,27 @@
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Java Tests
on: push
on: [pull_request, push, workflow_dispatch]

jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: adopt
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
test:
runs-on: ubuntu-22.04
steps:

- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: adopt

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1.1.0

- name: Setup Gradle
uses: gradle/gradle-build-action@v2.7.0

- name: Build with Gradle
run: ./gradlew build
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {
// https://github.com/ben-manes/gradle-versions-plugin
// Run: ./gradlew dependencyUpdates -Drevision=release
id "com.github.ben-manes.versions" version "0.47.0"
id 'pl.allegro.tech.build.axion-release' version '1.15.1'
id 'pl.allegro.tech.build.axion-release' version '1.15.4'
}

group 'io.securecodebox'
Expand Down