Skip to content

Commit

Permalink
Merge pull request #10 from Maddimax/releases/v2.7
Browse files Browse the repository at this point in the history
Added 'published' parameter
  • Loading branch information
Maddimax authored Aug 14, 2024
2 parents dc8d1e1 + 82774fb commit a91a973
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 31 deletions.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ inputs:
download-url:
description: 'The url to download the extension from'
required: true
publish:
description: 'Whether to immediately set status to "published"'
required: false
default: 'false'

# Define your outputs here.
#outputs:
Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 13 additions & 11 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.

33 changes: 17 additions & 16 deletions src/extensionstore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface PluginMetaData {
Category: string
Description: string
Url: string
[name: string]: string
Tags: string[]
}

interface PlatformDescriptor {
Expand Down Expand Up @@ -91,7 +91,8 @@ interface Versions {
function createPluginSets(
downloadUrl: string,
pluginMetaData: PluginMetaData,
qtcVersion: Versions
qtcVersion: Versions,
publish: boolean
): PluginSet[] {
const osArr = [
{
Expand All @@ -118,7 +119,7 @@ function createPluginSets(
)
return allPlatforms.map(platform => {
return {
status: 'draft',
status: publish ? 'published' : 'draft',
core_version: qtcVersion.version,
core_compat_version: qtcVersion.compat_version,
host_os: platform.name,
Expand All @@ -137,20 +138,20 @@ function createPluginSets(
}

function createSaveRequest(
pluginName: string,
vendorName: string,
version: string,
pluginSets: PluginSet[]
pluginMetaData: PluginMetaData,
pluginSets: PluginSet[],
publish: boolean
): ExtensionSaveRequest {
return {
name: pluginName,
vendor: vendorName,
name: pluginMetaData.Name,
vendor: pluginMetaData.Vendor,
compatibility: 'Qt 6.0',
platforms: ['Windows', 'macOS', 'Linux'],
license: 'os',
version,
status: 'draft',
version: pluginMetaData.Version,
status: publish ? 'published' : 'draft',
is_pack: false,
tags: pluginMetaData.Tags,
plugin_sets: pluginSets
}
}
Expand Down Expand Up @@ -186,7 +187,8 @@ export async function createOrUpdateExtension(
pluginMetaData: PluginMetaData,
qtcVersion: Versions,
apiUrl: string,
apiToken: string
apiToken: string,
publish: boolean
): Promise<void> {
core.debug(`Creating or updating extension ${pluginMetaData.Name}`)
const search = await request(
Expand All @@ -201,10 +203,9 @@ export async function createOrUpdateExtension(

const saveRequest = JSON.stringify(
createSaveRequest(
pluginMetaData.Name,
pluginMetaData.Vendor,
pluginMetaData.Version,
createPluginSets(downloadUrl, pluginMetaData, qtcVersion)
pluginMetaData,
createPluginSets(downloadUrl, pluginMetaData, qtcVersion, publish),
publish
)
)

Expand Down
8 changes: 6 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ import { createOrUpdateExtension, PluginMetaData } from './extensionstore'
export async function run(): Promise<void> {
try {
const specPath: string = core.getInput('spec')
const isTest: boolean = core.getInput('test') === 'true'
const isTest: boolean =
core.getInput('test', { required: false }) === 'true'
const downloadUrl: string = core.getInput('download-url')
const api: string = core.getInput('api')
const token: string = core.getInput('token')
const publish: boolean =
core.getInput('publish', { required: false }) === 'true'

const spec = await fs.readFile(specPath)
const asJson = JSON.parse(jsonFromSpec(spec.toString()))
Expand All @@ -33,7 +36,8 @@ export async function run(): Promise<void> {
asJson as unknown as PluginMetaData,
{ version: '14.0.0', compat_version: '14.0.0' },
api,
token
token,
publish
)

//core.setOutput('outputJson', asJson)
Expand Down

0 comments on commit a91a973

Please sign in to comment.