Skip to content
67 changes: 56 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,81 @@

# 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?

- name: Fetch git tags # Required for axion-release-plugin
run: git fetch --tags

- 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

- name: Get current version
id: version
run: echo "::set-output name=version::$(./gradlew -q -Prelease.quiet currentVersion)"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment before this step to explain its purpose & functionality. Is this sufficient?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good starting point for the reason, but there should also be some info about the concrete syntax (::set-output name=version::). If you have a link which describes this, a link with a hint that it describes the syntax is sufficient.


# TODO: Create Github release

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

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

- name: Fetch git tags # Required for axion-release-plugin
run: git fetch --tags

- 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 }}
21 changes: 13 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,37 @@
# 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

- name: Fetch git tags # Required for axion-release-plugin
run: git fetch --tags

- 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 }}
33 changes: 19 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@
# 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: Setup Gradle
Comment thread
Zero3141 marked this conversation as resolved.
uses: gradle/gradle-build-action@v2.7.0

- name: Build with Gradle
run: ./gradlew build