diff options
author | Alphrag <34252790+Alphrag@users.noreply.github.com> | 2022-07-17 04:56:16 +0530 |
---|---|---|
committer | Vijay A <vraravam@users.noreply.github.com> | 2022-07-17 04:56:16 +0530 |
commit | 0146fdb434f64572bdabbd15926ef7eb869c5713 (patch) | |
tree | 1cc12706de70d81198e2d8fe482ef89572ba3b98 | |
parent | 6.0.0-nightly.101 [skip ci] (diff) | |
download | ferdium-app-0146fdb434f64572bdabbd15926ef7eb869c5713.tar.gz ferdium-app-0146fdb434f64572bdabbd15926ef7eb869c5713.tar.zst ferdium-app-0146fdb434f64572bdabbd15926ef7eb869c5713.zip |
Create winget updater GH workflow (#484)
-rw-r--r-- | .github/workflows/winget-bucket-update.yml | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/.github/workflows/winget-bucket-update.yml b/.github/workflows/winget-bucket-update.yml new file mode 100644 index 000000000..88314fb43 --- /dev/null +++ b/.github/workflows/winget-bucket-update.yml | |||
@@ -0,0 +1,135 @@ | |||
1 | name: Update Ferdium package on winget | ||
2 | |||
3 | on: | ||
4 | workflow_dispatch: | ||
5 | inputs: | ||
6 | message: | ||
7 | description: "Channel to update" | ||
8 | required: false | ||
9 | release: | ||
10 | types: [published] | ||
11 | |||
12 | env: | ||
13 | REPO_URL: https://api.github.com/repos/ferdium/ferdium-app/releases | ||
14 | |||
15 | jobs: | ||
16 | manual_winget_update: | ||
17 | runs-on: windows-latest | ||
18 | name: "Manual winget update: ${{ github.event.inputs.message }}" | ||
19 | if: ${{ github.event_name == 'workflow_dispatch' }} | ||
20 | steps: | ||
21 | - name: "Install winget" | ||
22 | # cf https://github.com/actions/virtual-environments/issues/910#issuecomment-1009640391 | ||
23 | # TODO: update urls to get more updated version | ||
24 | run: | | ||
25 | $ErrorActionPreference = 'Stop' | ||
26 | |||
27 | iwr $(iwr 'https://store.rg-adguard.net/api/GetFiles' -Method 'POST' -ContentType 'application/x-www-form-urlencoded' -Body 'type=PackageFamilyName&url=Microsoft.VCLibs.140.00_8wekyb3d8bbwe&ring=RP&lang=en-US' -UseBasicParsing | Foreach-Object Links | Where-Object outerHTML -match 'Microsoft.VCLibs.140.00_.+_x64__8wekyb3d8bbwe.appx' | Foreach-Object href) -OutFile $env:TEMP\vclibs.appx | ||
28 | iwr $(iwr 'https://store.rg-adguard.net/api/GetFiles' -Method 'POST' -ContentType 'application/x-www-form-urlencoded' -Body 'type=PackageFamilyName&url=Microsoft.VCLibs.140.00.UWPDesktop_8wekyb3d8bbwe&ring=RP&lang=en-US' -UseBasicParsing | Foreach-Object Links | Where-Object outerHTML -match 'Microsoft.VCLibs.140.00.UWPDesktop_.+_x64__8wekyb3d8bbwe.appx' | Foreach-Object href) -OutFile $env:TEMP\vclibsuwp.appx | ||
29 | iwr 'https://github.com/microsoft/winget-cli/releases/download/v1.1.12653/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle' -OutFile $env:TEMP\winget.msixbundle | ||
30 | iwr 'https://github.com/microsoft/winget-cli/releases/download/v1.1.12653/9c0fe2ce7f8e410eb4a8f417de74517e_License1.xml' -Outfile $env:TEMP\winget.license | ||
31 | |||
32 | Add-AppxProvisionedPackage -Online -PackagePath $env:TEMP\winget.msixbundle -LicensePath $env:TEMP\winget.license -DependencyPackagePath @("$env:TEMP\vclibs.appx", "$env:TEMP\vclibsuwp.appx") | ||
33 | - name: "Verify winget" | ||
34 | run: | | ||
35 | winget --info | ||
36 | - name: "Get release tag" | ||
37 | run: | | ||
38 | if ("${{ contains(github.event.inputs.message, '[nightly]') }}" -eq $True) { | ||
39 | $preRel = $True | ||
40 | $tagInc = "nightly" | ||
41 | $package = "Ferdium.Ferdium.Nightly" | ||
42 | } | ||
43 | elseif ("${{ contains(github.event.inputs.message, '[beta]') }}" -eq $True) { | ||
44 | $preRel = $True | ||
45 | $tagInc = "beta" | ||
46 | $package = "Ferdium.Ferdium.Beta" | ||
47 | } | ||
48 | else | ||
49 | { | ||
50 | $preRel = $False | ||
51 | $tagInc = "" | ||
52 | $package = "Ferdium.Ferdium" | ||
53 | } | ||
54 | $release=Invoke-RestMethod -Uri '${{ env.REPO_URL }}' | ||
55 | $lastCorrectTag = $release | Where-Object -Property prerelease -eq $preRel | Where-Object -Property tag_name -match $tagInc | Select -First 1 | Select -ExpandProperty tag_name | ||
56 | $lastVersion = $($lastCorrectTag.Trim('v')) | ||
57 | |||
58 | echo "last_tag=$lastCorrectTag" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append | ||
59 | echo "last_version=$lastVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append | ||
60 | echo "PACKAGE_NAME=$package" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append | ||
61 | |||
62 | - name: "Verify if version already exist on winget" | ||
63 | run: | | ||
64 | $lastVersion = '${{ env.last_version }}' | ||
65 | $versions = winget show --id '${{ env.PACKAGE_NAME }}' --versions --accept-source-agreements | ||
66 | if ( $versions.Contains('${{ env.last_version }}') ) { | ||
67 | echo "version_exists='true'" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append | ||
68 | } | ||
69 | |||
70 | - name: "Publish update" | ||
71 | if: ${{ env.version_exists != 'true' }} | ||
72 | run: | | ||
73 | $release=Invoke-RestMethod -Uri '${{ env.REPO_URL }}' | ||
74 | $assets = $release | Where-Object -Property tag_name -match '${{ env.last_tag }}' | Select -First 1 | Select -ExpandProperty assets | ||
75 | |||
76 | $urlSetup64 = $assets | Where-Object -Property name -CLike '*-win-AutoSetup*-x64.exe' | Select -ExpandProperty browser_download_url | ||
77 | $urlSetup86 = $assets | Where-Object -Property name -CLike '*-win-AutoSetup*-ia32.exe' | Select -ExpandProperty browser_download_url | ||
78 | $urlSetupArm = $assets | Where-Object -Property name -CLike '*-win-AutoSetup*-arm64.exe' | Select -ExpandProperty browser_download_url | ||
79 | |||
80 | $installerUrls = "'$urlSetup64|x64' '$urlSetup86|x86' '$urlSetupArm|arm64'" | ||
81 | Write-Host "urls to use: $installerUrls" | ||
82 | |||
83 | $package = '${{ env.PACKAGE_NAME }}' | ||
84 | $ghToken = '${{ secrets.FERDIUM_WINGET_PAT }}' | ||
85 | |||
86 | iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe | ||
87 | |||
88 | # TODO: remove -o and add -s | ||
89 | $command = ".\wingetcreate.exe update $package -v '${{ env.last_version }}' -u $installerUrls -t $ghToken -o .\" | ||
90 | Write-Host $command | ||
91 | Invoke-Expression $command | ||
92 | |||
93 | |||
94 | winget_release: | ||
95 | name: "Update winget after publish: ${{ github.event.inputs.message }}" | ||
96 | if: ${{ github.event_name == 'release' }} | ||
97 | runs-on: windows-latest | ||
98 | steps: | ||
99 | - name: Check release type | ||
100 | run: | | ||
101 | PRERELEASE_VERSION="${{ github.event.release.prerelease == 'true' }}" | ||
102 | |||
103 | if [[ $PRERELEASE_VERSION == "true" && ${{ contains(github.event.release.tag_name, 'nightly') }} ]]; then | ||
104 | # use the nightly version | ||
105 | PACKAGE_NAME="Ferdium.Ferdium.Nightly" | ||
106 | elif [[ $PRERELEASE_VERSION == "true" && ${{ contains(github.event.release.tag_name, 'beta') }} ]]; then | ||
107 | PACKAGE_NAME="Ferdium.Ferdium.Beta" | ||
108 | else | ||
109 | PACKAGE_NAME="Ferdium.Ferdium" | ||
110 | fi | ||
111 | echo "Using package $PACKAGE_NAME with pre-release $PRERELEASE_VERSION" | ||
112 | echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV | ||
113 | shell: bash | ||
114 | - name: Send update to winget | ||
115 | run: | | ||
116 | iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe | ||
117 | |||
118 | $ghobject = Get-Content '${{ github.event_path }}' | ConvertFrom-Json | ||
119 | $assets = $ghobject.release.assets | ||
120 | |||
121 | $urlSetup64 = $assets | Where-Object -Property name -CLike '*-win-AutoSetup*-x64.exe' | Select -ExpandProperty browser_download_url | ||
122 | $urlSetup86 = $assets | Where-Object -Property name -CLike '*-win-AutoSetup*-ia32.exe' | Select -ExpandProperty browser_download_url | ||
123 | $urlSetupArm = $assets | Where-Object -Property name -CLike '*-win-AutoSetup*-arm64.exe' | Select -ExpandProperty browser_download_url | ||
124 | |||
125 | $installerUrls = "'$urlSetup64|x64' '$urlSetup86|x86' '$urlSetupArm|arm64'" | ||
126 | Write-Host "urls to use: $installerUrls" | ||
127 | |||
128 | $version = $ghobject.release.tag_name | ||
129 | $package = '${{ env.PACKAGE_NAME }}' | ||
130 | $ghToken = '${{ secrets.FERDIUM_WINGET_PAT }}' | ||
131 | |||
132 | # TODO: remove -o and add -s | ||
133 | $command = ".\wingetcreate.exe update $package -v $($version.Trim('v')) -u $installerUrls -t $ghToken -o .\" | ||
134 | Write-Host $command | ||
135 | Invoke-Command $command | ||