Giter VIP home page Giter VIP logo

wordpress's Introduction

@semantic-release/wordpress

semantic-release plugin to create a zip file for a WordPress plugin or theme.

node-current (scoped) npm (scoped) Release Scrutinizer coverage (GitHub/BitBucket)

Step Description
verifyConditions Verify if the theme / plugin is valid. Check that the necessary files exist and if they contain needed metadata
prepare Copy the theme / plugins files and optionally prepare the asset bundle
publish Create a zip file for the theme / plugin, and optionally zip the assets
success Clean up the intermediate files

Install

$ npm install -D @semantic-release/wordpress

Usage

The plugin can be configured in the semantic-release configuration file:

{
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    ["@semantic-release/wordpress", {
      "type": "plugin",
      "slug" : "my-plugin",
      "withAssets": true,
      "withReadme": true,
      "withVersionFile": true,
    }]
  ]
}

With this example, for each release, the plugin will:

  • Verify that the plugin is valid
  • Create a zip file for the plugin (/tmp/wp-release/my-plugin.zip)
  • Create a zip file for the assets (/tmp/wp-release/assets.zip)
  • Copy the readme.txt file (/tmp/wp-release/readme.txt)
  • Create a version file (/tmp/wp-release/version.txt)

Configuration

Plugin uses no environment variables, but has a lot of configuration options

Options

