This commit is contained in:
@@ -0,0 +1,84 @@
|
|||||||
|
name: Deploy to Maven Repository
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up JDK
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
java-version: '21'
|
||||||
|
cache: 'maven'
|
||||||
|
|
||||||
|
- name: Get release version
|
||||||
|
id: get_version
|
||||||
|
run: echo "version=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Set version from release tag
|
||||||
|
run: mvn -B versions:set -DnewVersion="${{ github.event.release.tag_name }}" -DgenerateBackupPoms=false
|
||||||
|
|
||||||
|
- name: Build plugin
|
||||||
|
run: mvn -B -U -C clean package -DskipTests
|
||||||
|
|
||||||
|
- name: Extract Maven coordinates
|
||||||
|
id: meta
|
||||||
|
run: |
|
||||||
|
echo "groupId=$(mvn help:evaluate -Dexpression=project.groupId -q -DforceStdout)" >> $GITHUB_OUTPUT
|
||||||
|
echo "artifactId=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> $GITHUB_OUTPUT
|
||||||
|
echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Set up SSH
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "${{ secrets.MVN_REPO_SSH_KEY }}" > ~/.ssh/id_rsa
|
||||||
|
chmod 600 ~/.ssh/id_rsa
|
||||||
|
ssh-keyscan -H ${{ secrets.MVN_REPO_SSH_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
- name: Generate checksums
|
||||||
|
run: |
|
||||||
|
ARTIFACT_ID=${{ steps.meta.outputs.artifactId }}
|
||||||
|
VERSION=${{ steps.meta.outputs.version }}
|
||||||
|
|
||||||
|
JAR_FILE=target/$ARTIFACT_ID-$VERSION.jar
|
||||||
|
POM_FILE=target/$ARTIFACT_ID-$VERSION.pom
|
||||||
|
|
||||||
|
cp pom.xml $POM_FILE
|
||||||
|
|
||||||
|
for file in $JAR_FILE $POM_FILE; do
|
||||||
|
sha1sum "$file" | awk '{ print $1 }' > "$file.sha1"
|
||||||
|
md5sum "$file" | awk '{ print $1 }' > "$file.md5"
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Upload artifact and checksums to VPS
|
||||||
|
run: |
|
||||||
|
GROUP_PATH=$(echo "${{ steps.meta.outputs.groupId }}" | sed 's/\./\//g')
|
||||||
|
ARTIFACT_ID=${{ steps.meta.outputs.artifactId }}
|
||||||
|
VERSION=${{ steps.meta.outputs.version }}
|
||||||
|
REMOTE_DIR="${{ secrets.REMOTE_MAVEN_PATH }}/$GROUP_PATH/$ARTIFACT_ID/$VERSION"
|
||||||
|
|
||||||
|
echo "Creating remote directory: $REMOTE_DIR"
|
||||||
|
ssh ${{ secrets.MVN_REPO_SSH_USER }}@${{ secrets.MVN_REPO_SSH_HOST }} "mkdir -p $REMOTE_DIR"
|
||||||
|
|
||||||
|
FILES=(
|
||||||
|
"target/$ARTIFACT_ID-$VERSION.jar"
|
||||||
|
"target/$ARTIFACT_ID-$VERSION.jar.sha1"
|
||||||
|
"target/$ARTIFACT_ID-$VERSION.jar.md5"
|
||||||
|
"target/$ARTIFACT_ID-$VERSION.pom"
|
||||||
|
"target/$ARTIFACT_ID-$VERSION.pom.sha1"
|
||||||
|
"target/$ARTIFACT_ID-$VERSION.pom.md5"
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "Uploading files..."
|
||||||
|
for file in "${FILES[@]}"; do
|
||||||
|
echo "Uploading $file"
|
||||||
|
scp "$file" ${{ secrets.MVN_REPO_SSH_USER }}@${{ secrets.MVN_REPO_SSH_HOST }}:$REMOTE_DIR/
|
||||||
|
done
|
||||||
Generated
+1
-2
@@ -5,9 +5,8 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="98c311c3-6130-4449-9bcb-07029b56b776" name="Changes" comment="">
|
<list default="true" id="98c311c3-6130-4449-9bcb-07029b56b776" name="Changes" comment="">
|
||||||
<change afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/.gitea/workflows/publish.yml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
|||||||
Reference in New Issue
Block a user