Skip to content

Commit 62e07ea

Browse files
authored
Update maven-publish.yml
1 parent fc9b7b9 commit 62e07ea

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

.github/workflows/maven-publish.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
branches: [ "main" ]
66
pull_request:
77
branches: [ "main" ]
8+
release:
9+
types: [created]
810

911
jobs:
1012
build:
@@ -69,3 +71,61 @@ jobs:
6971
target/AdvancementInfo-latest.jar
7072
env:
7173
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
75+
- name: Checkout Maven repository
76+
uses: actions/checkout@v4
77+
with:
78+
repository: CroaBeast/repositories
79+
path: maven-repo
80+
token: ${{ secrets.MAVEN_DEPLOY_TOKEN }}
81+
82+
- name: Configure Git
83+
run: |
84+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
85+
git config --global user.name "github-actions[bot]"
86+
87+
- name: Deploy to Maven repository
88+
run: |
89+
# Create directory structure
90+
mkdir -p maven-repo/me/croabeast/AdvancementInfo/${{ env.VERSION }}
91+
92+
# Copy JAR file
93+
cp target/AdvancementInfo-${{ env.VERSION }}.jar maven-repo/me/croabeast/AdvancementInfo/${{ env.VERSION }}/
94+
95+
# Create POM file
96+
cat > maven-repo/me/croabeast/AdvancementInfo/${{ env.VERSION }}/AdvancementInfo-${{ env.VERSION }}.pom << EOF
97+
<?xml version="1.0" encoding="UTF-8"?>
98+
<project>
99+
<modelVersion>4.0.0</modelVersion>
100+
<groupId>me.croabeast</groupId>
101+
<artifactId>AdvancementInfo</artifactId>
102+
<version>${{ env.VERSION }}</version>
103+
<packaging>jar</packaging>
104+
</project>
105+
EOF
106+
107+
# Update or create maven-metadata.xml
108+
cat > maven-repo/me/croabeast/AdvancementInfo/maven-metadata.xml << EOF
109+
<?xml version="1.0" encoding="UTF-8"?>
110+
<metadata>
111+
<groupId>me.croabeast</groupId>
112+
<artifactId>AdvancementInfo</artifactId>
113+
<versioning>
114+
<latest>${{ env.VERSION }}</latest>
115+
<release>${{ env.VERSION }}</release>
116+
<versions>
117+
<version>${{ env.VERSION }}</version>
118+
</versions>
119+
<lastUpdated>$(date +%Y%m%d%H%M%S)</lastUpdated>
120+
</versioning>
121+
</metadata>
122+
EOF
123+
124+
# Commit and push changes
125+
cd maven-repo
126+
git add .
127+
git commit -m "Deploy AdvancementInfo ${{ env.VERSION }}"
128+
git push
129+
130+
env:
131+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)