From 1c3ac9fe1415933d7a8e5a1fd6bdd4550dfc1ce0 Mon Sep 17 00:00:00 2001 From: Iceflower Date: Sun, 1 Sep 2024 15:25:00 +0200 Subject: [PATCH] [ci] Support subfolder plugins --- .github/workflows/publish.yml | 26 +++++++++++++++++++++----- publisher/cli.go | 4 ++-- publisher/internal/addon.go | 10 +++++++++- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 654a13b..25ad962 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -15,51 +15,67 @@ jobs: config: - { id: "aspect_ratio_resize_container", + id-name: "aspect_ratio_resize_container", name: "AspectRatioResizeContainer", asset-id: "2089", } - { id: "custom_theme_overrides", + id-name: "custom_theme_overrides", name: "Custom Theme Overrides", asset-id: "2091", } - { id: "git_sha_project_setting", + id-name: "git_sha_project_setting", name: "Git SHA Project Setting", asset-id: "1979", } - { id: "glogging", + id-name: "glogging", name: "GLogging", asset-id: "no-deploy", } - { id: "hide_private_properties", + id-name: "hide_private_properties", name: "Hide Private Properties", asset-id: "1989", } - { id: "icon_explorer", + id-name: "icon_explorer", name: "Icon Explorer", asset-id: "2511", } - { id: "icons_patcher", + id-name: "icons_patcher", name: "Icons Patcher", asset-id: "1980", } - { id: "licenses", + id-name: "licenses", name: "License Manager", asset-id: "1969", } + - { + id: "kenyoni/plugin_reloader", + id-name: "plugin_reloader", + name: "Plugin Reloader", + asset-id: "no-deploy", + } - { id: "qr_code", + id-name: "qr_code", name: "QR Code", asset-id: "2090", } - { id: "texture_button_colored", + id-name: "texture_button_colored", name: "TextureButtonColored", asset-id: "2092", } @@ -92,20 +108,20 @@ jobs: uses: actions/upload-artifact@v3 with: name: ${{ matrix.config.name }} - path: archives/${{ matrix.config.id }}-*.zip + path: archives/${{ matrix.config.id-name }}-*.zip - uses: mukunku/tag-exists-action@v1.2.0 id: checkTag with: - tag: ${{ matrix.config.id }}-${{ steps.prepare-artifacts.outputs.version }} + tag: ${{ matrix.config.id-name }}-${{ steps.prepare-artifacts.outputs.version }} - name: Prepare Release if: ${{ steps.checkTag.outputs.exists == 'false' }} run: | git config user.name github-actions git config user.email github-actions@github.com - git tag ${{ matrix.config.id }}-${{ steps.prepare-artifacts.outputs.version }} - git push origin tag ${{ matrix.config.id }}-${{ steps.prepare-artifacts.outputs.version }} + git tag ${{ matrix.config.id-name }}-${{ steps.prepare-artifacts.outputs.version }} + git push origin tag ${{ matrix.config.id-name }}-${{ steps.prepare-artifacts.outputs.version }} # wait 5s that the pushed tag is available in the next step, sometimes the next step saw only the local tag - name: Wait 5s @@ -117,7 +133,7 @@ jobs: env: GITHUB_TOKEN: ${{ github.token }} run: | - gh release create ${{ matrix.config.id }}-${{ steps.prepare-artifacts.outputs.version }} ./archives/* --title "${{ matrix.config.name }} ${{ steps.prepare-artifacts.outputs.version }}" --notes "${{ steps.prepare-artifacts.outputs.notes }}" + gh release create ${{ matrix.config.id-name }}-${{ steps.prepare-artifacts.outputs.version }} ./archives/* --title "${{ matrix.config.name }} ${{ steps.prepare-artifacts.outputs.version }}" --notes "${{ steps.prepare-artifacts.outputs.notes }}" #- name: Deploy to Godot Asset Library # if: ${{ matrix.config.asset-id != 'no-deploy' }} diff --git a/publisher/cli.go b/publisher/cli.go index b5fd0de..d6d6938 100644 --- a/publisher/cli.go +++ b/publisher/cli.go @@ -181,7 +181,7 @@ func doActionAssetLibrary(baseDir string, addonId string, cfg assetLibraryAction assetData := internal.AssetData{ AssetId: cfg.AssetId, Title: plgCfg.Plugin.Name, - Description: fmt.Sprintf("%s\n\n%s", plgCfg.Plugin.Description, fmt.Sprintf("More detailed information and documentation is available at https://kenyoni-software.github.io/godot-addons/addons/%s", addon.Id())), + Description: fmt.Sprintf("%s\n\n%s", plgCfg.Plugin.Description, fmt.Sprintf("More detailed information and documentation is available at https://kenyoni-software.github.io/godot-addons/addons/%s", addon.IdName())), VersionString: plgCfg.Plugin.Version, GodotVersion: gdMinversion, CategoryId: cfg.Category, @@ -222,7 +222,7 @@ func doActionZip(baseDir string, addonId string, cfg zipActionCfg) { if outputDir == "" { outputDir = filepath.Join(addon.ProjectPath(), "archives") } - outputFile := filepath.Join(outputDir, addon.Id()+"-"+strings.ReplaceAll(plgCfg.Plugin.Version, ".", "_")+".zip") + outputFile := filepath.Join(outputDir, addon.IdName()+"-"+strings.ReplaceAll(plgCfg.Plugin.Version, ".", "_")+".zip") err = addon.Zip(outputFile) if err != nil { log.Fatalln(err) diff --git a/publisher/internal/addon.go b/publisher/internal/addon.go index 0e6daa3..cc67ef0 100644 --- a/publisher/internal/addon.go +++ b/publisher/internal/addon.go @@ -5,6 +5,7 @@ import ( "log" "os" "path/filepath" + "strings" "github.com/pelletier/go-toml/v2" ) @@ -39,10 +40,17 @@ func NewAddon(id string, projectPath string) *Addon { } } +// Id contains the namespace directory and the addon directory name like "kenyoni/addon_name" func (addon *Addon) Id() string { return addon.addonId } +// IdName is only the addon directory name like "addon_name" +func (addon *Addon) IdName() string { + splitted := strings.Split(addon.addonId, "/") + return splitted[len(splitted)-1] +} + func (addon *Addon) ProjectPath() string { return addon.projectPath } @@ -74,7 +82,7 @@ func (addon *Addon) Zip(outputFile string) error { if err != nil { return err } - exampleDir := filepath.Join(addon.ProjectPath(), "examples", addon.Id()) + exampleDir := filepath.Join(addon.ProjectPath(), "examples", addon.IdName()) // zip example directory only if it exists if _, err := os.Stat(exampleDir); err == nil { err = ZipDir(zw, exampleDir, filepath.Join("examples", addon.Id()))