Skip to content

Commit

Permalink
Merge pull request #1 from mdddj/changelog-update-1.1.2
Browse files Browse the repository at this point in the history
Changelog update - `1.1.2`
  • Loading branch information
mdddj authored Apr 19, 2024
2 parents c30a5a1 + fd40b0e commit 528a650
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 21 deletions.
103 changes: 103 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# GitHub Actions Workflow created for handling the release process based on the draft release prepared with the Build workflow.
# Running the publishPlugin task requires all following secrets to be provided: PUBLISH_TOKEN, PRIVATE_KEY, PRIVATE_KEY_PASSWORD, CERTIFICATE_CHAIN.
# See https://plugins.jetbrains.com/docs/intellij/plugin-signing.html for more information.

name: Release
on:
release:
types: [prereleased, released]

jobs:

# 准备插件并将其发布到 JetBrains Marketplace 存储库
release:
name: Publish Plugin
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:

# 查看当前存储库
- name: Fetch Sources
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}

# 为后续步骤设置 Java 环境
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17

# 设置 Gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true

# 设置环境变量
- name: Export Properties
id: properties
shell: bash
run: |
CHANGELOG="$(cat << 'EOM' | sed -e 's/^[[:space:]]*$//g' -e '/./,$!d'
${{ github.event.release.body }}
EOM
)"
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# 使用当前发行说明更新未发布部分
- name: Patch Changelog
if: ${{ steps.properties.outputs.changelog != '' }}
env:
CHANGELOG: ${{ steps.properties.outputs.changelog }}
run: |
./gradlew patchChangelog --release-note="$CHANGELOG"
# 将插件发布到 JetBrains Marketplace
- name: Publish Plugin
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }}
run: ./gradlew publishPlugin -Dorg.gradle.project.intellijPublishToken=${{ secrets.PUBLISH_TOKEN }}

# 上传工件作为发布资产
- name: Upload Release Asset
env:
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }}
run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*

# 创建拉取请求
- name: Create Pull Request
if: ${{ steps.properties.outputs.changelog != '' }}
env:
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }}
run: |
VERSION="${{ github.event.release.tag_name }}"
BRANCH="changelog-update-$VERSION"
LABEL="release changelog"
git config user.email "[email protected]"
git config user.name "GitHub Action"
git checkout -b $BRANCH
git commit -am "Changelog update - $VERSION"
git push --set-upstream origin $BRANCH
gh label create "$LABEL" \
--description "Pull requests with release changelog update" \
--force \
|| true
gh pr create \
--title "Changelog update - \`$VERSION\`" \
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
--label "$LABEL" \
--head $BRANCH
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# IntelliJ Platform Plugin Template Changelog

## [Unreleased]
### Added

### Changed

### Deprecated

### Removed

### Fixed

### Security

## [1.1.2]
**Full Changelog**: https://github.com/mdddj/SalvoRsTool/compare/1.1.1.7...1.1.2

## [1.1.2] - 2024-04-19
- upload test

## [1.1.1] - 2024-04-19
- bug fix
29 changes: 20 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
plugins {
id("org.jetbrains.kotlin.jvm") version "1.9.22"
id("org.jetbrains.intellij") version "1.17.2"
id("org.jetbrains.changelog") version "1.3.1"
}

group = "shop.itbug"
version = "1.0-SNAPSHOT"
version = "1.1.2"

repositories {
mavenCentral()
}

// Configure Gradle IntelliJ Plugin
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
//
intellij {
version.set("LATEST-EAP-SNAPSHOT")
type.set("RR") // Target IDE Platform
type.set("RR")
plugins.set(listOf("com.jetbrains.rust"))
}

val pushToken: String? = System.getenv("idea_push_token")
val pushToken: String? = System.getenv("PUBLISH_TOKEN")

