-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
80 lines (72 loc) · 2.89 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: 'WinGet Updater'
description: 'Publish updates of your application to Windows Package Manager automatically.'
branding:
color: blue
icon: upload-cloud
inputs:
komac-version:
description: 'Which Komac version to use.'
required: false
default: '2.6.0'
komac-token:
description: 'The GitHub token to use for authentication.'
required: true
identifier:
description: 'The PackageIdentifier of the package (case-sensitive).'
required: true
repo:
description: 'The GitHub repository to check for the latest release.'
required: true
url:
description: 'The URL(s) to the latest release.'
required: true
custom-fork-owner:
description: 'Custom winget-pkgs fork owner'
required: false
runs:
using: "composite"
steps:
- name: Check if Package Exists in winget-pkgs Repository
uses: actions/github-script@v7
with:
script: |
const pkgid = "${{ inputs.identifier }}";
const url = `https://github.com/microsoft/winget-pkgs/tree/master/manifests/${pkgid.charAt(0).toLowerCase()}/${pkgid.replaceAll('.', '/')}`;
const headers = { method: 'HEAD' };
const res = await fetch(url, headers);
if (!res.ok) {
core.setFailed(`Package ${pkgid} does not exist in the winget-pkgs repository. Please add at least one version of the package before using this action.`);
process.exit(1);
}
- name: Detect Latest Release
id: latest_release
uses: actions/github-script@v7
with:
script: |
const [owner, repo] = '${{ inputs.repo }}'.split('/');
try {
const { data } = await github.rest.repos.getLatestRelease({ owner, repo });
const tagName = data.tag_name.startsWith('v') ? data.tag_name.substring(1) : data.tag_name;
return tagName;
} catch (error) {
core.setFailed(`Failed to get latest release for repo: ${owner}/${repo}`);
process.exit(1);
}
- name: Compose URL
shell: bash
run: |
VERSION=${{ steps.latest_release.outputs.result }}
URL=${{ inputs.url }}
FINAL_URL=$(echo $URL | sed "s/{VERSION}/$VERSION/g")
echo "FINAL_URL=$FINAL_URL" >> $GITHUB_ENV
echo "Detected latest Version: ${{ steps.latest_release.outputs.result }}"
echo "Final URL: $FINAL_URL"
- name: Run Komac
uses: michidk/run-komac@v2
continue-on-error: true
with:
komac-version: ${{ inputs.komac-version }}
custom-fork-owner: ${{ inputs.custom-fork-owner }}
custom-tool: WinGet Updater
custom-tool-url: "https://github.com/michidk/winget-updater"
args: update ${{ inputs.identifier }} --version ${{ steps.latest_release.outputs.result }} --urls $FINAL_URL --submit --token ${{ inputs.komac-token }}