diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml new file mode 100644 index 0000000..447f10a --- /dev/null +++ b/.gitea/workflows/publish.yml @@ -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 \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index bb7dcde..62f73b6 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,9 +5,8 @@ - + -