102 lines
4.0 KiB
YAML
102 lines
4.0 KiB
YAML
name: npm-get-next-branched-version
|
|
description: "Get the next version of an NPM package based on the current branch status."
|
|
inputs:
|
|
name:
|
|
description: "The name of the package."
|
|
required: true
|
|
defaultVersion:
|
|
description: "Default version to use."
|
|
required: true
|
|
default: "1.0.0"
|
|
url:
|
|
description: "URL of the Gitea server instance."
|
|
required: false
|
|
default: ${{ github.server_url }}
|
|
organization:
|
|
description: "Organization to search."
|
|
required: false
|
|
default: ${{ github.repository_owner }}
|
|
apiKey:
|
|
description: "API token for Gitea."
|
|
required: true
|
|
default: ${{ github.token }}
|
|
prerelease:
|
|
description: "Query prerelease packages. Values: true, false."
|
|
required: false
|
|
default: "${{ github.event_name == 'pull_request' }}"
|
|
incrementMode:
|
|
description: "The mode to increment by. Options: 'default', 'major', 'minor', 'patch'"
|
|
required: false
|
|
default: patch
|
|
outputs:
|
|
latestVersion:
|
|
description: "The current latest version for the package."
|
|
value: ${{ steps.gitea.outputs.version || steps.giteaFallback.outputs.version }}
|
|
nextVersion:
|
|
description: "The next version for the package."
|
|
value: ${{ steps.version.outputs.nextVersion }}
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: "Get the base version for the package."
|
|
uses: act/common/utils/version-increment-branch@master
|
|
id: base
|
|
with:
|
|
version: ${{ inputs.defaultVersion }}
|
|
- name: "Debug - Base version info"
|
|
run: |
|
|
echo "Default version: '${{ inputs.defaultVersion }}'"
|
|
echo "Base version: '${{ steps.base.outputs.baseVersion }}'"
|
|
echo "Major.Minor.Patch version: '${{ steps.base.outputs.majorMinorPatchVersion }}'"
|
|
echo "Prerelease mode: '${{ inputs.prerelease }}'"
|
|
shell: bash
|
|
- uses: act/common/gitea/gitea-query-package-versions-latest@master
|
|
id: gitea
|
|
with:
|
|
name: ${{ inputs.name }}
|
|
url: ${{ inputs.url }}
|
|
organization: ${{ inputs.organization }}
|
|
apiToken: ${{ inputs.apiKey }}
|
|
type: npm
|
|
filter: ^${{ steps.base.outputs.baseVersion }}
|
|
filterIsExpression: "true"
|
|
prerelease: ${{ inputs.prerelease }}
|
|
- name: "Debug - First query results"
|
|
run: |
|
|
echo "Query filter: '^${{ steps.base.outputs.baseVersion }}'"
|
|
echo "Found version: '${{ steps.gitea.outputs.version }}'"
|
|
echo "Will run fallback: ${{ steps.gitea.outputs.version == '' && inputs.prerelease != 'false' }}"
|
|
shell: bash
|
|
- name: "If no version is found, get the latest version for the package if we didn't already look for it."
|
|
uses: act/common/gitea/gitea-query-package-versions-latest@master
|
|
id: giteaFallback
|
|
if: ${{ steps.gitea.outputs.version == '' && inputs.prerelease != 'false' }}
|
|
with:
|
|
name: ${{ inputs.name }}
|
|
url: ${{ inputs.url }}
|
|
organization: ${{ inputs.organization }}
|
|
apiToken: ${{ inputs.apiKey }}
|
|
type: npm
|
|
filter: ^${{ steps.base.outputs.majorMinorPatchVersion }}
|
|
filterIsExpression: "true"
|
|
prerelease: "false"
|
|
- name: "Debug - Fallback query results"
|
|
if: ${{ steps.giteaFallback.conclusion != 'skipped' }}
|
|
run: |
|
|
echo "Fallback filter: '^${{ steps.base.outputs.majorMinorPatchVersion }}'"
|
|
echo "Fallback found version: '${{ steps.giteaFallback.outputs.version }}'"
|
|
shell: bash
|
|
- name: "Get the next version for the package."
|
|
uses: act/common/utils/version-increment-branch@master
|
|
id: version
|
|
with:
|
|
incrementMode: ${{ inputs.incrementMode }}
|
|
version: ${{ steps.gitea.outputs.version || steps.giteaFallback.outputs.version || inputs.defaultVersion }}
|
|
- name: "Debug - Final version info"
|
|
run: |
|
|
echo "Increment mode: '${{ inputs.incrementMode }}'"
|
|
echo "Base for increment: '${{ steps.gitea.outputs.version || steps.giteaFallback.outputs.version || inputs.defaultVersion }}'"
|
|
echo "Latest version (output): '${{ steps.gitea.outputs.version || steps.giteaFallback.outputs.version }}'"
|
|
echo "Next version (output): '${{ steps.version.outputs.nextVersion }}'"
|
|
shell: bash
|