Skip to content

Commit

Permalink
Update gradle_template.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyrobbrt authored Nov 1, 2023
1 parent e763597 commit 1f2c4fd
Showing 1 changed file with 61 additions and 15 deletions.
76 changes: 61 additions & 15 deletions .github/workflows/gradle_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@ on:
required: false
type: string
default: "17"
version_task:
description: "The Gradle task that outputs the version"
required: false
type: string
default: ""
pre_gradle_tasks:
description: "The Gradle task(s) to run pre-publication"
required: false
type: string
default: ""
gradle_tasks:
description: "The Gradle task(s) to run"
description: "The Gradle task(s) to run at publication"
required: false
type: string
default: "publish"
Expand Down Expand Up @@ -38,32 +48,62 @@ permissions:
statuses: write

jobs:
notify-build-start:
name: Build notifications (start)
compute-version:
name: Compute version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
version: ${{ inputs.version_task && steps.gradle.outputs.version || steps.version.outputs.version }}
steps:
- uses: matyrobbrt/actions-tag-versioning@v1
- uses: neoforged/action-tag-versioning@v1
name: Calculate version
id: version
if: ${{ !inputs.version_task }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: matyrobbrt/action-webhooks@v1
- uses: actions/checkout@v4
if: inputs.version_task
with:
fetch-depth: 1000
fetch-tags: true

- name: Make Gradle executable
# language=bash
run: chmod +x ./gradlew # Thanks Windows
if: inputs.version_task

- name: Setup Java ${{ inputs.java }}
if: inputs.version_task
# https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#java
# language=bash
run: export JAVA_HOME=$(echo $JAVA_HOME_${{ inputs.java }}_X64)

- name: Gradle version task
uses: gradle/gradle-build-action@v2
if: inputs.version_task
id: gradle
with:
arguments: ${{ inputs.version_task }}

notify-build-start:
needs: ["compute-version"]
name: Build notifications (start)
runs-on: ubuntu-latest
steps:
- uses: neoforged/action-webhooks@v1
name: Send Discord start notification
with:
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
status: 'started'
version: ${{ steps.version.outputs.version }}
version: ${{ needs.compute-version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: Sibz/github-status-action@v1
- uses: neoforged/action-github-status@v1
name: Set pending status
with:
authToken: ${{secrets.GITHUB_TOKEN}}
context: 'Publishing'
state: 'pending'
description: "Version: ${{ steps.version.outputs.version }}"
description: "Version: ${{ needs.compute-version.outputs.version }}"
target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

gradle:
Expand All @@ -83,6 +123,12 @@ jobs:
# language=bash
run: export JAVA_HOME=$(echo $JAVA_HOME_${{ inputs.java }}_X64)

- name: Gradle pre-publication tasks
uses: gradle/gradle-build-action@v2
if: inputs.pre_gradle_tasks
with:
arguments: ${{ inputs.pre_gradle_tasks }}

- name: Gradle ${{ inputs.gradle_tasks }}
uses: gradle/gradle-build-action@v2
with:
Expand All @@ -91,29 +137,29 @@ jobs:
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
GPG_KEY_PASSWORD: ${{ secrets.GPG_KEY_PASSWORD }}
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}

notify-build-end:
name: Build notifications (end)
needs: [ "notify-build-start", "gradle" ]
needs: [ "compute-version", "notify-build-start", "gradle" ]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- uses: matyrobbrt/action-webhooks@v1
- uses: neoforged/action-webhooks@v1
name: Send Discord end notification
with:
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
status: ${{ needs.gradle.result }}
version: ${{ needs.notify-build-start.outputs.version }}
version: ${{ needs.compute-version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: Sibz/github-status-action@v1
- uses: neoforged/action-github-status@v1
name: Set build status
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
context: 'Publishing'
state: ${{ needs.gradle.result }}
description: "Version: ${{ needs.notify-build-start.outputs.version }}"
description: "Version: ${{ needs.compute-version.outputs.version }}"
target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

0 comments on commit 1f2c4fd

Please sign in to comment.