forked from neoforged/NeoForm
-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (75 loc) · 2.88 KB
/
Copy pathget-diff.yml
File metadata and controls
77 lines (75 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Get diff
# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
old_version:
description: 'Old version'
required: true
new_branch:
description: 'New branch'
required: false
new_version:
description: 'New version'
required: true
workflow_call:
inputs:
old_version:
type: string
required: true
new_branch:
type: string
required: false
new_version:
type: string
required: true
jobs:
get-diff:
name: Get diff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Get Time
id: time
run: echo "time=$(date -Isecond -u)" >> $GITHUB_OUTPUT
- uses: actions/github-script@v7
id: split_version
env:
OLD_VERSION: ${{ inputs.old_version }}
NEW_VERSION: ${{ inputs.new_version }}
with:
script: |
const oldVersion = process.env.OLD_VERSION.split("/");
const newVersion = process.env.NEW_VERSION.split("/");
var returnValue = {old_version_type: oldVersion[0], old_version_name: oldVersion[oldVersion.length - 1], new_version_type: newVersion[0], new_version_name: newVersion[newVersion.length - 1]}
return returnValue;
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: false
generate-job-summary: false
- name: Get old joined src
env:
VERSION_NAME: ${{ fromJson(steps.split_version.outputs.result).old_version_name }}
VERSION_TYPE: ${{ fromJson(steps.split_version.outputs.result).old_version_type }}
run: ./gradlew :$VERSION_NAME:projectResetAll -Pupdating -Ptype=$VERSION_TYPE
- name: Checkout new branch
if: ${{ inputs.new_branch }}
run: git checkout ${{ inputs.new_branch }}
- name: Get new joined src
env:
VERSION_NAME: ${{ fromJson(steps.split_version.outputs.result).new_version_name }}
VERSION_TYPE: ${{ fromJson(steps.split_version.outputs.result).new_version_type }}
run: ./gradlew :$VERSION_NAME:projectResetAll -Pupdating -Ptype=$VERSION_TYPE
- name: Get diff
run: git diff --no-index versions/${{ inputs.old_version }}/projects/joined/src/main/java versions/${{ inputs.new_version }}/projects/joined/src/main/java > ${{ fromJson(steps.split_version.outputs.result).old_version_name }}-${{ fromJson(steps.split_version.outputs.result).new_version_name }}.patch || true
- name: Upload diff as artifact
uses: actions/upload-artifact@v4
with:
name: ${{ fromJson(steps.split_version.outputs.result).old_version_name }}-${{ fromJson(steps.split_version.outputs.result).new_version_name }}-patch
path: '*.patch'