Options Description Default
type Type of the package to create. Can be plugin or theme None. You must set this explicitly
slug Package slug. None. You must set this explicitly
path The path of root folder that contains plugin or theme ./
withAssets Does the package have assets (screenshots, banners, logo) false
withReadme Does the package have a readme.txt file false
withVersionFile Do we need to create a file with the next release version true
releasePath Base path for all of the release files /tmp/wp-release
versionFiles Array of additional files containing the package version. []
include Files to include in the package zip file. **/*
exclude Files to exclude from the package zip file List of files and folders defined in constants.ts

Versioning

Plugin will automatically replace versions in your main file (for plugins) and the style.css file (for themes). We follow the WordPress codex, so your plugin file must have the same slug as the plugin folder.

If you have other variables which need to have the version replaced, you can add them to the versionFiles option.

If you need any further processing of the package files, next release version will be output to /tmp/wp-release/VERSION file, if the withVersionFile option is set to true.

Important

Version in your plugin / theme must be set to 0.0.0 for this plugin to work

Assets

If your package is on wp.org repository, you might have assets (screenshots, banners, logos) which you want to include in the assets file. Plugin respects the Codex, and expects those to be in .wordpress-org/assets folder. Main theme screenshot should be named screenshot and should be there as well.

Readme

readme.txt is a special Markdown file needed for packages on wp.org to work. It can be in the .wordpress-org folder, or in the repository root.
Plugin will automatically replace the version in the file if the withReadme option is set to true.

Warning

Version in your readme.txt must also be set to 0.0.0 for this plugin to work

Include / Exclude

By default, plugin will include all files in the package zip file. If you want to exclude some files, you can use the exclude option. It accepts an array of files and folders, and uses glob for path resolution. You can also use the include option which works in the same manner.

Notes

  • Include and exclude options are not mutually exclusive so you can use both.
  • Plugin also looks for .distinclude and .distexclude / .distignore files which take precedence over the options set in the plugin.
  • By default we exclude a lot of build artifacts and files which are not needed in the package. You can see the full list in constants.ts.

Examples

Plugin with assets, readme and additional version files

{
  "plugins": [
    ["@semantic-release/wordpress", {
      "type": "plugin",
      "slug" : "my-plugin",
      "withAssets": true,
      "withReadme": true,
      "withVersionFile": false,
      "versionFiles": [
        "constants.php",
        "includes/db-schema.php"
      ]
    }]
  ]
}

wordpress's People

Contributors

antoninobonanno avatar renovate[bot] avatar seebeen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

wordpress's Issues

Requirement that `readme.txt` is in the `.wordpress-org` Directory is Not the Correct Standard

Current behavior

I'm not sure if this is a documentation issue or an implementation issue but the requirement that the readme.txt needs to be in the .wordpress-org directory seems completely wrong as this is not the correct standard. The readme.txt file is required to be in the root of the plugin or theme directory.

Expected behavior

Support readme.txt in the repository root as is the general best practice.

semantic-release version

"semantic-release": "^22.0.8", "@semantic-release/wordpress": "^1.5.4"

CI environment

Buildkite

Plugins used

  • @semantic-release/commit-analyzer
  • @semantic-release/release-notes-generator
  • @semantic-release/changelog
  • @semantic-release/git
  • @semantic-release/wordpress

semantic-release configuration

{
	"branches": ["main", "feature/Build-Release-Tooling"],
	"tagFormat": "${version}",
	"plugins": [
		[
			"@semantic-release/commit-analyzer",
			{
				"preset": "conventionalcommits"
			}
		],
		[
			"@semantic-release/release-notes-generator",
			{
				"preset": "conventionalcommits",
			}
		],
		[
			"@semantic-release/changelog",
			{
				"changelogFile": "CHANGELOG.md",
				"changelogTitle": "# Change Log"
			}
		],
		[
			"@semantic-release/git",
			{
				"assets": ["CHANGELOG.md"]
			}
		],
		[
			"@semantic-release/wordpress",
			{
				"type": "theme",
				"slug" : "internal-theme-name",
				"withReadme": true,
				"withVersionFile": true
			}
		]
	],
}

CI logs

Just testing this out locally at the moment and trying to get clarification on the correct configuration.

Failure to Complete Creating Package - TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

Current behavior

I'm getting the following results.

An error occurred while running semantic-release: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:405:5)
    at validateString (node:internal/validators:162:11)
    at Module.join (node:path:1171:7)
    at success (file:///node_modules/@semantic-release/[secure]/dist/success.js:6:26)
    at validator (file:///node_modules/semantic-release/lib/plugins/normalize.js:36:30)
    at file:///node_modules/semantic-release/lib/plugins/pipeline.js:38:42
    at next (file:///node_modules/semantic-release/node_modules/p-reduce/index.js:16:10) {
  code: 'ERR_INVALID_ARG_TYPE',
  pluginName: '@semantic-release/[secure]'
}
AggregateError: 
    TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
        at success (file:///node_modules/@semantic-release/[secure]/dist/success.js:6:26)
        at validator (file:///node_modules/semantic-release/lib/plugins/normalize.js:36:30)
        at file:///node_modules/semantic-release/lib/plugins/pipeline.js:38:42
        at next (file:///node_modules/semantic-release/node_modules/p-reduce/index.js:16:10)
    at file:///node_modules/semantic-release/lib/plugins/pipeline.js:55:13
    at async pluginsConfigAccumulator.<computed> [as success] (file:///node_modules/semantic-release/lib/plugins/index.js:87:11)
    at async run (file:///node_modules/semantic-release/index.js:215:3)
    at async Module.default (file:///node_modules/semantic-release/index.js:275:22)
    at async default (file:///node_modules/semantic-release/cli.js:55:5) {
  errors: [
    TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
        at new NodeError (node:internal/errors:405:5)
        at validateString (node:internal/validators:162:11)
        at Module.join (node:path:1171:7)
        at success (file:///node_modules/@semantic-release/[secure]/dist/success.js:6:26)
        at validator (file:///node_modules/semantic-release/lib/plugins/normalize.js:36:30)
        at file:///node_modules/semantic-release/lib/plugins/pipeline.js:38:42
        at next (file:///node_modules/semantic-release/node_modules/p-reduce/index.js:16:10) {
      code: 'ERR_INVALID_ARG_TYPE',
      pluginName: '@semantic-release/[secure]'
    }
  ]
}

Expected behavior

The release package is completed successfully.

semantic-release version

"semantic-release": "^22.0.8", "@semantic-release/wordpress": "^1.5.4"

CI environment

Buildkite/Local

Plugins used

No response

semantic-release configuration

{
	"branches": [
		{
			"name": "main",
			"channel": "main"
		},
		{
			"name": "develop",
			"prerelease": "rc"
		},
		{
			"name": "feature/Build-Release-Tooling",
			"prerelease": "beta"
		}
	],
	"ci": false,
	"tagFormat": "${version}",
	"plugins": [
		"@semantic-release/commit-analyzer",
		"@semantic-release/release-notes-generator",
		[
			"@semantic-release/changelog",
			{
				"changelogFile": "CHANGELOG.md",
				"changelogTitle": "# Change Log"
			}
		],
		[
			"@semantic-release/exec",
			{
				"prepareCmd": "npm run build"
			}
		],
		[
			"@semantic-release/git",
			{
				"assets": [
					"CHANGELOG.md"
				]
			}
		],
		[
			"@semantic-release/wordpress",
			{
				"type": "theme",
				"slug": "internal-theme-name",
				"withAssets": false,
				"withReadme": true,
				"withVersionFile": true,
				"include": [
					"build"
				],
				"versionFiles": [
					"style.css"
				]
			}
		]
	],
	"preset": "conventionalcommits",
	"publishConfig": {
		"access": "restricted"
	}
}

CI logs

[9:55:14 PM] [semantic-release] › ✔  Completed step "prepare" of plugin "@semantic-release/exec"
[9:55:14 PM] [semantic-release] › ℹ  Start step "prepare" of plugin "@semantic-release/git"
[9:55:14 PM] [semantic-release] [@semantic-release/git] › ℹ  Found 1 file(s) to commit
[9:55:16 PM] [semantic-release] [@semantic-release/git] › ℹ  Prepared Git release: 0.2.0-beta.1
[9:55:16 PM] [semantic-release] › ✔  Completed step "prepare" of plugin "@semantic-release/git"
[9:55:16 PM] [semantic-release] › ℹ  Start step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[9:55:16 PM] [semantic-release] › ✔  Completed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[9:55:16 PM] [semantic-release] › ℹ  Start step "generateNotes" of plugin "@semantic-release/exec"
[9:55:16 PM] [semantic-release] › ✔  Completed step "generateNotes" of plugin "@semantic-release/exec"
[9:55:16 PM] [semantic-release] › ℹ  Start step "prepare" of plugin "@semantic-release/[secure]"
[9:55:16 PM] [semantic-release] › ✔  Completed step "prepare" of plugin "@semantic-release/[secure]"
[9:55:18 PM] [semantic-release] › ✔  Created tag 0.2.0-beta.1
[9:55:18 PM] [semantic-release] › ℹ  Start step "publish" of plugin "@semantic-release/exec"
[9:55:18 PM] [semantic-release] › ✔  Completed step "publish" of plugin "@semantic-release/exec"
[9:55:18 PM] [semantic-release] › ℹ  Start step "publish" of plugin "@semantic-release/[secure]"
[9:55:18 PM] [semantic-release] › ✔  Completed step "publish" of plugin "@semantic-release/[secure]"
[9:55:18 PM] [semantic-release] › ℹ  Start step "success" of plugin "@semantic-release/exec"
[9:55:18 PM] [semantic-release] › ✔  Completed step "success" of plugin "@semantic-release/exec"
[9:55:18 PM] [semantic-release] › ℹ  Start step "success" of plugin "@semantic-release/[secure]"
[9:55:18 PM] [semantic-release] › ✘  Failed step "success" of plugin "@semantic-release/[secure]"
[9:55:18 PM] [semantic-release] › ✘  An error occurred while running semantic-release: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

Exclude not excluding files in nested folders

Current behavior

Files that should be excluded remain in the release in the release output.

In the example below...

  • example.js is removed from the root
  • assets/test.js remains in the output
  • Everything in assets/src remains in the output

Expected behavior

Files that match the exclude pattern should be excluded from the release output.

In the example below...

  • example.js should be removed from the root
  • assets/test.js should be removed from the assets directory
  • Everything in assets/src should be removed

semantic-release version

22.0.12

CI environment

GitHub Actions

Plugins used

@semantic-release/changelog
@semantic-release/git
@semantic-release/github
@semantic-release/wordpress

semantic-release configuration

.distignore

assets/src/**/*.*
assets/test.js
example.js

