Skip to content

Commit

Permalink
feat: add working-directory input (#210)
Browse files Browse the repository at this point in the history
Closes #209
  • Loading branch information
jessebye authored Nov 15, 2024
1 parent a9d6d15 commit b621d34
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
repository-url: https://github.com/codfish/semantic-release-action.git
extends: '@semantic-release/apm-config'
tag-format: 'ver${version}'
working-directory: .
additional-packages: |
['@semantic-release/apm', '@semantic-release/git']
plugins: |
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ defined in your repo (`.releaserc`, `release.config.js`, `release` prop in `pack
| `extends` | `Array`, `String` | List of modules or file paths containing a shareable configuration. | [Semantic default](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#extends) |
| `additional-packages` | `Array`, `String` | Define a list of additional plugins/configurations (official or community) to install. Use this if you 1) use any plugins other than the defaults, which are already installed along with semantic-release or 2) want to extend from a shareable configuration. | `[]` |
| `dry-run` | `Boolean` | The objective of the dry-run mode is to get a preview of the pending release. Dry-run mode skips the following steps: prepare, publish, success and fail. | [Semantic default](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#dryrun) |
| `working-directory` | `String` | The working directory to use for all semantic-release actions. | `.` |
| `repository-url` | `String` | The git repository URL | [Semantic default](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#repositoryurl) |
| `tag-format` | `String` | The Git tag format used by semantic-release to identify releases. | [Semantic default](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#tagformat) |

Expand Down Expand Up @@ -266,6 +267,7 @@ steps:
]
repository-url: https://github.com/codfish/semantic-release-action.git
tag-format: 'v${version}'
working-directory: dist
extends: '@semantic-release/apm-config'
additional-packages: |
['@semantic-release/[email protected]', '@semantic-release/git']
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ inputs:
'The Git tag format used by semantic-release to identify releases.
https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#tagformat'
required: false
working-directory:
description: 'The working directory to use for all semantic-release actions.'
required: false
branch:
description:
'DEPRECATED. Will continue to be supported for v1. Use `branches` instead. Previously used in
Expand Down Expand Up @@ -88,4 +91,5 @@ runs:
- ${{ inputs.dry-run }}
- ${{ inputs.repository-url }}
- ${{ inputs.tag-format }}
- ${{ inputs.working-directory }}
- ${{ inputs.branch }}
7 changes: 5 additions & 2 deletions entrypoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ const setGitConfigSafeDirectory = () => {
* @see https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#options
*/
async function run() {
const workingDirectory =
parseInput(core.getInput('working-directory', { required: false })) || '.';
const configFile = await cosmiconfig('release')
.search()
.search(workingDirectory)
.then((result) => result?.config);
const branch = parseInput(core.getInput('branch', { required: false }));
// Branches are parsed in this order:
Expand Down Expand Up @@ -112,6 +114,7 @@ async function run() {
core.debug(`dry-run input: ${dryRun}`);
core.debug(`repository-url input: ${repositoryUrl}`);
core.debug(`tag-format input: ${tagFormat}`);
core.debug(`working-directory input: ${workingDirectory}`);

setGitConfigSafeDirectory();

Expand Down Expand Up @@ -143,7 +146,7 @@ async function run() {

core.debug(`options after cleanup: ${JSON.stringify(options)}`);

const result = await semanticRelease(options);
const result = await semanticRelease(options, { cwd: workingDirectory });
if (!result) {
core.debug('No release published');

Expand Down

0 comments on commit b621d34

Please sign in to comment.