Skip to content

Commit a91a973

Browse files
authored
Merge pull request #10 from Maddimax/releases/v2.7
Added 'published' parameter
2 parents dc8d1e1 + 82774fb commit a91a973

File tree

6 files changed

+42
-31
lines changed

6 files changed

+42
-31
lines changed

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ inputs:
2121
download-url:
2222
description: 'The url to download the extension from'
2323
required: true
24+
publish:
25+
description: 'Whether to immediately set status to "published"'
26+
required: false
27+
default: 'false'
2428

2529
# Define your outputs here.
2630
#outputs:

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

dist/index.js

Lines changed: 13 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/extensionstore.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface PluginMetaData {
1313
Category: string
1414
Description: string
1515
Url: string
16-
[name: string]: string
16+
Tags: string[]
1717
}
1818

1919
interface PlatformDescriptor {
@@ -91,7 +91,8 @@ interface Versions {
9191
function createPluginSets(
9292
downloadUrl: string,
9393
pluginMetaData: PluginMetaData,
94-
qtcVersion: Versions
94+
qtcVersion: Versions,
95+
publish: boolean
9596
): PluginSet[] {
9697
const osArr = [
9798
{
@@ -118,7 +119,7 @@ function createPluginSets(
118119
)
119120
return allPlatforms.map(platform => {
120121
return {
121-
status: 'draft',
122+
status: publish ? 'published' : 'draft',
122123
core_version: qtcVersion.version,
123124
core_compat_version: qtcVersion.compat_version,
124125
host_os: platform.name,
@@ -137,20 +138,20 @@ function createPluginSets(
137138
}
138139

139140
function createSaveRequest(
140-
pluginName: string,
141-
vendorName: string,
142-
version: string,
143-
pluginSets: PluginSet[]
141+
pluginMetaData: PluginMetaData,
142+
pluginSets: PluginSet[],
143+
publish: boolean
144144
): ExtensionSaveRequest {
145145
return {
146-
name: pluginName,
147-
vendor: vendorName,
146+
name: pluginMetaData.Name,
147+
vendor: pluginMetaData.Vendor,
148148
compatibility: 'Qt 6.0',
149149
platforms: ['Windows', 'macOS', 'Linux'],
150150
license: 'os',
151-
version,
152-
status: 'draft',
151+
version: pluginMetaData.Version,
152+
status: publish ? 'published' : 'draft',
153153
is_pack: false,
154+
tags: pluginMetaData.Tags,
154155
plugin_sets: pluginSets
155156
}
156157
}
@@ -186,7 +187,8 @@ export async function createOrUpdateExtension(
186187
pluginMetaData: PluginMetaData,
187188
qtcVersion: Versions,
188189
apiUrl: string,
189-
apiToken: string
190+
apiToken: string,
191+
publish: boolean
190192
): Promise<void> {
191193
core.debug(`Creating or updating extension ${pluginMetaData.Name}`)
192194
const search = await request(
@@ -201,10 +203,9 @@ export async function createOrUpdateExtension(
201203

202204
const saveRequest = JSON.stringify(
203205
createSaveRequest(
204-
pluginMetaData.Name,
205-
pluginMetaData.Vendor,
206-
pluginMetaData.Version,
207-
createPluginSets(downloadUrl, pluginMetaData, qtcVersion)
206+
pluginMetaData,
207+
createPluginSets(downloadUrl, pluginMetaData, qtcVersion, publish),
208+
publish
208209
)
209210
)
210211

src/main.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ import { createOrUpdateExtension, PluginMetaData } from './extensionstore'
1212
export async function run(): Promise<void> {
1313
try {
1414
const specPath: string = core.getInput('spec')
15-
const isTest: boolean = core.getInput('test') === 'true'
15+
const isTest: boolean =
16+
core.getInput('test', { required: false }) === 'true'
1617
const downloadUrl: string = core.getInput('download-url')
1718
const api: string = core.getInput('api')
1819
const token: string = core.getInput('token')
20+
const publish: boolean =
21+
core.getInput('publish', { required: false }) === 'true'
1922

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

3943
//core.setOutput('outputJson', asJson)

0 commit comments

Comments
 (0)