Skip to content

Commit

Permalink
Reuse version workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Thodor12 committed Aug 21, 2024
1 parent 87ddcae commit 155f01e
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 73 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/gradle.build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ permissions:
contents: read

jobs:
compute-version:
name: Compute version
runs-on: ubuntu-latest
steps:
- uses: ldtteam/operapublicacreator/.github/workflows/gradle.version.yaml@${{ github.workflow_sha }}
with:
suffix: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || format('branch-{0}', steps.computeBranchSuffix.outputs.branch_suffix) }}

build:
runs-on: ubuntu-latest
steps:
Expand All @@ -39,4 +47,6 @@ jobs:

- id: build
name: "🏗️ Build"
run: ./gradlew --build-cache ${{ inputs.gradle_tasks }}
run: ./gradlew --build-cache ${{ inputs.gradle_tasks }}
env:
Version: "${{ needs.compute-version.outputs.version }}"
41 changes: 2 additions & 39 deletions .github/workflows/gradle.prerelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,47 +28,10 @@ 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]
- uses: ldtteam/operapublicacreator/.github/workflows/gradle.version.yaml@${{ github.workflow_sha }}
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) }}"
suffix: ${{ 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
Expand Down
37 changes: 4 additions & 33 deletions .github/workflows/gradle.publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,17 @@ on:
required: false
type: number
default: 100

secrets:
DISCORD_WEBHOOK:
required: true

MAVEN_USER:
required: true
MAVEN_PASSWORD:
required: true

CURSE_API_KEY:
required: true

CROWDIN_API_KEY:
required: true

GRADLE_ENCRYPTION_KEY:
required: true

Expand All @@ -51,37 +46,13 @@ 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: version
name: "🔢 Compute version"
uses: PaulHatch/[email protected]
- uses: ldtteam/operapublicacreator/.github/workflows/gradle.version.yaml@${{ github.workflow_sha }}
with:
tag_prefix: "v"
search_commit_body: true
debug: true
bump_each_commit: true
version_format: "${major}.${minor}.${patch}-${{ steps.minecraftVersion.outputs.minecraft_version }}-${{ inputs.curse_release_type }}"
suffix: ${{ inputs.curse_release_type }}

notify-build-start:
needs: ["compute-version"]
needs: [ "compute-version" ]
name: "🔴 Build notifications (start)"
runs-on: ubuntu-latest
steps:
Expand All @@ -104,7 +75,7 @@ jobs:
target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

gradle:
needs: ["compute-version"] # Make sure we now the version before starting to build
needs: [ "compute-version" ] # Make sure we now the version before starting to build
runs-on: ubuntu-latest
steps:
- id: checkout
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/gradle.version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Common Version Determination CI

on:
workflow_call:
inputs:
suffix:
description: "The suffix to finish the version string with"
required: false
type: string
default: ""
outputs:
version: ${{ jobs.compute-version.outputs.version }}
minecraft_version: ${{ jobs.compute-version.outputs.minecraft_version }}

permissions:
contents: read

jobs:
compute-version:
name: Compute version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
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 }}-${{ inputs.suffix }}"

0 comments on commit 155f01e

Please sign in to comment.