.releaserc

{
    "branches": [
        "main"
    ],
    "plugins": [
        "@semantic-release/commit-analyzer",
        "@semantic-release/release-notes-generator",        
        [
            "@semantic-release/changelog",
            {
                "changelogFile": "CHANGELOG.md"
            }
        ],
        [
            "@semantic-release/wordpress",
            {
                "type": "plugin",
                "slug": "demo-wsu-plugin",
                "releasePath": "/tmp/release",
                "withAssets": false,
                "withReadme": true,
                "withVersionFile": false,
                "versionFiles": [
                    "includes/plugin.php"
                ]
            }
        ],
        [
            "@semantic-release/github",
            {
                "assets": [
                    {
                        "path": "/tmp/release/package.zip",
                        "name": "release-${nextRelease.version}.zip"
                    }
                ]
            }
        ],
        [
            "@semantic-release/git",
            {
                "assets": [
                    "CHANGELOG.md"
                ],
                "message": "chore(release): set version refs to ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
            }
        ]
    ]
}

CI logs

Run webteam/demo--gh-actions/.github/actions/standard-release@main
Run npm install @semantic-release/changelog @semantic-release/git @semantic-release/github @semantic-release/wordpress @semantic-release/exec
npm WARN deprecated [email protected]: Renamed to read-package-up
added 227 packages, and audited 1981 packages in 9s
298 packages are looking for funding
run npm fund for details
found 0 vulnerabilities
Run npx semantic-release
[6:16:49 PM] [semantic-release] › ℹ Running semantic-release version 22.0.12
[6:16:49 PM] [semantic-release] › ℹ Running semantic-release version 22.0.12
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/exec"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/changelog"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/wordpress"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/github"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/git"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "analyzeCommits" from "@semantic-release/exec"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "verifyRelease" from "@semantic-release/exec"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "generateNotes" from "@semantic-release/exec"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "prepare" from "@semantic-release/exec"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "prepare" from "@semantic-release/changelog"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "prepare" from "@semantic-release/wordpress"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "prepare" from "@semantic-release/git"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "publish" from "@semantic-release/exec"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "publish" from "@semantic-release/wordpress"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "publish" from "@semantic-release/github"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "addChannel" from "@semantic-release/exec"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "addChannel" from "@semantic-release/github"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "success" from "@semantic-release/exec"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "success" from "@semantic-release/wordpress"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "success" from "@semantic-release/github"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "fail" from "@semantic-release/exec"
[6:16:50 PM] [semantic-release] › ✔ Loaded plugin "fail" from "@semantic-release/github"
[6:16:51 PM] [semantic-release] › ✔ Run automated release from branch main on repository https://github.com/webteam/demo--plugin
[6:16:51 PM] [semantic-release] › ✔ Allowed to push to the Git repository
[6:16:51 PM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/exec"
[6:16:51 PM] [semantic-release] › ℹ Start step "verifyConditions" of plugin "@semantic-release/changelog"
[6:16:51 PM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/changelog"
[6:16:51 PM] [semantic-release] › ℹ Start step "verifyConditions" of plugin "@semantic-release/wordpress"
[6:16:51 PM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/wordpress"
[6:16:51 PM] [semantic-release] › ℹ Start step "verifyConditions" of plugin "@semantic-release/github"
[6:16:51 PM] [semantic-release] [@semantic-release/github] › ℹ Verify GitHub authentication (https://api.github.com)
[6:16:51 PM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/github"
[6:16:51 PM] [semantic-release] › ℹ Start step "verifyConditions" of plugin "@semantic-release/git"
[6:16:51 PM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/git"
[6:16:51 PM] [semantic-release] › ℹ Found git tag v1.6.5 associated with version 1.6.5 on branch main
[6:16:51 PM] [semantic-release] › ℹ Found 1 commits since last release
[6:16:51 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[6:16:51 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ Analyzing commit: fix: again
[6:16:51 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ The release type for the commit is patch
[6:16:51 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ Analysis of 1 commits complete: patch release
[6:16:51 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[6:16:51 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "@semantic-release/exec"
[6:16:51 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "@semantic-release/exec"
[6:16:51 PM] [semantic-release] › ℹ The next release version is 1.6.6
[6:16:51 PM] [semantic-release] › ℹ Start step "verifyRelease" of plugin "@semantic-release/exec"
[6:16:51 PM] [semantic-release] › ✔ Completed step "verifyRelease" of plugin "@semantic-release/exec"
[6:16:51 PM] [semantic-release] › ℹ Start step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[6:16:51 PM] [semantic-release] › ✔ Completed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[6:16:51 PM] [semantic-release] › ℹ Start step "generateNotes" of plugin "@semantic-release/exec"
[6:16:51 PM] [semantic-release] › ✔ Completed step "generateNotes" of plugin "@semantic-release/exec"
[6:16:51 PM] [semantic-release] › ℹ Start step "prepare" of plugin "@semantic-release/exec"
[6:16:51 PM] [semantic-release] › ✔ Completed step "prepare" of plugin "@semantic-release/exec"
[6:16:51 PM] [semantic-release] › ℹ Start step "prepare" of plugin "@semantic-release/changelog"
[6:16:51 PM] [semantic-release] [@semantic-release/changelog] › ℹ Update /home/runner/work/demo--plugin/demo--plugin/demo--plugin/CHANGELOG.md
[6:16:51 PM] [semantic-release] › ✔ Completed step "prepare" of plugin "@semantic-release/changelog"
[6:16:51 PM] [semantic-release] › ℹ Start step "prepare" of plugin "@semantic-release/wordpress"
[6:16:51 PM] [semantic-release] › ✔ Completed step "prepare" of plugin "@semantic-release/wordpress"
[6:16:51 PM] [semantic-release] › ℹ Start step "prepare" of plugin "@semantic-release/git"
[6:16:52 PM] [semantic-release] [@semantic-release/git] › ℹ Found 1 file(s) to commit
[6:16:52 PM] [semantic-release] [@semantic-release/git] › ℹ Prepared Git release: v1.6.6
[6:16:52 PM] [semantic-release] › ✔ Completed step "prepare" of plugin "@semantic-release/git"
[6:16:52 PM] [semantic-release] › ℹ Start step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[6:16:52 PM] [semantic-release] › ✔ Completed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[6:16:52 PM] [semantic-release] › ℹ Start step "generateNotes" of plugin "@semantic-release/exec"
[6:16:52 PM] [semantic-release] › ✔ Completed step "generateNotes" of plugin "@semantic-release/exec"
[6:16:54 PM] [semantic-release] › ✔ Created tag v1.6.6
[6:16:54 PM] [semantic-release] › ✔ Completed step "publish" of plugin "@semantic-release/exec"
[6:16:54 PM] [semantic-release] › ℹ Start step "publish" of plugin "@semantic-release/wordpress"
[6:16:54 PM] [semantic-release] › ✔ Completed step "publish" of plugin "@semantic-release/wordpress"
[6:16:54 PM] [semantic-release] › ℹ Start step "publish" of plugin "@semantic-release/github"
[6:16:55 PM] [semantic-release] [@semantic-release/github] › ℹ Published file https://github.com/webteam/demo--plugin/releases/download/untagged-be8fbbc96e395e0c0456/release-1.6.6.zip
[6:16:56 PM] [semantic-release] [@semantic-release/github] › ℹ Published GitHub release: https://github.com/webteam/demo--plugin/releases/tag/v1.6.6
[6:16:56 PM] [semantic-release] › ✔ Completed step "publish" of plugin "@semantic-release/github"
[6:16:56 PM] [semantic-release] › ℹ Start step "success" of plugin "@semantic-release/exec"
[6:16:56 PM] [semantic-release] › ✔ Completed step "success" of plugin "@semantic-release/exec"
[6:16:56 PM] [semantic-release] › ℹ Start step "success" of plugin "@semantic-release/wordpress"
[6:16:56 PM] [semantic-release] › ✔ Completed step "success" of plugin "@semantic-release/wordpress"
[6:16:56 PM] [semantic-release] › ℹ Start step "success" of plugin "@semantic-release/github"
[6:16:58 PM] [semantic-release] › ✔ Completed step "success" of plugin "@semantic-release/github"
[6:16:58 PM] [semantic-release] › ✔ Published release 1.6.6 on default channel

Bug theme when specify path verify stage

Hi @seebeen, thanks for the immediate response.
I did a test but with this configuration the file verification fails.

[
    "@semantic-release/wordpress",
    {
        "type": "theme",
        "slug" : "my-theme",
        "withReadme": true,
        "copyFiles": false,
        "releasePath": "/tmp/wp-release",
        "path": "./dist/my-theme"
    }
],

i think because inside verify-theme.ts concat path with slug.

? path.resolve(config.path, config.slug)

So the path in verify state is "./dist/my-theme/my-theme" and in prepare state is "./dist/my-theme"

In my case the correct path is "./dist/my-theme".

[5:13:15 PM] [semantic-release] › ✘  ETHEMEFILENOTFOUND Your theme must contain these files: style.css, functions.php
Check if the files exist, and if not create them: style.css, functions.php.
AggregateError: 
    SemanticReleaseError: Your theme must contain these files: style.css, functions.php
        at getError (file:///builds/my-theme/theme/node_modules/@semantic-release/wordpress/dist/utils/get-error.js:5:12)
        at verifyTheme (file:///builds/my-theme/theme/node_modules/@semantic-release/wordpress/dist/utils/verify-theme.js:13:13)
        at async verifyConditions (file:///builds/my-theme/theme/node_modules/@semantic-release/wordpress/dist/verify-conditions.js:12:17)
        at async validator (file:///builds/my-theme/theme/node_modules/semantic-release/lib/plugins/normalize.js:36:24)
        at async file:///builds/my-theme/theme/node_modules/semantic-release/lib/plugins/pipeline.js:38:36
        at async Promise.all (index 0)
        at async next (file:///builds/my-theme/theme/node_modules/semantic-release/node_modules/p-reduce/index.js:15:44)
    at file:///builds/my-theme/theme/node_modules/semantic-release/lib/plugins/pipeline.js:55:13
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async pluginsConfigAccumulator.<computed> [as verifyConditions] (file:///builds/my-theme/theme/node_modules/semantic-release/lib/plugins/index.js:87:11)
    at async run (file:///builds/my-theme/theme/node_modules/semantic-release/index.js:106:3)
    at async Module.default (file:///builds/my-theme/theme/node_modules/semantic-release/index.js:275:22)
    at async default (file:///builds/my-theme/theme/node_modules/semantic-release/cli.js:55:5) {
  errors: [
    SemanticReleaseError: Your theme must contain these files: style.css, functions.php
        at getError (file:///builds/my-theme/theme/node_modules/@semantic-release/wordpress/dist/utils/get-error.js:5:12)
        at verifyTheme (file:///builds/my-theme/theme/node_modules/@semantic-release/wordpress/dist/utils/verify-theme.js:13:13)
        at async verifyConditions (file:///builds/my-theme/theme/node_modules/@semantic-release/wordpress/dist/verify-conditions.js:12:17)
        at async validator (file:///builds/my-theme/theme/node_modules/semantic-release/lib/plugins/normalize.js:36:24)
        at async file:///builds/my-theme/theme/node_modules/semantic-release/lib/plugins/pipeline.js:38:36
        at async Promise.all (index 0)
        at async next (file:///builds/my-theme/theme/node_modules/semantic-release/node_modules/p-reduce/index.js:15:44) {
      code: 'ETHEMEFILENOTFOUND',
      details: 'Check if the files exist, and if not create them: style.css, functions.php.',
      semanticRelease: true,
      pluginName: '@semantic-release/wordpress'
    }
  ]

For test this user case, the prepare.specs.ts and verify-theme.spec.ts must have the same options

{
      type: 'theme',
      slug: 'complete-theme',
      path: './test/fixtures/complete-theme',
      copyFiles: false,
}

Originally posted by @AntoninoBonanno in #120 (comment)

zip command not found

If the zip command is not present this code will return an error but packageResult.stderr is empty and the publish stage will be triggered anyway.
Then it shows an error on the screen that is not easily understandable.

wordpress/lib/publish.ts

Lines 18 to 35 in e8b42e5

const zipCommand = process.env.ZIP_COMMAND ?? 'zip';
const packageResult = await execa(
zipCommand,
['-qr', path.join(releaseDir, `package.zip`), config.slug],
{
reject: false,
cwd: config.releasePath,
timeout: 30 * 1000,
},
);
if (
('exitCode' in packageResult && packageResult.exitCode !== 0) ||
('code' in packageResult && packageResult.code !== 0)
) {
throw getError('EZIP', packageResult.stderr);
}

It would be a good idea to check whether the zip command is already present during the verify stage.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update babel monorepo (@babel/core, @babel/preset-env)
  • chore(deps): update dependency @types/node to v20.14.13
  • ci(action): update actions/setup-node action to v4.0.3
  • chore(deps): update dependency eslint-plugin-prettier to v5.2.1
  • chore(deps): update dependency ts-jest to v29.2.3
  • chore(deps): update dependency rimraf to v6
  • chore(deps): update dependency sinon to v18
  • fix(deps): update dependency execa to v9
  • fix(deps): update dependency glob to v11
  • fix(deps): update dependency replace-in-file to v8
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/release.yml
  • actions/checkout v4.1.7@692973e3d937129bcbf40652eb9f2f61becf3332
  • actions/setup-node v4.0.2@60edb5dd545a775178f52524783378180af0d1f8
.github/workflows/test.yml
  • actions/checkout v4.1.7@692973e3d937129bcbf40652eb9f2f61becf3332
  • actions/setup-node v4.0.2@60edb5dd545a775178f52524783378180af0d1f8
  • actions/checkout v4.1.7@692973e3d937129bcbf40652eb9f2f61becf3332
  • actions/setup-node v4.0.2@60edb5dd545a775178f52524783378180af0d1f8
npm
package.json
  • @semantic-release/error ^4.0.0
  • class-transformer ^0.5.1
  • class-transformer-validator ^0.9.1
  • class-validator ^0.14.0
  • execa ^8.0.1
  • fs-extra ^11.1.1
  • glob ^10.3.3
  • read-pkg ^9.0.0
  • reflect-metadata ^0.2.0
  • replace-in-file ^7.0.1
  • @babel/core 7.24.7
  • @babel/preset-env 7.24.7
  • @types/fs-extra 11.0.4
  • @types/jest 29.5.12
  • @types/node 20.14.7
  • @types/semantic-release__error 3.0.3
  • @types/signale 1.4.7
  • @types/sinon 17.0.3
  • @typescript-eslint/eslint-plugin 6.19.0
  • @typescript-eslint/parser 6.19.0
  • babel-jest 29.7.0
  • eslint 8.56.0
  • eslint-config-prettier 9.1.0
  • eslint-plugin-prettier 5.1.3
  • jest 29.7.0
  • prettier 3.2.4
  • rimraf 5.0.5
  • semantic-release 23.0.8
  • signale 1.4.0
  • sinon 17.0.1
  • ts-jest 29.1.5
  • typescript 5.3.3
  • semantic-release ^21.0.7 || ^22.0.0 || ^23.0.0
  • node >= 18
nvm
.nvmrc
  • node 20

  • Check this box to trigger a request for Renovate to run again on this repository

Bug theme when specify path

Current behavior

hi @seebeen,

I generate my theme files inside the dist folder and I want the version to be replaced in this folder and then proceed to create the .zip file.

image

So i use this configuration

[
    "@semantic-release/wordpress",
    {
        "type": "theme",
        "slug" : "my-theme",
        "withReadme": true,
        "copyFiles": false,
        "releasePath": "/tmp/wp-release",
        "path": "./dist/"
    }
],

the verification step is successful but when the version replacement is carried out I get an error.

I think the file is not found because in verify-theme.ts the path is concatenated with the slug

? path.resolve(config.path, config.slug)

however in prepare.ts the path is not concatenated with the slug

: path.resolve(path.resolve(config.path));

My style.css is correct

/*
Theme Name: My Theme
Theme URI: https://gitlab.com....
Author: Antonino Bonanno
Version: 0.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: my-theme
Text Domain: my-theme
Requires at least: 6.3
Tested up to: 6.3.0
Requires PHP: 8.1
*/

Expected behavior

The version is replaced and the zip is passed through a specific path

semantic-release version

22.0.5

CI environment

GitLab

Plugins used

"@semantic-release/wordpress": "^1.5.3",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/gitlab": "^12.0.6",

semantic-release configuration

[
    "@semantic-release/wordpress",
    {
        "type": "theme",
        "slug" : "my-theme",
        "withReadme": true,
        "copyFiles": false,
        "releasePath": "/tmp/wp-release",
        "path": "./dist/"
    }
],

CI logs

[11:30:50 PM] [semantic-release] › ✘  EFILEINVALID File is invalid: style.css
The file is invalid: style.css.
AggregateError
    at prepare (file:///builds/my-theme/theme/node_modules/@semantic-release/wordpress/dist/prepare.js:28:15)
    at async validator (file:///builds//my-theme/theme/node_modules/semantic-release/lib/plugins/normalize.js:36:24)
    at async file:///builds//my-theme/theme/node_modules/semantic-release/lib/plugins/pipeline.js:38:36
    at async Promise.all (index 0)
    at async next (file:///builds//my-theme/theme/node_modules/semantic-release/node_modules/p-reduce/index.js:15:44) {
  [errors]: [
    SemanticReleaseError: File is invalid: style.css
        at getError (file:///builds//my-theme/theme/node_modules/@semantic-release/wordpress/dist/utils/get-error.js:5:12)
        at replaceVersions (file:///builds//my-theme/theme/node_modules/@semantic-release/wordpress/dist/utils/replace-versions.js:20:25)
        at async prepare (file:///builds//my-theme/theme/node_modules/@semantic-release/wordpress/dist/prepare.js:26:21)
        at async validator (file:///builds//my-theme/theme/node_modules/semantic-release/lib/plugins/normalize.js:36:24)
        at async file:///builds//my-theme/theme/node_modules/semantic-release/lib/plugins/pipeline.js:38:36
        at async Promise.all (index 0)
        at async next (file:///builds//my-theme/theme/node_modules/semantic-release/node_modules/p-reduce/index.js:15:44) {
      code: 'EFILEINVALID',
      details: 'The file is invalid: style.css.',
      semanticRelease: true,
      pluginName: '@semantic-release/wordpress'
    }
  ]
}

Upgrade for semantic-release v24

New feature motivation

Update the library to support semantic-release v24

New feature description

Upgrade for semantic-release v24

New feature implementation

No response

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (github>semantic-release/.github)

DOCS: Update zip name

In the documentation the zip name is my-plugin.zip (<slug>.zip)

* Create a zip file for the plugin (/tmp/wp-release/my-plugin.zip)

but inside code and test the name of zip is package.zip

wordpress/lib/publish.ts

Lines 20 to 28 in e8b42e5

const packageResult = await execa(
zipCommand,
['-qr', path.join(releaseDir, `package.zip`), config.slug],
{
reject: false,
cwd: config.releasePath,
timeout: 30 * 1000,
},
);

expect(files).toContain('package.zip');

and actually the name of the generated zip file is package.zip

Upgrade to semantic-release v23

New feature motivation

npm ERR! Could not resolve dependency:
npm ERR! peer semantic-release@"^21.0.7 || ^22.0.0" from @semantic-release/[email protected]
npm ERR! node_modules/@semantic-release/wordpress
npm ERR! dev @semantic-release/wordpress@"^1.6.1" from the root project

New feature description

Close #212

New feature implementation

No response

DOCS: Listed as `.distexclude` but actually is `.distignore`

New feature motivation

The pre-existing convention with many other tools is a .distignore file. It would be better to leverage this more widely used convention.

New feature description

Support .distignore as the default with .distexclude as a deprecated backwards compatible option.

New feature implementation

Actually, a note that as I was searching through the code I don't actually see any support for .distexclude. I see tests for .distinclude but no tests or references to .distexclude at all.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.