Skip to content

Commit

Permalink
Revamp Workflows for Optimal Productivity (#2112)
Browse files Browse the repository at this point in the history
  • Loading branch information
krossgg authored Oct 9, 2024
1 parent b312167 commit 97f2dbb
Show file tree
Hide file tree
Showing 15 changed files with 351 additions and 106 deletions.
15 changes: 9 additions & 6 deletions .github/actions/build_setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@ inputs:
description: If cache should be updated
required: false
default: 'false'
ref:
description: 'Ref to checkout'
required: false

runs:
using: 'composite'

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up JDK 17
ref: ${{ inputs.ref || github.ref }}
- name: Set up JDK
uses: actions/setup-java@v4
env:
REF: ${{ inputs.ref || github.ref }}
with:
distribution: adopt
java-version: 17
distribution: temurin
java-version: ${{ contains(env.REF, '1.20.1') && '17' || '21' }}

- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v3
Expand Down
22 changes: 22 additions & 0 deletions .github/json/config-latest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"categories": [
{
"title": "### Added",
"labels": ["type: feature"]
},
{
"title": "### Fixed",
"labels": ["type: bugfix"]
},
{
"title": "### Changed",
"labels": ["type: refactor", "type: translation"]
}
],
"sort": "ASC",
"template": "## Changes\n#{{CHANGELOG}}",
"pr_template": "- #{{TITLE}} by #{{AUTHOR}} in [##{{NUMBER}}](#{{URL}})",
"ignore_labels": ["ignore changelog"],
"max_pull_requests": 1000,
"max_back_track_time_days": 90
}
35 changes: 35 additions & 0 deletions .github/json/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"categories": [
{
"title": "### Added",
"labels": ["type: feature"]
},
{
"title": "### Fixed",
"labels": ["type: bugfix"]
},
{
"title": "### Changed",
"labels": ["type: refactor", "type: translation"]
}
],
"sort": "ASC",
"template": "## Version [#{{TO_TAG}}](#{{RELEASE_DIFF}})\n#{{CHANGELOG}} ",
"pr_template": "- #{{TITLE}} by #{{AUTHOR}} in [##{{NUMBER}}](#{{URL}})",
"empty_template": "- No changes",
"ignore_labels": ["ignore changelog"],
"tag_resolver": {
"method": "semver",
"filter": {
"pattern": "^(?!v?(1\\.20\\.1-)?[0-9\\.]+$).+$",
"flags": "gu"
},
"transformer": {
"pattern": "v?([0-9\\.]+-)?([0-9\\.]+)",
"target": "$2"
}
},
"max_pull_requests": 1000,
"max_back_track_time_days": 90,
"base_branches": ["1.20.1"]
}
66 changes: 35 additions & 31 deletions .github/workflows/auto-build.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: auto-build
name: Latest Build

on:
push:
branches:
- '1.20.1'
branches: ['1.20.1', '1.21']
paths-ignore: ['.github/**', '**/*.md']

concurrency:
group: auto-build-${{ github.head_ref || github.ref }}
group: auto-build-${{ github.ref }}
cancel-in-progress: true

