Skip to content

Commit 429835f

Browse files
committed
Автоматика модрич
1 parent a193f1a commit 429835f

1 file changed

Lines changed: 128 additions & 74 deletions

File tree

Lines changed: 128 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
name: Сборка
1+
name: Сборка и публикация
2+
23
on:
34
push:
45
branches: [ main, master ]
56
workflow_dispatch:
7+
68
jobs:
79
extract-version:
810
runs-on: ubuntu-latest
@@ -11,89 +13,141 @@ jobs:
1113
artifact_name: ${{ steps.get_artifact_name.outputs.ARTIFACT_NAME }}
1214
tag_exists: ${{ steps.check_tag.outputs.TAG_EXISTS }}
1315
steps:
14-
- name: Checkout code
15-
uses: actions/checkout@v4
16-
with:
17-
fetch-depth: 0
18-
token: ${{ secrets.PAT }}
19-
- name: Get Maven version
20-
id: get_version
21-
run: |
22-
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
23-
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
24-
echo "Detected version: $VERSION"
25-
- name: Get artifact name
26-
id: get_artifact_name
27-
run: |
28-
ARTIFACT_NAME=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)
29-
echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_OUTPUT
30-
echo "Detected artifact name: $ARTIFACT_NAME"
31-
- name: Check if tag exists
32-
id: check_tag
33-
run: |
34-
if git rev-parse "v${{ steps.get_version.outputs.VERSION }}" >/dev/null 2>&1; then
35-
echo "TAG_EXISTS=true" >> $GITHUB_OUTPUT
36-
else
37-
echo "TAG_EXISTS=false" >> $GITHUB_OUTPUT
38-
fi
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
token: ${{ secrets.PAT }}
21+
22+
- name: Set up JDK
23+
uses: actions/setup-java@v3
24+
with:
25+
java-version: '21'
26+
distribution: 'temurin'
27+
28+
- name: Get Maven version
29+
id: get_version
30+
run: |
31+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
32+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
33+
echo "Detected version: $VERSION"
34+
35+
- name: Get artifact name
36+
id: get_artifact_name
37+
run: |
38+
ARTIFACT_NAME=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)
39+
echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_OUTPUT
40+
echo "Detected artifact name: $ARTIFACT_NAME"
41+
42+
- name: Check if tag exists
43+
id: check_tag
44+
run: |
45+
if git rev-parse "v${{ steps.get_version.outputs.VERSION }}" >/dev/null 2>&1; then
46+
echo "TAG_EXISTS=true" >> $GITHUB_OUTPUT
47+
else
48+
echo "TAG_EXISTS=false" >> $GITHUB_OUTPUT
49+
fi
50+
3951
build:
4052
needs: extract-version
4153
runs-on: ubuntu-latest
4254
if: needs.extract-version.outputs.tag_exists == 'false'
4355
steps:
44-
- name: Checkout code
45-
uses: actions/checkout@v4
46-
- name: Set up JDK
47-
uses: actions/setup-java@v3
48-
with:
49-
java-version: '21'
50-
distribution: 'temurin'
51-
- name: Build
52-
run: mvn clean package
53-
- name: Upload artifact
54-
uses: actions/upload-artifact@v4
55-
with:
56-
name: ${{ needs.extract-version.outputs.artifact_name }}-v${{ needs.extract-version.outputs.version }}
57-
path: target/*.jar
56+
- name: Checkout code
57+
uses: actions/checkout@v4
58+
59+
- name: Set up JDK
60+
uses: actions/setup-java@v3
61+
with:
62+
java-version: '21'
63+
distribution: 'temurin'
64+
65+
- name: Build
66+
run: mvn clean package
67+
68+
- name: Upload artifact
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: ${{ needs.extract-version.outputs.artifact_name }}-v${{ needs.extract-version.outputs.version }}
72+
path: target/*.jar
73+
5874
create-tag:
59-
needs:
60-
- extract-version
61-
- build
75+
needs: [extract-version, build]
6276
runs-on: ubuntu-latest
6377
if: needs.extract-version.outputs.tag_exists == 'false'
6478
steps:
65-
- name: Checkout code
66-
uses: actions/checkout@v4
67-
with:
68-
token: ${{ secrets.PAT }}
69-
fetch-depth: 0
70-
- name: Create tag
71-
run: |
72-
git config user.name "GitHub Actions"
73-
git config user.email "actions@github.com"
74-
git tag -a "v${{ needs.extract-version.outputs.version }}" -m "Release v${{ needs.extract-version.outputs.version }}"
75-
git push origin "v${{ needs.extract-version.outputs.version }}"
79+
- name: Checkout code
80+
uses: actions/checkout@v4
81+
with:
82+
token: ${{ secrets.PAT }}
83+
fetch-depth: 0
84+
85+
- name: Create tag
86+
run: |
87+
git config user.name "GitHub Actions"
88+
git config user.email "actions@github.com"
89+
git tag -a "v${{ needs.extract-version.outputs.version }}" -m "Release v${{ needs.extract-version.outputs.version }}"
90+
git push origin "v${{ needs.extract-version.outputs.version }}"
91+
7692
release:
77-
needs:
78-
- extract-version
79-
- create-tag
93+
needs: [extract-version, create-tag]
8094
runs-on: ubuntu-latest
8195
if: needs.extract-version.outputs.tag_exists == 'false'
8296
steps:
83-
- name: Download artifact
84-
uses: actions/download-artifact@v4
85-
with:
86-
name: ${{ needs.extract-version.outputs.artifact_name }}-v${{ needs.extract-version.outputs.version }}
87-
- name: Filter out original jars
88-
run: |
89-
find . -name "original-*.jar" -delete
90-
echo "Removed original-*.jar files"
91-
- name: Create Release
92-
uses: softprops/action-gh-release@v1
93-
with:
94-
tag_name: v${{ needs.extract-version.outputs.version }}
95-
name: v${{ needs.extract-version.outputs.version }}
96-
files: "*.jar"
97-
generate_release_notes: true
98-
env:
99-
GITHUB_TOKEN: ${{ secrets.PAT }}
97+
- name: Download artifact
98+
uses: actions/download-artifact@v4
99+
with:
100+
name: ${{ needs.extract-version.outputs.artifact_name }}-v${{ needs.extract-version.outputs.version }}
101+
102+
- name: Remove original-*.jar
103+
run: |
104+
find . -name "original-*.jar" -delete
105+
106+
- name: Create GitHub Release
107+
uses: softprops/action-gh-release@v1
108+
with:
109+
tag_name: v${{ needs.extract-version.outputs.version }}
110+
name: v${{ needs.extract-version.outputs.version }}
111+
files: "*.jar"
112+
generate_release_notes: true
113+
env:
114+
GITHUB_TOKEN: ${{ secrets.PAT }}
115+
116+
publish-modrinth:
117+
needs: release
118+
runs-on: ubuntu-latest
119+
if: needs.extract-version.outputs.tag_exists == 'false'
120+
steps:
121+
- name: Download artifact
122+
uses: actions/download-artifact@v4
123+
with:
124+
name: ${{ needs.extract-version.outputs.artifact_name }}-v${{ needs.extract-version.outputs.version }}
125+
126+
- name: Remove original-*.jar
127+
run: |
128+
find . -name "original-*.jar" -delete
129+
130+
- name: Publish to Modrinth
131+
uses: modrinth-actions/publish@v2
132+
with:
133+
token: ${{ secrets.MODRINTH_TOKEN }}
134+
project_id: k7ZA8q9y
135+
version: ${{ needs.extract-version.outputs.version }}
136+
version_type: release
137+
changelog: "Автоматический релиз v${{ needs.extract-version.outputs.version }}"
138+
files: "*.jar"
139+
game_versions: |
140+
1.21.11
141+
1.21.10
142+
1.21.9
143+
1.21.8
144+
1.21.7
145+
1.21.6
146+
1.21.5
147+
1.21.4
148+
loaders: |
149+
paper
150+
spigot
151+
purpur
152+
folia
153+
bukkit

0 commit comments

Comments
 (0)