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

Fix changelog merging across MC versions #19

Merged
merged 26 commits into from
Aug 28, 2024
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
36 changes: 23 additions & 13 deletions .github/workflows/gradle.build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,33 @@ permissions:
contents: read

jobs:
generate-build-information:
name: "Generate build information"
runs-on: ubuntu-latest
outputs:
branch_suffix: ${{ steps.computeBranchSuffix.outputs.branch_suffix }}
steps:
- id: computeBranchSuffix
name: "🔢 Compute branch suffix"
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"

compute-version:
needs: [ "generate-build-information" ]
uses: ./.github/workflows/gradle.version.yaml
with:
suffix: ${{ needs.generate-build-information.outputs.branch_suffix }}

build:
needs: [ "compute-version" ]
name: "🏗️ Build"
runs-on: ubuntu-latest
steps:
- id: checkout
Expand All @@ -46,18 +68,6 @@ jobs:
gradle-version: wrapper
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}

- id: computeBranchSuffix
name: "🔢 Compute branch suffix"
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: build
name: "🏗️ Build"
run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} -PmodVersion=${{ needs.compute-version.outputs.version }} -PmodVersionSuffix=${{ steps.computeBranchSuffix.outputs.branch_suffix }}
run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} -PmodVersion=${{ needs.compute-version.outputs.mod_version }} -PmodVersionSuffix=${{ needs.compute_version.outputs.suffix }}
4 changes: 3 additions & 1 deletion .github/workflows/gradle.prerelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ permissions:
jobs:
compute-version:
uses: ./.github/workflows/gradle.version.yaml
with:
suffix: rc

gradle:
needs: [ "compute-version" ]
Expand All @@ -55,7 +57,7 @@ jobs:

- id: build
name: "🏗️ Build"
run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} -PmodVersion=${{ needs.compute-version.outputs.version }} -PmodVersionSuffix=rc
run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} -PmodVersion=${{ needs.compute-version.outputs.mod_version }} -PmodVersionSuffix=${{ needs.compute-version.outputs.suffix }}
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_REPOSITORY: ${{ github.repository }}
Expand Down
55 changes: 33 additions & 22 deletions .github/workflows/gradle.publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,29 @@ permissions:
statuses: write

jobs:
generate-release-information:
name: "Generate release information"
runs-on: ubuntu-latest
outputs:
release_version_suffix: ${{ steps.generateReleaseSuffix.outputs.release_version_suffix }}
steps:
- id: generateReleaseSuffix
name: "Generate release suffix"
run: |
release_version_suffix="alpha"
if [[ ${{ inputs.curse_release_type }} == release ]]; then
release_version_suffix=""
elif [[ ${{ inputs.curse_release_type }} == beta ]]; then
release_version_suffix="snapshot"
fi
echo "Release version suffix: ${release_version_suffix}"
echo "release_version_suffix=${release_version_suffix}" >> "$GITHUB_OUTPUT"

compute-version:
needs: [ "generate-release-information" ]
uses: ./.github/workflows/gradle.version.yaml
with:
suffix: ${{ needs.generate-release-information.outputs.release_version_suffix }}

notify-build-start:
needs: [ "compute-version" ]
Expand All @@ -57,7 +78,7 @@ jobs:
with:
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
status: 'started'
version: "${{ needs.compute-version.outputs.version }}"
version: "${{ needs.compute-version.outputs.full_version }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -67,7 +88,7 @@ jobs:
authToken: ${{secrets.GITHUB_TOKEN}}
context: 'Publishing'
state: 'pending'
description: "Version: ${{ needs.compute-version.outputs.version }}"
description: ${{ needs.compute-version.outputs.release_text }}
target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

gradle:
Expand Down Expand Up @@ -99,33 +120,23 @@ jobs:
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git tag -a ${{ needs.compute-version.outputs.version }} -m "Version ${{ needs.compute-version.outputs.version }}"
git tag -a "${{ needs.compute-version.outputs.tag_version }}" -m "${{ needs.compute-version.outputs.release_text }}"

- id: generate-release-changelog
- id: generateReleaseChangelog
name: "📝 Generate release changelog"
uses: heinrichreimer/[email protected]
with:
output: changelog.md
token: ${{ secrets.GITHUB_TOKEN }}
stripGeneratorNotice: "true"
onlyLastTag: true
dueTag: ${{ needs.compute-version.outputs.tag_version }}
excludeTagsRegex: ${{ needs.compute-version.outputs.tag_regex }}
maxIssues: ${{ inputs.changelog_max_issues }}

- id: generate-release-suffix
name: "Generate release suffix"
run: |
release_version_suffix="alpha"
if [[ ${{ inputs.curse_release_type }} == release ]]; then
release_version_suffix=""
elif [[ ${{ inputs.curse_release_type }} == beta ]]; then
release_version_suffix="snapshot"
fi
echo "Release version suffix: ${release_version_suffix}"
echo "release_version_suffix=${release_version_suffix}" >> "$GITHUB_OUTPUT"

