Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build task should actually build the application, not publish #13

Merged
merged 18 commits into from
Aug 23, 2024
Merged
80 changes: 6 additions & 74 deletions .github/workflows/gradle.build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,85 +10,25 @@ on:
type: string
default: "21"
gradle_tasks:
description: "The Gradle task(s) to run at publication"
description: "The Gradle task(s) to run for building"
required: false
type: string
default: "publish"
default: "assemble"
Thodor12 marked this conversation as resolved.
Show resolved Hide resolved
secrets:
CROWDIN_API_KEY:
required: true

GRADLE_ENCRYPTION_KEY:
required: true
description: The AES key to enable Gradle cache encryption
required: false
Thodor12 marked this conversation as resolved.
Show resolved Hide resolved

permissions:
contents: read
statuses: write
packages: write

jobs:
compute-version:
name: Compute version
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
version_tag: ${{ steps.version.outputs.version_tag }}
minecraft_version: ${{ steps.minecraftVersion.outputs.minecraft_version }}
steps:
- id: checkout
name: "📦 Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- id: minecraftVersion
name: "📦 Extract Minecraft version"
run: |
cat gradle.properties | grep exactMinecraftVersion | cut -d "=" -f 2 > minecraft_version.txt
echo "Minecraft version: $(cat minecraft_version.txt)"
echo "minecraft_version=$(cat minecraft_version.txt)" >> "$GITHUB_OUTPUT"

- id: computeBranchSuffix
name: "🔢 Compute branch suffix"
if: github.event_name == 'push'
run: |
gitRef="${{ github.ref }}"
branchName=$(echo "${gitRef/refs\/heads\//}")
echo "Branch name: $branchName"

cleanedBranchName=$(echo $branchName | sed 's/[^a-zA-Z0-9]/-/g')
echo "Cleaned branch name: $cleanedBranchName"

echo "branch_suffix=$cleanedBranchName" >> "$GITHUB_OUTPUT"

- id: version
name: "🔢 Compute version"
uses: PaulHatch/[email protected]
with:
tag_prefix: "v"
search_commit_body: true
debug: true
bump_each_commit: true
version_format: "${major}.${minor}.${patch}-${{ steps.minecraftVersion.outputs.minecraft_version }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || format('branch-{0}', steps.computeBranchSuffix.outputs.branch_suffix) }}"

gradle:
needs: ["compute-version"] # Make sure we now the version before starting to build
runs-on: ubuntu-latest
steps:
- id: checkout
name: "📦 Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 1000
fetch-tags: true

- id: setupJava
name: "🔧 Setup Java"
# https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#java
# language=bash
run: |
echo "JAVA_HOME=$(echo $JAVA_HOME_${{ inputs.java }}_X64)" >> "$GITHUB_ENV"
Thodor12 marked this conversation as resolved.
Show resolved Hide resolved

- id: setupGradle
name: "🔧 Setup Gradle"
Expand All @@ -99,12 +39,4 @@ jobs:

- id: build
name: "🏗️ Build"
run: ./gradlew --build-cache ${{ inputs.gradle_tasks }}
env:
crowdinKey: ${{ secrets.CROWDIN_API_KEY }}
Version: "${{ needs.compute-version.outputs.version }}"
GITHUB_TOKEN: ${{ github.token }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_USERNAME: ${{ github.actor }}


run: ./gradlew --build-cache ${{ inputs.gradle_tasks }}
Thodor12 marked this conversation as resolved.
Show resolved Hide resolved
105 changes: 105 additions & 0 deletions .github/workflows/gradle.prerelease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Based off https://github.com/MinecraftForge/SharedActions/blob/main/.github/workflows/gradle.yml
name: Gradle Pre-release CI

on:
workflow_call:
inputs:
java:
description: "The version of Java to use to run Gradle" # Note: Gradle's Java toolchains feature is used for compiling, which is separate from this
required: false
type: string
default: "21"
gradle_tasks:
description: "The Gradle task(s) to run for building"
required: false
type: string
default: "publish"
secrets:
GRADLE_ENCRYPTION_KEY:
description: The AES key to enable Gradle cache encryption
required: false

permissions:
contents: read
statuses: write
packages: write

jobs:
compute-version:
name: Compute version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
version_tag: ${{ steps.version.outputs.version_tag }}
minecraft_version: ${{ steps.minecraftVersion.outputs.minecraft_version }}
steps:
- id: checkout
name: "📦 Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- id: minecraftVersion
name: "📦 Extract Minecraft version"
run: |
cat gradle.properties | grep exactMinecraftVersion | cut -d "=" -f 2 > minecraft_version.txt
echo "Minecraft version: $(cat minecraft_version.txt)"
echo "minecraft_version=$(cat minecraft_version.txt)" >> "$GITHUB_OUTPUT"

- id: computeBranchSuffix
name: "🔢 Compute branch suffix"
if: github.event_name == 'push'
run: |
gitRef="${{ github.ref }}"
branchName=$(echo "${gitRef/refs\/heads\//}")
echo "Branch name: $branchName"

cleanedBranchName=$(echo $branchName | sed 's/[^a-zA-Z0-9]/-/g')
echo "Cleaned branch name: $cleanedBranchName"

echo "branch_suffix=$cleanedBranchName" >> "$GITHUB_OUTPUT"

- id: version
name: "🔢 Compute version"
uses: PaulHatch/[email protected]
with:
tag_prefix: "v"
search_commit_body: true
debug: true
bump_each_commit: true
version_format: "${{ steps.minecraftVersion.outputs.minecraft_version }}-${major}.${minor}.${patch}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || format('branch-{0}', steps.computeBranchSuffix.outputs.branch_suffix) }}"
Thodor12 marked this conversation as resolved.
Show resolved Hide resolved

gradle:
needs: [ "compute-version" ] # Make sure we now the version before starting to build
runs-on: ubuntu-latest
steps:
- id: checkout
name: "📦 Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 1000
fetch-tags: true

- id: setupJava
name: "🔧 Setup Java"
# https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#java
# language=bash
run: |
echo "JAVA_HOME=$(echo $JAVA_HOME_${{ inputs.java }}_X64)" >> "$GITHUB_ENV"

- id: setupGradle
name: "🔧 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: wrapper
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}

- id: build
name: "🏗️ Build"
run: ./gradlew --build-cache ${{ inputs.gradle_tasks }}
env:
Version: "${{ needs.compute-version.outputs.version }}"
GITHUB_TOKEN: ${{ github.token }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_USERNAME: ${{ github.actor }}
Thodor12 marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion .github/workflows/gradle.publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
search_commit_body: true
debug: true
bump_each_commit: true
version_format: "${major}.${minor}.${patch}-${{ steps.minecraftVersion.outputs.minecraft_version }}-${{ inputs.curse_release_type }}"
version_format: "${{ steps.minecraftVersion.outputs.minecraft_version }}-${major}.${minor}.${patch}-${{ inputs.curse_release_type }}"

notify-build-start:
needs: ["compute-version"]
Expand Down