Skip to content

Commit

Permalink
Add build info to built JAR files (#2588)
Browse files Browse the repository at this point in the history
  • Loading branch information
krossgg authored Dec 19, 2024
1 parent 5f5214f commit cd19a78
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 103 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/auto-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Latest Build
on:
push:
branches: ['1.20.1', '1.21']
paths-ignore: ['.github/**', '**/*.md']
paths: ['src/**', '**/*.gradle', 'gradle.properties']

concurrency:
group: auto-build-${{ github.ref }}
Expand All @@ -13,24 +13,29 @@ jobs:
build:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ github.token }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
MAVEN_USER: ${{ secrets.MAVEN_USER }}
SNAPSHOT: true
GITHUB_TOKEN: ${{ github.token }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Setup Build
uses: ./.github/actions/build_setup
- name: Get Version
- name: Get Mod Version
id: ver
run: echo "version=$(./gradlew -q printVersion)" >> $GITHUB_OUTPUT
- name: Version Suffix
id: suffix
run: echo "VERSION_SUFFIX=$(echo "${{ github.sha }}" | cut -c 1-7)" >> $GITHUB_ENV
- name: Build
run: ./gradlew build --build-cache
- name: Publish to Maven
if: github.repository_owner == 'GregTechCEu'
run: ./gradlew publish --build-cache
- name: Rename Jars
run: for file in build/libs/*; do mv "$file" "${file/SHOT/SHOT-$(date --utc '+%Y%m%d-%H%M%S')-${{ env.VERSION_SUFFIX }}}"; done;
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
Expand All @@ -51,10 +56,10 @@ jobs:
uses: andelf/nightly-release@46e2d5f80828ecc5c2c3c819eb31186a7cf2156c
with:
tag_name: latest-${{ github.ref_name }}
name: '${{ github.ref_name }}-${{ steps.ver.outputs.version}} SNAPSHOT $$'
name: '${{ github.ref_name }}-${{ steps.ver.outputs.version}} SNAPSHOT ${{ env.VERSION_SUFFIX }}'
prerelease: true
body: |
The latest build of GTM for Minecraft ${{ github.ref_name }}.
Please report any [issues](https://github.com/GregTechCEu/GregTech-Modern/issues).
${{ steps.changelog.outputs.changelog }}
files: build/libs/*.jar
files: build/libs/*.jar
89 changes: 0 additions & 89 deletions .github/workflows/auto-publish.yml

This file was deleted.

16 changes: 14 additions & 2 deletions .github/workflows/build-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ concurrency:
jobs:
build:
runs-on: ubuntu-latest
env:
VERSION_SUFFIX: "PR-${{ github.event.number }}"
steps:
- uses: actions/checkout@v4
- name: Check Path Filter
Expand All @@ -31,10 +33,20 @@ jobs:
- name: Build
if: steps.filter.outputs.code == 'true'
run: ./gradlew assemble --build-cache
- name: Upload Artifact
- name: Rename Jars
if: steps.filter.outputs.code == 'true'
run: for file in build/libs/*; do mv "$file" "${file/.jar/-${{ env.VERSION_SUFFIX }}.jar}"; done;
- name: Upload All Artifacts
if: steps.filter.outputs.code == 'true'
uses: actions/[email protected]
with:
name: build output
name: Full Package
path: build/libs/*
retention-days: 15
- name: Upload Main Jar
if: steps.filter.outputs.code == 'true'
uses: actions/[email protected]
with:
name: Main Jar
path: build/libs/*[0-9]-PR-*.jar
retention-days: 15
9 changes: 3 additions & 6 deletions .github/workflows/manage-pr-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@ name: Pull Request Labels

# Checks for label once PR has been reviewed or label is applied
on:
pull_request_review:
types: [submitted]
pull_request:
types: [labeled]
types: [opened, labeled, unlabeled]

concurrency:
group: pr-labels-${{ github.head_ref }}
cancel-in-progress: true

jobs:
Labels:
name: On Approval
if: github.event_name == 'pull_request' || github.event.review.state == 'approved'
labels:
name: Label Check
runs-on: ubuntu-latest
permissions:
pull-requests: read # needed to utilize required-labels
Expand Down
5 changes: 4 additions & 1 deletion gradle/scripts/resources.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ def mod_description = getConfig("mod_description")
def mod_url = getConfig("mod_url")
def mod_issue_tracker = getConfig("mod_issue_tracker")

String suffix = System.getenv("VERSION_SUFFIX")
String version_toml = "$version" + (suffix ? "-$suffix" : "")

task printVersion {
doLast {
println mod_version
Expand All @@ -21,7 +24,7 @@ task printVersion {
var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) {
var forgeVers = forge.versions.forgeShortVersion.get().split("\\.")[0]
var replaceProperties = [
version : version,
version : version_toml,
mod_id : mod_id,
minecraft_version : libs.versions.minecraft.get(),
loader_version : forgeVers,
Expand Down

0 comments on commit cd19a78

Please sign in to comment.