Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing framework in version prefix builder #38

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Make sure to set the required secret CircleCI API token in the repository settin
The action requires the following inputs:

| name | description | required |
|-------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -------- |
| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `gh_token` | The GitHub access token used to authenticate with the Octokit instance. | Yes |
| `circleci_token` | The CircleCI API token used to trigger the build and deploy workflow. | Yes |
| `product` | The name of the product's SDK, such as `chat`, `calls`, `uikit`, `live`, or `live_uikit`. | Yes |
Expand All @@ -67,3 +67,6 @@ You can pass `--test` parameter to command: `/bot create ticket --test`

It mentions the `@{{product}}-approver` Slack group to notify ticket creation in the channel.
If it's a new product, you need to add a Slack group with the corresponding name so that the appropriate people can be mentioned.

The Slack message is sent in the following format:
`@{{product}}-approver 🔖{{product_jira_version_prefix}} {{version}} release ticket has been created!`
22 changes: 12 additions & 10 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,21 @@ export function replaceVersion(link: string, version: string): string {
return link.replace(target, version)
}

export function buildProductJiraVersion(
function platformWithFramework(platform: string, framework?: string): string {
return platform + (framework ? `-${framework}` : '')
}

export function buildJiraVersionPrefix(
platform: string,
product: string
product: string,
framework = ''
): string {
// {product}-{platform}[-{framework}]?
// chat-ios, chat-android, live-uikit-js-react, uikit-js-react

return `${product}-${platform}`
const platformAndFramework = platformWithFramework(platform, framework)
return `${product}-${platformAndFramework}`
}

export function buildReleaseJiraVersion(
platform: string,
product: string,
Expand All @@ -45,8 +50,7 @@ export function buildReleaseJiraVersion(
// {product}-{platform}[-{framework}]?@{version}
// live-uikit-js-react@0.0.0, chat-ios@0.0.0

const platformAndFramework = platformWithFramework(platform, framework)
return `${product}-${platformAndFramework}@${version}`
return `${buildJiraVersionPrefix(platform, product, framework)}@${version}`
}

export function buildReleaseJiraTicket(
Expand All @@ -62,14 +66,11 @@ export function buildReleaseJiraTicket(
return `[${capitalizeProduct(product)}] ${platformAndFramework}@${version}`
}

function platformWithFramework(platform: string, framework?: string): string {
return platform + (framework ? `-${framework}` : '')
}

function capitalizeProduct(str?: string): string {
if (!str) return ''
if (str === 'uikit') return 'UIKit'
if (str === 'live_uikit' || str === 'live-uikit') return 'Live-UIKit'
if (str === 'chat-ai-widget') return 'Chat-AI-Widget'
return capitalize(str)
}

Expand Down
8 changes: 6 additions & 2 deletions src/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import fetch from 'node-fetch'
import type {CommandArguments, CommandParameters} from './command/command'
import {WORKFLOW_REPO, WORKFLOW_SCRIPT_VERSION, WORKFLOWS} from './constants'
import {
buildProductJiraVersion,
buildJiraVersionPrefix,
buildReleaseJiraTicket,
buildReleaseJiraVersion,
extractVersion,
Expand Down Expand Up @@ -121,7 +121,11 @@ async function buildCreateTicketParams(
product_jira_project_key: core.getInput('product_jira_project_key'),
product_jira_version_prefix:
core.getInput('product_jira_version_prefix') ||
buildProductJiraVersion(basicParams.platform, basicParams.product),
buildJiraVersionPrefix(
basicParams.platform,
basicParams.product,
core.getInput('framework').toLowerCase()
),
release_branch: args.branch,
release_version,
release_gh_link: replaceVersion(latestReleaseLink, release_version),
Expand Down
Loading