-
Notifications
You must be signed in to change notification settings - Fork 184
141 lines (123 loc) · 5.23 KB
/
verify-pull-request.yaml
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Verify pull requests
on:
pull_request:
branches:
- main
- main/**
- feature/**
jobs:
style_check:
name: Style/Format check
runs-on: ubuntu-latest
steps:
- name: Checkout git repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Commit Linter
uses: wagoid/commitlint-github-action@v5
with:
configFile: .github/commitlint.config.js
build_test:
name: Build and Test
runs-on: ubuntu-latest
environment: prod
steps:
- name: Checkout git repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Extract commit info
id: commit_info
run: |
short_sha="$(git rev-parse --short $GITHUB_SHA)"
branch_name="pr$(echo $GITHUB_REF | sed -e 's/refs\/pull\/\(.*\)\/merge/\1/')"
echo "short_sha=$short_sha" >> $GITHUB_OUTPUT
echo "branch_name=$branch_name" >> $GITHUB_OUTPUT
# Install python and deps
- name: Set up Python 3.12.1
uses: actions/setup-python@v4
with:
python-version: 3.12.1
- name: Cache PIP packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('.github/requirements.txt') }}
- name: Install python deps
run: |
python -m pip install --upgrade pip
python -m pip install -r .github/requirements.txt
- name: Generate version
id: versioning
run: |
version=$(python .github/git_utils.py genVersion --format_str="{major}.{minor}.{patch}-${{ steps.commit_info.outputs.branch_name }}+{increment}")
echo "version=$version"
echo "version=$version" >> $GITHUB_OUTPUT
- name: Set up JDK 1.8
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '8'
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle2-${{ hashFiles('**/build.gradle', '**/build.properties', '**/gradle.properties', '**/gradle-wrapper.properties') }}
- name: Build with Gradle
run: ./gradlew build # TODO test
env:
AUTO_GENERATED_VERSION: ${{ steps.versioning.outputs.version }}
- name: Cleanup Gradle Cache
# These files shouldn't be cached according to https://docs.github.com/en/actions/guides/building-and-testing-java-with-gradle
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: project-red-${{ steps.versioning.outputs.version }}
path: '*/build/libs/ProjectRed-*.jar'
- name: TEST Publish to Modrinth
# if: ${{ steps.release_type.outputs.publish_launchers == 'true' }}
continue-on-error: true
run: |
# Base args for all modules
COMMON_ARGS=( \
-k $API_TOKEN \
create-version \
-v "$MOD_VERSION" \
-c ./CHANGELOG.md \
-gv 1.20.1 \
-vt $RELEASE_TYPE \
-l forge \
-l neoForge \
--required-dep codechicken-lib \
--required-dep cb-multipart \
)
# All submodules need PR Core
MODULE_ARGS=( \
"${COMMON_ARGS[@]}" \
--required-dep project-red-core \
)
# Fabrication is special and also needs Integration and Transmission
FAB_ARGS=( \
"${MODULE_ARGS[@]}" \
--required-dep project-red-integration \
--required-dep project-red-transmission \
)
# TEST: Make changelog
echo "## $AUTO_GENERATED_VERSION \n * change1 \n * change2 \n * change3" > ./CHANGELOG.md
python -m modrinthpy "${COMMON_ARGS[@]}" -p project-red-core -n "Project Red Core v$MOD_VERSION" -f core/build/libs/*-core.jar
python -m modrinthpy "${MODULE_ARGS[@]}" -p project-red-expansion -n "Project Red Expansion v$MOD_VERSION" -f expansion/build/libs/*-expansion.jar
python -m modrinthpy "${MODULE_ARGS[@]}" -p project-red-exploration -n "Project Red Exploration v$MOD_VERSION" -f exploration/build/libs/*-exploration.jar
python -m modrinthpy "${FAB_ARGS[@]}" -p project-red-fabrication -n "Project Red Fabrication v$MOD_VERSION" -f fabrication/build/libs/*-fabrication.jar
python -m modrinthpy "${MODULE_ARGS[@]}" -p project-red-illumination -n "Project Red Illumination v$MOD_VERSION" -f illumination/build/libs/*-illumination.jar
python -m modrinthpy "${MODULE_ARGS[@]}" -p project-red-integration -n "Project Red Integration v$MOD_VERSION" -f integration/build/libs/*-integration.jar
python -m modrinthpy "${MODULE_ARGS[@]}" -p project-red-transmission -n "Project Red Transmission v$MOD_VERSION" -f transmission/build/libs/*-transmission.jar
env:
RELEASE_TYPE: alpha
API_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
MOD_VERSION: ${{ steps.versioning.outputs.version }}