- id: publish
name: "🚀 Publish"
run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} -PmodVersion=${{ needs.compute-version.outputs.version }} -PmodVersionSuffix=${{ steps.generate-release-suffix.outputs.release_version_suffix }}
run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} -PmodVersion=${{ needs.compute-version.outputs.mod_version }} -PmodVersionSuffix=${{ needs.compute-version.outputs.suffix }}
env:
LDTTeamJfrogUsername: ${{ secrets.MAVEN_USER }}
LDTTeamJfrogPassword: ${{ secrets.MAVEN_PASSWORD }}
Expand All @@ -138,14 +149,14 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.compute-version.outputs.version }}
release_name: "Release ${{ needs.compute-version.outputs.version }}"
tag_name: ${{ needs.compute-version.outputs.tag_version }}
release_name: ${{ needs.compute-version.outputs.release_text }}
body_path: changelog.md
prerelease: ${{ inputs.curse_release_type != 'release' }}

notify-build-end:
name: Build notifications (end)
needs: [ "compute-version", "notify-build-start", "gradle" ]
name: "🔴 Build notifications (end)"
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
Expand All @@ -154,7 +165,7 @@ jobs:
with:
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
status: ${{ needs.gradle.result }}
version: "${{ needs.compute-version.outputs.version }}"
version: "${{ needs.compute-version.outputs.full_version }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: neoforged/action-github-status@v1
Expand All @@ -163,5 +174,5 @@ jobs:
authToken: ${{ secrets.GITHUB_TOKEN }}
context: 'Publishing'
state: ${{ needs.gradle.result }}
description: "Version: ${{ needs.compute-version.outputs.version }}"
description: ${{ needs.compute-version.outputs.release_text }}
target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
82 changes: 73 additions & 9 deletions .github/workflows/gradle.version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,32 @@ name: Common Version Determination CI

on:
workflow_call:
inputs:
suffix:
description: "The release suffix"
type: string
outputs:
version:
description: "The computed version"
value: ${{ jobs.compute-version.outputs.version }}
minecraft_version:
description: "The minecraft version"
value: ${{ jobs.compute-version.outputs.minecraft_version }}
mod_version:
description: "The mod version"
value: ${{ jobs.compute-version.outputs.mod_version }}
suffix:
description: "The input suffix"
value: ${{ inputs.suffix }}
full_version:
description: "The full version string"
value: ${{ jobs.compute-version.outputs.full_version }}
tag_version:
description: "The version that the tag should get"
value: ${{ jobs.compute-version.outputs.tag_version }}
tag_regex:
description: "The regex for matching identical version tags"
value: ${{ jobs.compute-version.outputs.tag_regex }}
release_text:
description: "The text for the release version"
value: ${{ jobs.compute-version.outputs.release_text }}

permissions:
contents: read
Expand All @@ -14,21 +36,63 @@ jobs:
compute-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
minecraft_version: ${{ steps.generateMinecraftVersion.outputs.minecraft_version }}
mod_version: ${{ steps.generateModVersion.outputs.version }}
full_version: ${{ steps.generateFullVersion.outputs.full_version }}
tag_version: ${{ steps.generateTagVersion.outputs.tag_version }}
tag_regex: ${{ steps.generateTagRegex.outputs.tag_regex }}
release_text: ${{ steps.generateReleaseText.outputs.release_text }}
steps:
- id: checkout
name: "📦 Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-depth: 1000
Copy link
Member

Choose a reason for hiding this comment

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

At Orion: i think we can lower this something more sensible like 100? (not sure where 1k comes from, but iirc neo has changelog generation since fixed version so that's why)

fetch-tags: true

- id: version
name: "🔢 Compute version"
- id: generateMinecraftVersion
name: "Generate 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: generateModVersion
name: "Generate mod version"
uses: PaulHatch/[email protected]
with:
tag_prefix: "v"
tag_prefix: "v${{ steps.generateMinecraftVersion.outputs.minecraft_version }}-"
search_commit_body: true
debug: true
Copy link
Member

Choose a reason for hiding this comment

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

do we need debug for this? isnt that linked to running action in debug mode?

bump_each_commit: true
version_format: "${major}.${minor}.${patch}"
version_format: "${major}.${minor}.${patch}"

- id: generateFullVersion
name: "Generate full version"
run: |
full_version="${{ steps.generateModVersion.outputs.version }}-${{ steps.generateMinecraftVersion.outputs.minecraft_version }}-${{ inputs.suffix }}"
echo "Full version: ${full_version}"
echo "full_version=${full_version}" >> "$GITHUB_OUTPUT"

- id: generateTagVersion
name: "Generate tag version"
run: |
tag_version="v${{ steps.generateMinecraftVersion.outputs.minecraft_version }}-${{ steps.generateModVersion.outputs.version }}"
echo "Tag version: ${tag_version}"
echo "tag_version=${tag_version}" >> "$GITHUB_OUTPUT"

- id: generateTagRegex
name: "Generate tag version regex"
run: |
echo -n "^(?!v" > tag_regex.txt
echo -n "${{ steps.generateMinecraftVersion.outputs.minecraft_version }}" | sed "s|\.|\\\\.|g" >> tag_regex.txt
echo -n ").+$" >> tag_regex.txt
echo "Tag version regex: $(cat tag_regex.txt)"
echo "tag_regex=$(cat tag_regex.txt)" >> "$GITHUB_ENV"

- id: generateReleaseText
name: "Generate release text"
run: |
release_text="Version ${{ steps.generateModVersion.outputs.version }} for Minecraft ${{ steps.generateMinecraftVersion.outputs.minecraft_version }}"
echo "Release text: ${release_text}"
echo "release_text=${release_text}" >> "$GITHUB_OUTPUT"