jobs:
Expand All @@ -16,41 +16,45 @@ jobs:
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
MAVEN_USER: ${{ secrets.MAVEN_USER }}
SNAPSHOT: true
GITHUB_TOKEN: ${{ github.token }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Setup Build
uses: ./.github/actions/build_setup

- name: Get Version
id: ver
run: echo "version=$(./gradlew -q printVersion)" >> $GITHUB_OUTPUT
- name: Build
run: ./gradlew build --build-cache

- name: Publish to Maven
if: github.repository_owner == 'GregTechCEu'
run: ./gradlew publish --build-cache

- name: Get Version
id: var
run: |
VER=$(./gradlew -q printVersion)
BUILD_VER=$VER-build_${{ github.run_number }}
for jar in ./build/libs/*; do mv "$jar" "${jar/${VER}-SNAPSHOT/${BUILD_VER}-SNAPSHOT}";done 2>/dev/null
echo "version=$BUILD_VER" >> $GITHUB_OUTPUT
- name: Release
id: release
uses: Kir-Antipov/[email protected]
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
github-tag: ${{ steps.var.outputs.version }}
github-token: ${{ secrets.GITHUB_TOKEN }}
files: |
build/libs/!(*-@(dev|dev-all|dev-slim|javadoc)).jar
- name: Print Output
run: |
echo "Release tag: ${{ steps.release.outputs.github-tag }}"
echo "Release URL: ${{ steps.release.outputs.github-url }}"
echo "Released files: ${{ steps.release.outputs.github-files }}"
name: build-artifacts
path: build/libs/*
if-no-files-found: error
retention-days: 90
- name: Changelog
id: changelog
uses: mikepenz/release-changelog-builder-action@v5
with:
configuration: ./.github/json/config-latest.json
fromTag: latest-${{ github.ref_name }}
toTag: ${{ github.ref }}
fetchViaCommits: true
failOnError: false
- name: Release Latest
uses: andelf/nightly-release@46e2d5f80828ecc5c2c3c819eb31186a7cf2156c
with:
tag_name: latest-${{ github.ref_name }}
name: '${{ github.ref_name }}-${{ steps.ver.outputs.version}} SNAPSHOT $$'
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
19 changes: 8 additions & 11 deletions .github/workflows/build-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,37 @@ on:
pull_request:
paths: ['**']

# Cancel previous jobs if PR gets another push
concurrency:
group: PR-build-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
env:
GITHUB_RUN_NUMBER: ${{ vars.GITHUB_RUN_NUMBER }}
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Check Path Filter
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
code:
- 'src/**'
- '**.gradle'
- '*.gradle'
- 'gradle.properties'
- 'gradlew**'
- 'gradlew*'
- 'gradle/**'
- name: Setup Build
if: steps.filter.outputs.code == 'true'
uses: ./.github/actions/build_setup

- name: Build
if: steps.filter.outputs.code == 'true'
run: ./gradlew assemble --build-cache

- name: Upload Artifact
if: steps.filter.outputs.code == 'true'
uses: actions/[email protected]
with:
name: build output
path: build/libs/*
retention-days: 30
retention-days: 15
30 changes: 0 additions & 30 deletions .github/workflows/changelog.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .github/workflows/clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ jobs:
contents: write
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Setup Build
uses: ./.github/actions/build_setup
with:
update-cache: true

- name: Clean
run: ./gradlew clean --build-cache
11 changes: 4 additions & 7 deletions .github/workflows/format-java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,24 @@ name: Java Formatting

on:
push:
branches:
- '1.20.1'
branches: ['1.20.1', '1.21']
paths: ['src/main/java/**', 'src/test/**']
pull_request:
paths: ['**']

concurrency:
group: formatting-${{ github.head_ref || github.ref }}
group: formatting-${{ github.ref }}
cancel-in-progress: true

jobs:
formatting:
name: Formatting
runs-on: ubuntu-latest

permissions:
pull-requests: read
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Check Path Filter
uses: dorny/paths-filter@v3
id: filter
Expand All @@ -30,11 +29,9 @@ jobs:
code:
- 'src/main/java/**'
- 'src/test/**'
- name: Setup Build
if: steps.filter.outputs.code == 'true'
uses: ./.github/actions/build_setup

- name: Run Spotless Formatting Check with Gradle
if: steps.filter.outputs.code == 'true'
run: ./gradlew spotlessCheck --warning-mode all --build-cache
16 changes: 6 additions & 10 deletions .github/workflows/manage-pr-labels.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
# Manages labels on PRs before allowing merging
name: Pull Request Labels

# Checks for label once PR has been reviewed
on:
pull_request:
types:
- opened
- labeled
- unlabeled
- synchronize
pull_request_review:
types: [submitted]

# if a second commit is pushed quickly after the first, cancel the first one's build
concurrency:
group: pr-labels-${{ github.head_ref }}
cancel-in-progress: true

jobs:
Labels:
name: On Approval
if: github.event.review.state == 'approved'
runs-on: ubuntu-latest

permissions:
pull-requests: read # needed to utilize required-labels

steps:
- name: Check for Merge-Blocking Labels # blocks merge if present
uses: mheap/github-action-required-labels@v5
with:
mode: exactly
count: 0
labels: 'status: do not merge'
labels: 'do not merge'
exit_type: failure

- name: Check for Required Labels # require at least one of these labels
Expand Down
Loading

0 comments on commit 97f2dbb

Please sign in to comment.