tasks {
// Set the JVM compatibility versions
withType<JavaCompile> {
sourceCompatibility = "17"
targetCompatibility = "17"
Expand All @@ -33,16 +32,28 @@ tasks {
patchPluginXml {
sinceBuild.set("232")
untilBuild.set("242.*")
changeNotes.set("""
<div>
<h1>1.1.0</h1>
<p>
Optimize the presentation of underlined database table names, which will be changed to camel case naming method
</p>
</div>
""".trimIndent())
}

signPlugin {
certificateChainFile.set(file("chain.crt"))
privateKeyFile.set(file("private.key"))
// certificateChainFile.set(file("chain.crt"))
// privateKeyFile.set(file("private.key"))
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
}

publishPlugin {
token.set(pushToken)
if(pushToken != null) {
token.set(pushToken)
}
}

runIde {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import shop.itbug.salvorstool.i18n.MyI18n
import shop.itbug.salvorstool.tool.MyRsPsiFactory
import shop.itbug.salvorstool.tool.Tools
import shop.itbug.salvorstool.tool.myManager
import shop.itbug.salvorstool.tool.underlineToCamel
import shop.itbug.salvorstool.widget.RsEditor
import java.awt.Dimension
import java.util.*
Expand All @@ -48,10 +49,11 @@ enum class GenerateDtoDialogResultEnum {

///获取struct名称,例如: "user"表名字,生成对象的名称:"UserAddRequest"
fun GenerateDtoDialogResultEnum.getStructName(sqlTableName: String): String {

return when (this) {
GenerateDtoDialogResultEnum.AddRequest -> sqlTableName + "AddRequest"
GenerateDtoDialogResultEnum.UpdateRequest -> sqlTableName + "UpdateRequest"
GenerateDtoDialogResultEnum.Response -> sqlTableName + "Response"
GenerateDtoDialogResultEnum.AddRequest -> sqlTableName.underlineToCamel + "AddRequest"
GenerateDtoDialogResultEnum.UpdateRequest -> sqlTableName.underlineToCamel + "UpdateRequest"
GenerateDtoDialogResultEnum.Response -> sqlTableName.underlineToCamel + "Response"
}.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }
}

Expand Down
11 changes: 10 additions & 1 deletion src/main/kotlin/shop/itbug/salvorstool/tool/ExtendedFuntions.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package shop.itbug.salvorstool.tool

import com.google.common.base.CaseFormat
import com.intellij.psi.PsiElement
import org.rust.lang.core.psi.RsNamedFieldDecl
import org.rust.lang.core.psi.RsOuterAttr
import org.rust.lang.core.psi.impl.RsStructItemImpl
import java.util.*

val PsiElement.myManager get() = MyRsPsiElementManager(this)
val RsStructItemImpl.myManager get() = MyRsStructManager(this)
val RsNamedFieldDecl.myManager get() = MyFieldPsiElementManager(this)
Expand All @@ -12,5 +15,11 @@ fun String.capitalizeFirstLetter(): String {
if (isEmpty()) {
return this
}
return substring(0, 1).toUpperCase() + substring(1)
return substring(0, 1).uppercase(Locale.getDefault()) + substring(1)
}
///
val String.underlineToCamel: String get() = underlineToCamel(this)
///将驼峰变成下划线
fun underlineToCamel(underlineString: String): String {
return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, underlineString)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MyRsPsiElementManager(context: PsiElement) {
}

/// struct操作管理
class MyRsStructManager(val psiElement: RsStructItemImpl) {
class MyRsStructManager(private val psiElement: RsStructItemImpl) {


///属性列表
Expand All @@ -40,7 +40,7 @@ class MyRsStructManager(val psiElement: RsStructItemImpl) {
}



///


///属性处理
Expand Down
10 changes: 5 additions & 5 deletions src/main/kotlin/shop/itbug/salvorstool/tool/MyRsPsiFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub async fn add_$tabName(req: $structName) -> AppResult<$responseName> {
let model = $tabName::ActiveModel {
$sb
};
let result = ${tabName.capitalizeFirstLetter()}::insert(model).exec(db).await?;
let result = ${tabName.underlineToCamel.capitalizeFirstLetter()}::insert(model).exec(db).await?;
Ok($responseName {
${primaryField.myManager.name}: result.last_insert_id,
$fsb
Expand Down Expand Up @@ -138,9 +138,9 @@ pub async fn update_$tabName(req: $structName) -> AppResult<$responseName> {
.get()
.ok_or(anyhow::anyhow!("Database connection failed."))?;
let find = ${tabName.capitalizeFirstLetter()}::find_by_id(req.${primaryField.myManager.name}).one(db).await?;
let find = ${tabName.underlineToCamel.capitalizeFirstLetter()}::find_by_id(req.${primaryField.myManager.name}).one(db).await?;
if find.is_none() {
return Err(anyhow::anyhow!("${tabName.capitalizeFirstLetter()} does not exist.").into());
return Err(anyhow::anyhow!("${tabName.underlineToCamel.capitalizeFirstLetter()} does not exist.").into());
}
let mut model: $tabName::ActiveModel = find.unwrap().into();
Expand Down Expand Up @@ -169,7 +169,7 @@ $fsb
let db = DB
.get()
.ok_or(anyhow::anyhow!("Database connection failed."))?;
${tabName.capitalizeFirstLetter()}::delete_by_id(${primaryField.myManager.name}).exec(db).await?;
${tabName.underlineToCamel.capitalizeFirstLetter()}::delete_by_id(${primaryField.myManager.name}).exec(db).await?;
Ok(())
}
""".trimIndent()
Expand All @@ -195,7 +195,7 @@ pub async fn ${tabName+"_find_all"}() -> AppResult<Vec<$typeStructName>> {
let db = DB
.get()
.ok_or(anyhow::anyhow!("Database connection failed."))?;
let $tabName = ${tabName.capitalizeFirstLetter()}::find().all(db).await?;
let $tabName = ${tabName.underlineToCamel.capitalizeFirstLetter()}::find().all(db).await?;
let res = $tabName
.into_iter()
.map(|r| $typeStructName {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/shop/itbug/salvorstool/tool/Tools.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ object Tools {
};
use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, QueryFilter, Set, NotSet};
use crate::dtos::$tabName::*;
use crate::entities::prelude::${tabName.capitalizeFirstLetter()};
use crate::entities::prelude::${tabName.underlineToCamel.capitalizeFirstLetter()};
""".trimIndent()
}

Expand Down

0 comments on commit 528a650

Please sign in to comment.