From cac566c70a57c7ed4dd4b7263832f9f072c7359b Mon Sep 17 00:00:00 2001 From: jklingen Date: Fri, 16 May 2025 15:17:26 +0200 Subject: [PATCH 1/9] Add Release Script (#581) --- .github/workflows/release.yml | 126 +++++++++++++++ .github/workflows/update-gh-pages.yml | 18 +++ .gitignore | 4 +- azure-pipelines.yml | 106 ------------- build-and-deploy.ps1 | 149 ++++++++++++++++++ installer/innosetup/setup.iss | 3 +- nuget.config | 6 + src/Directory.Build.targets | 64 +++++++- .../Drawing/StepLabelContainer.cs | 2 +- .../Greenshot.Plugin.Box.Credentials.template | 2 +- src/Greenshot.Plugin.Office/OfficeUtils.cs | 60 +++---- src/Greenshot.sln | 5 +- src/Greenshot/Greenshot.csproj | 2 + 13 files changed, 400 insertions(+), 147 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/update-gh-pages.yml delete mode 100644 azure-pipelines.yml create mode 100644 build-and-deploy.ps1 create mode 100644 nuget.config diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..345c0cae9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,126 @@ +name: Build and Deploy + +on: + push: + branches: + - 'release/1.*' + +jobs: + build: + runs-on: windows-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v2 + + - name: Set up .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '7.x' + + - name: Restore NuGet packages + run: msbuild src/Greenshot.sln /p:Configuration=Release /restore /t:PrepareForBuild + env: + Box13_ClientId: ${{ secrets.Box13_ClientId }} + Box13_ClientSecret: ${{ secrets.Box13_ClientSecret }} + DropBox13_ClientId: ${{ secrets.DropBox13_ClientId }} + DropBox13_ClientSecret: ${{ secrets.DropBox13_ClientSecret }} + Flickr_ClientId: ${{ secrets.Flickr_ClientId }} + Flickr_ClientSecret: ${{ secrets.Flickr_ClientSecret }} + Imgur13_ClientId: ${{ secrets.Imgur13_ClientId }} + Imgur13_ClientSecret: ${{ secrets.Imgur13_ClientSecret }} + Photobucket_ClientId: ${{ secrets.Photobucket_ClientId }} + Photobucket_ClientSecret: ${{ secrets.Photobucket_ClientSecret }} + Picasa_ClientId: ${{ secrets.Picasa_ClientId }} + Picasa_ClientSecret: ${{ secrets.Picasa_ClientSecret }} + + - name: Build and package + run: msbuild src/Greenshot.sln /p:Configuration=Release /t:Rebuild /v:normal + env: + Box13_ClientId: ${{ secrets.Box13_ClientId }} + Box13_ClientSecret: ${{ secrets.Box13_ClientSecret }} + DropBox13_ClientId: ${{ secrets.DropBox13_ClientId }} + DropBox13_ClientSecret: ${{ secrets.DropBox13_ClientSecret }} + Flickr_ClientId: ${{ secrets.Flickr_ClientId }} + Flickr_ClientSecret: ${{ secrets.Flickr_ClientSecret }} + Imgur13_ClientId: ${{ secrets.Imgur13_ClientId }} + Imgur13_ClientSecret: ${{ secrets.Imgur13_ClientSecret }} + Photobucket_ClientId: ${{ secrets.Photobucket_ClientId }} + Photobucket_ClientSecret: ${{ secrets.Photobucket_ClientSecret }} + Picasa_ClientId: ${{ secrets.Picasa_ClientId }} + Picasa_ClientSecret: ${{ secrets.Picasa_ClientSecret }} + + - name: Copy Files + run: | + mkdir -p ${{ github.workspace }}/artifacts + cp installer/Greenshot-INSTALLER-*.exe ${{ github.workspace }}/artifacts/ + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: drop + path: ${{ github.workspace }}/artifacts + +# deploy: +# runs-on: windows-latest +# needs: build +# +# steps: +# +# - name: Checkout repository +# uses: actions/checkout@v2 +# with: +# fetch-depth: 0 +# +# - name: Download build artifacts +# uses: actions/download-artifact@v4 +# with: +# name: drop Name of the artifact uploaded in previous steps +# path: drop Local folder where artifacts are downloaded +# +# - name: Extract version from file name +# id: extract_version +# run: | +# $file = Get-ChildItem drop -Filter "Greenshot-INSTALLER-*.exe" | Select-Object -First 1 +# if (-not $file) { +# throw "No matching file found in 'drop' directory." +# } +# if ($file.Name -match "Greenshot-INSTALLER-([\d\.]+).*\.exe") { +# echo "version=$($matches[1])" >> $Env:GITHUB_OUTPUT +# } else { +# throw "Version number could not be extracted from file name: $($file.Name)" +# } +# shell: pwsh +# +# - name: Create tag +# run: | +# git config user.name "github-actions[bot]" +# git config user.email "github-actions[bot]@users.noreply.github.com" +# git tag -a "v${{ steps.extract_version.outputs.version }}" -m "v${{ steps.extract_version.outputs.version }}" +# git push origin "v${{ steps.extract_version.outputs.version }}" +# +# - name: Create GitHub Release +# uses: softprops/action-gh-release@v2 +# with: +# name: "Greenshot ${{ steps.extract_version.outputs.version }} unstable" +# tag_name: "v${{ steps.extract_version.outputs.version }}" +# files: drop/*.exe +# generate_release_notes: true +# draft: true +# prerelease: true +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# +# - name: Trigger GitHub Pages rebuild +# shell: bash +# run: | +# curl -X POST \ +# -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ +# -H "Accept: application/vnd.github+json" \ +# https://api.github.com/repos/${{ github.repository }}/pages/builds + diff --git a/.github/workflows/update-gh-pages.yml b/.github/workflows/update-gh-pages.yml new file mode 100644 index 000000000..6c9666223 --- /dev/null +++ b/.github/workflows/update-gh-pages.yml @@ -0,0 +1,18 @@ +name: Update GitHub Pages + +on: + workflow_dispatch: + release: + types: [published] + +jobs: + update-gh-pages: + runs-on: ubuntu-latest + steps: + - name: Trigger GitHub Pages rebuild + shell: bash + run: | + curl -X POST \ + -H "Authorization: Bearer ${{ secrets.GH_PAT_JKL }}" \ + -H "Accept: application/vnd.github+json" \ + https://api.github.com/repos/${{ github.repository }}/pages/builds diff --git a/.gitignore b/.gitignore index 3afd2d7ab..7e96d5501 100644 --- a/.gitignore +++ b/.gitignore @@ -214,4 +214,6 @@ ModelManifest.xml *.credentials.cs # Rider files -.idea \ No newline at end of file +.idea + +/installer/Greenshot-INSTALLER-*.exe diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 558d40760..000000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,106 +0,0 @@ -# .NET Desktop -# Build and run tests for .NET Desktop or Windows classic desktop solutions. -# Add steps that publish symbols, save build artifacts, and more: -# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net - -trigger: - batch: true - branches: - include: - - 'release/1.*' - exclude: - - 'develop' - -stages: -- stage: Build - jobs: - - job: Build - variables: - - group: 'Plug-in Credentials' - - name: solution - value: 'src/Greenshot.sln' - - name: buildPlatform - value: 'Any CPU' - - name: buildConfiguration - value: 'Release' - - pool: - vmImage: 'Windows-latest' - - steps: - - task: MSBuild@1 - displayName: Restore nuget packages and generate credential templates - inputs: - solution: '$(solution)' - platform: $(buildPlatform) - configuration: $(buildConfiguration) - msbuildArguments: '/restore /t:PrepareForBuild' - - - task: MSBuild@1 - displayName: Build and package - inputs: - solution: '$(solution)' - platform: $(buildPlatform) - configuration: $(buildConfiguration) - env: - Box13_ClientId: $(Box13_ClientId) - Box13_ClientSecret: $(Box13_ClientSecret) - DropBox13_ClientId: $(DropBox13_ClientId) - DropBox13_ClientSecret: $(DropBox13_ClientSecret) - Flickr_ClientId: $(Flickr_ClientId) - Flickr_ClientSecret: $(Flickr_ClientSecret) - Imgur13_ClientId: $(Imgur13_ClientId) - Imgur13_ClientSecret: $(Imgur13_ClientSecret) - Photobucket_ClientId: $(Photobucket_ClientId) - Photobucket_ClientSecret: $(Photobucket_ClientSecret) - Picasa_ClientId: $(Picasa_ClientId) - Picasa_ClientSecret: $(Picasa_ClientSecret) - - - task: CopyFiles@2 - displayName: 'Copy Files to: $(build.artifactstagingdirectory)' - inputs: - SourceFolder: '$(Build.SourcesDirectory)\installer' - Contents: Greenshot-INSTALLER-*.exe - TargetFolder: '$(build.artifactstagingdirectory)' - flattenFolders: true - - - task: PublishBuildArtifacts@1 - displayName: 'Publish Artifact: drop' - inputs: - PathtoPublish: '$(build.artifactstagingdirectory)' - -- stage: Deploy - jobs: - - deployment: GitHub_Release - pool: - vmImage: 'Windows-latest' - - environment: 'GitHub Release' - strategy: - # default deployment strategy - runOnce: - deploy: - steps: - - download: current - artifact: drop - - # Create a GitHub release - - task: GitHubRelease@0 - inputs: - gitHubConnection: GitHub Release - repositoryName: '$(Build.Repository.Name)' - action: 'create' # Options: create, edit, delete - target: '$(Build.SourceVersion)' # Required when action == Create || Action == Edit - tagSource: 'manual' # Required when action == Create# Options: auto, manual - tag: 'v$(Build.BuildNumber)' # Required when action == Edit || Action == Delete || TagSource == Manual - title: Greenshot $(Build.BuildNumber) unstable # Optional - #releaseNotesSource: 'file' # Optional. Options: file, input - #releaseNotesFile: # Optional - #releaseNotes: # Optional - assets: '$(Pipeline.Workspace)/drop/*.exe' - #assetUploadMode: 'delete' # Optional. Options: delete, replace - isDraft: true # Optional - isPreRelease: true # Optional - addChangeLog: true # Optional - #compareWith: 'lastFullRelease' # Required when addChangeLog == True. Options: lastFullRelease, lastRelease, lastReleaseByTag - #releaseTag: # Required when compareWith == LastReleaseByTag diff --git a/build-and-deploy.ps1 b/build-and-deploy.ps1 new file mode 100644 index 000000000..5e373949b --- /dev/null +++ b/build-and-deploy.ps1 @@ -0,0 +1,149 @@ +# USAGE +# * Enable script execution in Powershell: 'Set-ExecutionPolicy RemoteSigned' +# * Create a GitHub personal access token (PAT) for greenshot repository +# * user must be owner of the repository +# * token needs read and write permissions ""for Contents"" and ""Pages"" +# * Execute the script and paste your token + +# Prompt the user to securely input the Github token +$SecureToken = Read-Host "Please enter your GitHub personal access token" -AsSecureString +$ReleaseToken = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureToken)) + +# Variables +$RepoPath = "." # Replace with your local repo path +$ArtifactsPath = "$RepoPath\artifacts" +$SolutionFile = "$RepoPath\src\Greenshot.sln" + +# Step 0: Update Local Repository +git pull + +# Step 1: Restore NuGet Packages +Write-Host "Restoring NuGet packages..." +msbuild "$SolutionFile" /p:Configuration=Release /restore /t:PrepareForBuild +if ($LASTEXITCODE -ne 0) { + Write-Error "Failed to restore NuGet packages." + exit $LASTEXITCODE +} + +# Step 2: Build and Package +Write-Host "Building and packaging the solution..." +msbuild "$SolutionFile" /p:Configuration=Release /t:Rebuild /v:normal +if ($LASTEXITCODE -ne 0) { + Write-Error "Build failed." + exit $LASTEXITCODE +} + +# Step 3: Copy Installer Files +Write-Host "Copying installer files..." +if (-not (Test-Path $ArtifactsPath)) { + New-Item -ItemType Directory -Force -Path $ArtifactsPath +} +Copy-Item "$RepoPath\installer\Greenshot-INSTALLER-*.exe" -Destination $ArtifactsPath -Force +if ($LASTEXITCODE -ne 0) { + Write-Error "Failed to copy installer files." + exit $LASTEXITCODE +} + +# Step 4: Extract Version from File Name +Write-Host "Extracting version from installer file name..." +$InstallerFile = Get-ChildItem $ArtifactsPath -Filter "Greenshot-INSTALLER-*.exe" | Select-Object -Last 1 +if (-not $InstallerFile) { + Write-Error "No matching installer file found in '$ArtifactsPath'." + exit 1 +} + +if ($InstallerFile.Name -match "Greenshot-INSTALLER-([\d\.]+).*\.exe") { + $Version = $matches[1] + Write-Host "Extracted version: $Version" +} else { + Write-Error "Version number could not be extracted from file name: $($InstallerFile.Name)" + exit 1 +} + +# Step 5: Create Git Tag +Write-Host "Creating Git tag..." +cd $RepoPath +#git config user.name "local-script" +#git config user.email "local-script@example.com" +git tag -a "v$Version" -m "v$Version" +git push origin "v$Version" +if ($LASTEXITCODE -ne 0) { + Write-Error "Failed to create Git tag." + exit $LASTEXITCODE +} + +# Step 6: Create GitHub Release +Write-Host "Creating GitHub release..." +$Headers = @{ + Authorization = "Bearer $ReleaseToken" + Accept = "application/vnd.github+json" +} +$ReleaseData = @{ + tag_name = "v$Version" + name = "Greenshot $Version unstable" + body = "Pre-release of Greenshot $Version." + draft = $true + prerelease = $true + generate_release_notes = $true +} +$ReleaseResponse = Invoke-RestMethod ` + -Uri "https://api.github.com/repos/jklingen/greenshot/releases" ` + -Method POST ` + -Headers $Headers ` + -Body (ConvertTo-Json $ReleaseData -Depth 10) + +if ($LASTEXITCODE -ne 0) { + Write-Error "Failed to create GitHub release." + exit $LASTEXITCODE +} + +Write-Host "Release created successfully." + +# Get the release ID from the response +$ReleaseId = $ReleaseResponse.id +Write-Host "Release ID: $ReleaseId" + +# Step 7: Upload .exe File to Release +Write-Host "Uploading .exe file to GitHub release..." +$ExeFilePath = "$ArtifactsPath\$($InstallerFile.Name)" +if (-Not (Test-Path $ExeFilePath)) { + Write-Error "Built .exe file not found: $ExeFilePath" + exit 1 +} + +# GitHub API for uploading release assets +$UploadUrl = $ReleaseResponse.upload_url -replace "{.*}", "" + +# Upload the file +$FileHeaders = @{ + Authorization = "Bearer $ReleaseToken" + ContentType = "application/octet-stream" +} +$FileName = [System.IO.Path]::GetFileName($ExeFilePath) + +Invoke-RestMethod ` + -Uri "$($UploadUrl)?name=$FileName" ` + -Method POST ` + -Headers $FileHeaders ` + -InFile $ExeFilePath ` + -ContentType "application/octet-stream" + +if ($LASTEXITCODE -ne 0) { + Write-Error "Failed to upload .exe file to release." + exit $LASTEXITCODE +} + +Write-Host "File uploaded successfully: $FileName" + +# Step 7: Trigger GitHub Pages Rebuild +#Write-Host "Triggering GitHub Pages rebuild..." +#Invoke-RestMethod ` +# -Uri "https://api.github.com/repos/jklingen/greenshot/pages/builds" ` +# -Method POST ` +# -Headers $Headers +#if ($LASTEXITCODE -ne 0) { +# Write-Error "Failed to trigger GitHub Pages rebuild." +# exit $LASTEXITCODE +#} +# +#Write-Host "GitHub Pages rebuild triggered successfully." \ No newline at end of file diff --git a/installer/innosetup/setup.iss b/installer/innosetup/setup.iss index 59363446f..fb77b0103 100644 --- a/installer/innosetup/setup.iss +++ b/installer/innosetup/setup.iss @@ -140,7 +140,8 @@ SetupIconFile=..\..\src\Greenshot\icons\applicationIcon\icon.ico ; SignTool=SignTool sign /debug /fd sha1 /tr https://time.certum.pl /td sha1 $f ; Append a SHA256 to the previous SHA1 signature (this is what as does) ; SignTool=SignTool sign /debug /as /fd sha256 /tr https://time.certum.pl /td sha256 $f -; SignedUninstaller=yes +SignTool=SignTool sign /sha1 "{#GetEnv('CertumThumbprint')}" /tr http://time.certum.pl /td sha256 /fd sha256 /v $f +;SignedUninstaller=yes UninstallDisplayIcon={app}\{#ExeName}.exe Uninstallable=true VersionInfoCompany={#ExeName} diff --git a/nuget.config b/nuget.config new file mode 100644 index 000000000..554c2f634 --- /dev/null +++ b/nuget.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index f2ce406a1..caa6a3db3 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -1,13 +1,65 @@ + + + + + + + + + + (); + foreach (var line in InputLines) + { + string text = line.ItemSpec; + foreach (var token in Tokens) + { + string tokenName = token.ItemSpec; + // Skip if tokenName is null or empty + if (string.IsNullOrEmpty(tokenName)) + continue; + + string replacementValue = token.GetMetadata("ReplacementValue"); + if (!string.IsNullOrEmpty(replacementValue)) + { + string placeholder = "$"+ "{"+tokenName+"}"; // Token-Format wie $(Box13_ClientId) + text = text.Replace(placeholder, replacementValue); + } + } + output.Add(new Microsoft.Build.Utilities.TaskItem(text)); + } + OutputLines = output.ToArray(); + ]]> + + + - $(PkgMSBuildTasks)\tools\ + $(NuGetPackageRoot)msbuildtasks/1.5.0.235/tools/ - - + + - - + + + + + + + + + + + + - \ No newline at end of file + + + + + diff --git a/src/Greenshot.Editor/Drawing/StepLabelContainer.cs b/src/Greenshot.Editor/Drawing/StepLabelContainer.cs index e5d93e514..e907d237b 100644 --- a/src/Greenshot.Editor/Drawing/StepLabelContainer.cs +++ b/src/Greenshot.Editor/Drawing/StepLabelContainer.cs @@ -205,7 +205,7 @@ namespace Greenshot.Editor.Drawing EllipseContainer.DrawEllipse(rect, graphics, rm, 0, Color.Transparent, fillColor, false); } - float fontSize = Math.Min(Math.Abs(Width), Math.Abs(Height)) / 1.4f; + float fontSize = Math.Min(Math.Abs(Width), Math.Abs(Height)) / 3f; using FontFamily fam = new FontFamily(FontFamily.GenericSansSerif.Name); using Font font = new Font(fam, fontSize, FontStyle.Bold, GraphicsUnit.Pixel); TextContainer.DrawText(graphics, rect, 0, lineColor, false, _stringFormat, text, font); diff --git a/src/Greenshot.Plugin.Box/Greenshot.Plugin.Box.Credentials.template b/src/Greenshot.Plugin.Box/Greenshot.Plugin.Box.Credentials.template index df6eaa0bd..da2dbc7ae 100644 --- a/src/Greenshot.Plugin.Box/Greenshot.Plugin.Box.Credentials.template +++ b/src/Greenshot.Plugin.Box/Greenshot.Plugin.Box.Credentials.template @@ -1,4 +1,4 @@ -/* +/* * Greenshot - a free and open source screenshot tool * Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom * diff --git a/src/Greenshot.Plugin.Office/OfficeUtils.cs b/src/Greenshot.Plugin.Office/OfficeUtils.cs index 52ca8d7cb..305611c5d 100644 --- a/src/Greenshot.Plugin.Office/OfficeUtils.cs +++ b/src/Greenshot.Plugin.Office/OfficeUtils.cs @@ -1,43 +1,45 @@ using System.Linq; using Microsoft.Win32; -namespace Greenshot.Plugin.Office; - -/// -/// A small utility class for helping with office -/// -internal static class OfficeUtils +namespace Greenshot.Plugin.Office { - private static readonly string[] OfficeRootKeys = { @"SOFTWARE\Microsoft\Office", @"SOFTWARE\WOW6432Node\Microsoft\Office" }; /// - /// Get the path to the office exe + /// A small utility class for helping with office /// - /// Name of the office executable - public static string GetOfficeExePath(string exeName) + internal static class OfficeUtils { - string strKeyName = exeName switch - { - "WINWORD.EXE" => "Word", - "EXCEL.EXE" => "Excel", - "POWERPNT.EXE" => "PowerPoint", - "OUTLOOK.EXE" => "Outlook", - "ONENOTE.EXE" => "OneNote", - _ => "" - }; + private static readonly string[] OfficeRootKeys = { @"SOFTWARE\Microsoft\Office", @"SOFTWARE\WOW6432Node\Microsoft\Office" }; - foreach (string strRootKey in OfficeRootKeys) + /// + /// Get the path to the office exe + /// + /// Name of the office executable + public static string GetOfficeExePath(string exeName) { - using RegistryKey rootKey = Registry.LocalMachine.OpenSubKey(strRootKey); - if (rootKey is null) continue; - - foreach (string officeVersion in rootKey.GetSubKeyNames().Where(r => r.Contains(".")).Reverse()) + string strKeyName = exeName switch { - using RegistryKey installRootKey = Registry.LocalMachine.OpenSubKey($@"{strRootKey}\{officeVersion}\{strKeyName}\InstallRoot"); - if (installRootKey == null) continue; - return $@"{installRootKey.GetValue("Path")}\{exeName}"; + "WINWORD.EXE" => "Word", + "EXCEL.EXE" => "Excel", + "POWERPNT.EXE" => "PowerPoint", + "OUTLOOK.EXE" => "Outlook", + "ONENOTE.EXE" => "OneNote", + _ => "" + }; + + foreach (string strRootKey in OfficeRootKeys) + { + using RegistryKey rootKey = Registry.LocalMachine.OpenSubKey(strRootKey); + if (rootKey is null) continue; + + foreach (string officeVersion in rootKey.GetSubKeyNames().Where(r => r.Contains(".")).Reverse()) + { + using RegistryKey installRootKey = Registry.LocalMachine.OpenSubKey($@"{strRootKey}\{officeVersion}\{strKeyName}\InstallRoot"); + if (installRootKey == null) continue; + return $@"{installRootKey.GetValue("Path")}\{exeName}"; + } } + return null; } - return null; } -} +} \ No newline at end of file diff --git a/src/Greenshot.sln b/src/Greenshot.sln index 91ddf4314..b71e79bd3 100644 --- a/src/Greenshot.sln +++ b/src/Greenshot.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29728.190 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34009.444 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot", "Greenshot\Greenshot.csproj", "{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}" ProjectSection(ProjectDependencies) = postProject @@ -48,6 +48,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\azure-pipelines.yml = ..\azure-pipelines.yml Directory.Build.props = Directory.Build.props Directory.Build.targets = Directory.Build.targets + ..\.github\workflows\release.yml = ..\.github\workflows\release.yml EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot.Editor", "Greenshot.Editor\Greenshot.Editor.csproj", "{148D3C8B-D6EC-4A7D-80E9-243A81F19DD2}" diff --git a/src/Greenshot/Greenshot.csproj b/src/Greenshot/Greenshot.csproj index fc4dd90d1..334bfc0f0 100644 --- a/src/Greenshot/Greenshot.csproj +++ b/src/Greenshot/Greenshot.csproj @@ -17,6 +17,7 @@ + @@ -75,6 +76,7 @@ + From 262307e61e1575b749af094996b7d26781b7a8b0 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Fri, 16 May 2025 15:34:51 +0200 Subject: [PATCH 2/9] fixed branch changes --- .github/workflows/update-gh-pages.yml | 2 +- build-and-deploy.ps1 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-gh-pages.yml b/.github/workflows/update-gh-pages.yml index 6c9666223..a7e2b42cb 100644 --- a/.github/workflows/update-gh-pages.yml +++ b/.github/workflows/update-gh-pages.yml @@ -13,6 +13,6 @@ jobs: shell: bash run: | curl -X POST \ - -H "Authorization: Bearer ${{ secrets.GH_PAT_JKL }}" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -H "Accept: application/vnd.github+json" \ https://api.github.com/repos/${{ github.repository }}/pages/builds diff --git a/build-and-deploy.ps1 b/build-and-deploy.ps1 index 5e373949b..7645259c5 100644 --- a/build-and-deploy.ps1 +++ b/build-and-deploy.ps1 @@ -87,7 +87,7 @@ $ReleaseData = @{ generate_release_notes = $true } $ReleaseResponse = Invoke-RestMethod ` - -Uri "https://api.github.com/repos/jklingen/greenshot/releases" ` + -Uri "https://api.github.com/repos/greenshot/greenshot/releases" ` -Method POST ` -Headers $Headers ` -Body (ConvertTo-Json $ReleaseData -Depth 10) @@ -138,7 +138,7 @@ Write-Host "File uploaded successfully: $FileName" # Step 7: Trigger GitHub Pages Rebuild #Write-Host "Triggering GitHub Pages rebuild..." #Invoke-RestMethod ` -# -Uri "https://api.github.com/repos/jklingen/greenshot/pages/builds" ` +# -Uri "https://api.github.com/repos/greenshot/greenshot/pages/builds" ` # -Method POST ` # -Headers $Headers #if ($LASTEXITCODE -ne 0) { From c8f424b72ee671a2e2470c5df772ea76c473d042 Mon Sep 17 00:00:00 2001 From: jklingen Date: Fri, 16 May 2025 15:49:26 +0200 Subject: [PATCH 3/9] Fix Reference to Token --- .github/workflows/update-gh-pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-gh-pages.yml b/.github/workflows/update-gh-pages.yml index a7e2b42cb..71a25b2e7 100644 --- a/.github/workflows/update-gh-pages.yml +++ b/.github/workflows/update-gh-pages.yml @@ -13,6 +13,6 @@ jobs: shell: bash run: | curl -X POST \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ -H "Accept: application/vnd.github+json" \ https://api.github.com/repos/${{ github.repository }}/pages/builds From 15d58880902108bf87c323f20391d4b8b64c03ea Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Fri, 16 May 2025 15:52:31 +0200 Subject: [PATCH 4/9] changed token --- .github/workflows/update-gh-pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-gh-pages.yml b/.github/workflows/update-gh-pages.yml index a7e2b42cb..5026ffb18 100644 --- a/.github/workflows/update-gh-pages.yml +++ b/.github/workflows/update-gh-pages.yml @@ -13,6 +13,6 @@ jobs: shell: bash run: | curl -X POST \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Authorization: Bearer ${{ secrets.GH_PAGES_TOKEN }}" \ -H "Accept: application/vnd.github+json" \ https://api.github.com/repos/${{ github.repository }}/pages/builds From 89aaa82252a72af9a3b0eb7b6a7ff421debccc85 Mon Sep 17 00:00:00 2001 From: jklingen Date: Mon, 19 May 2025 16:41:54 +0200 Subject: [PATCH 5/9] Activate Signed Uninstaller --- installer/innosetup/setup.iss | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/installer/innosetup/setup.iss b/installer/innosetup/setup.iss index fb77b0103..1d454f6be 100644 --- a/installer/innosetup/setup.iss +++ b/installer/innosetup/setup.iss @@ -136,12 +136,8 @@ OutputBaseFilename={#ExeName}-INSTALLER-{#Version}-UNSTABLE OutputDir=..\ PrivilegesRequired=lowest SetupIconFile=..\..\src\Greenshot\icons\applicationIcon\icon.ico -; Create a SHA1 signature -; SignTool=SignTool sign /debug /fd sha1 /tr https://time.certum.pl /td sha1 $f -; Append a SHA256 to the previous SHA1 signature (this is what as does) -; SignTool=SignTool sign /debug /as /fd sha256 /tr https://time.certum.pl /td sha256 $f SignTool=SignTool sign /sha1 "{#GetEnv('CertumThumbprint')}" /tr http://time.certum.pl /td sha256 /fd sha256 /v $f -;SignedUninstaller=yes +SignedUninstaller=yes UninstallDisplayIcon={app}\{#ExeName}.exe Uninstallable=true VersionInfoCompany={#ExeName} From 2f6b3a434008fdbb7d76910cf383884a3104f68e Mon Sep 17 00:00:00 2001 From: jklingen Date: Mon, 19 May 2025 16:46:21 +0200 Subject: [PATCH 6/9] Do not try to Sign if Thumbprint is Missing --- installer/innosetup/setup.iss | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/installer/innosetup/setup.iss b/installer/innosetup/setup.iss index 1d454f6be..56e52d328 100644 --- a/installer/innosetup/setup.iss +++ b/installer/innosetup/setup.iss @@ -136,8 +136,10 @@ OutputBaseFilename={#ExeName}-INSTALLER-{#Version}-UNSTABLE OutputDir=..\ PrivilegesRequired=lowest SetupIconFile=..\..\src\Greenshot\icons\applicationIcon\icon.ico -SignTool=SignTool sign /sha1 "{#GetEnv('CertumThumbprint')}" /tr http://time.certum.pl /td sha256 /fd sha256 /v $f -SignedUninstaller=yes +#if GetEnv('CertumThumbprint') != "" + SignTool=SignTool sign /sha1 "{#GetEnv('CertumThumbprint')}" /tr http://time.certum.pl /td sha256 /fd sha256 /v $f + SignedUninstaller=yes +#endif UninstallDisplayIcon={app}\{#ExeName}.exe Uninstallable=true VersionInfoCompany={#ExeName} From 34cc6bfee1a9e4a34c3cb27e2f8f273ae40cf6cc Mon Sep 17 00:00:00 2001 From: jklingen Date: Mon, 19 May 2025 16:58:57 +0200 Subject: [PATCH 7/9] Change filename if unsigned --- installer/innosetup/setup.iss | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/installer/innosetup/setup.iss b/installer/innosetup/setup.iss index 56e52d328..89b3df14f 100644 --- a/installer/innosetup/setup.iss +++ b/installer/innosetup/setup.iss @@ -7,6 +7,7 @@ #define BinDir "bin\Release\net472" #define ReleaseDir "..\..\src\Greenshot\bin\Release\net472" #define PluginDir "..\..\src\Greenshot\bin\Release\net472\Plugins" +#define CertumThumbprint GetEnv('CertumThumbprint') ; Include the scripts to install .NET Framework ; See https://www.codeproject.com/KB/install/dotnetfx_innosetup_instal.aspx @@ -132,13 +133,15 @@ InfoBeforeFile=..\additional_files\readme.txt LicenseFile=..\additional_files\license.txt LanguageDetectionMethod=uilanguage MinVersion=6.1sp1 -OutputBaseFilename={#ExeName}-INSTALLER-{#Version}-UNSTABLE OutputDir=..\ PrivilegesRequired=lowest SetupIconFile=..\..\src\Greenshot\icons\applicationIcon\icon.ico -#if GetEnv('CertumThumbprint') != "" - SignTool=SignTool sign /sha1 "{#GetEnv('CertumThumbprint')}" /tr http://time.certum.pl /td sha256 /fd sha256 /v $f +#if CertumThumbprint != "" + OutputBaseFilename={#ExeName}-INSTALLER-{#Version}-UNSTABLE + SignTool=SignTool sign /sha1 "{#CertumThumbprint }" /tr http://time.certum.pl /td sha256 /fd sha256 /v $f SignedUninstaller=yes +#else + OutputBaseFilename={#ExeName}-INSTALLER-{#Version}-UNSTABLE-UNSIGNED #endif UninstallDisplayIcon={app}\{#ExeName}.exe Uninstallable=true From 3c6a0a1fc1fbaaa429071ea06128f3b7c4e6a838 Mon Sep 17 00:00:00 2001 From: jklingen Date: Mon, 19 May 2025 16:59:36 +0200 Subject: [PATCH 8/9] Release Unstable Unsigned Binary by Default --- .github/workflows/release.yml | 114 +++++++++++++++++----------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 345c0cae9..22f9bc976 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -66,61 +66,61 @@ jobs: name: drop path: ${{ github.workspace }}/artifacts -# deploy: -# runs-on: windows-latest -# needs: build -# -# steps: -# -# - name: Checkout repository -# uses: actions/checkout@v2 -# with: -# fetch-depth: 0 -# -# - name: Download build artifacts -# uses: actions/download-artifact@v4 -# with: -# name: drop Name of the artifact uploaded in previous steps -# path: drop Local folder where artifacts are downloaded -# -# - name: Extract version from file name -# id: extract_version -# run: | -# $file = Get-ChildItem drop -Filter "Greenshot-INSTALLER-*.exe" | Select-Object -First 1 -# if (-not $file) { -# throw "No matching file found in 'drop' directory." -# } -# if ($file.Name -match "Greenshot-INSTALLER-([\d\.]+).*\.exe") { -# echo "version=$($matches[1])" >> $Env:GITHUB_OUTPUT -# } else { -# throw "Version number could not be extracted from file name: $($file.Name)" -# } -# shell: pwsh -# -# - name: Create tag -# run: | -# git config user.name "github-actions[bot]" -# git config user.email "github-actions[bot]@users.noreply.github.com" -# git tag -a "v${{ steps.extract_version.outputs.version }}" -m "v${{ steps.extract_version.outputs.version }}" -# git push origin "v${{ steps.extract_version.outputs.version }}" -# -# - name: Create GitHub Release -# uses: softprops/action-gh-release@v2 -# with: -# name: "Greenshot ${{ steps.extract_version.outputs.version }} unstable" -# tag_name: "v${{ steps.extract_version.outputs.version }}" -# files: drop/*.exe -# generate_release_notes: true -# draft: true -# prerelease: true -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# -# - name: Trigger GitHub Pages rebuild -# shell: bash -# run: | -# curl -X POST \ -# -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -# -H "Accept: application/vnd.github+json" \ -# https://api.github.com/repos/${{ github.repository }}/pages/builds + deploy: + runs-on: windows-latest + needs: build + + steps: + + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: drop Name of the artifact uploaded in previous steps + path: drop Local folder where artifacts are downloaded + + - name: Extract version from file name + id: extract_version + run: | + $file = Get-ChildItem drop -Filter "Greenshot-INSTALLER-*.exe" | Select-Object -First 1 + if (-not $file) { + throw "No matching file found in 'drop' directory." + } + if ($file.Name -match "Greenshot-INSTALLER-([\d\.]+).*\.exe") { + echo "version=$($matches[1])" >> $Env:GITHUB_OUTPUT + } else { + throw "Version number could not be extracted from file name: $($file.Name)" + } + shell: pwsh + + - name: Create tag + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag -a "v${{ steps.extract_version.outputs.version }}" -m "v${{ steps.extract_version.outputs.version }}" + git push origin "v${{ steps.extract_version.outputs.version }}" + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + name: "Greenshot ${{ steps.extract_version.outputs.version }} unstable" + tag_name: "v${{ steps.extract_version.outputs.version }}" + files: drop/*.exe + generate_release_notes: true +# draft: true + prerelease: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Trigger GitHub Pages rebuild + shell: bash + run: | + curl -X POST \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github+json" \ + https://api.github.com/repos/${{ github.repository }}/pages/builds From 4b03efd011a9bc615e4ff651322aaf22400b9075 Mon Sep 17 00:00:00 2001 From: jklingen Date: Mon, 19 May 2025 17:05:49 +0200 Subject: [PATCH 9/9] Generate Release Name from Filename --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 22f9bc976..8c39f3fee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -92,6 +92,7 @@ jobs: } if ($file.Name -match "Greenshot-INSTALLER-([\d\.]+).*\.exe") { echo "version=$($matches[1])" >> $Env:GITHUB_OUTPUT + echo "attribs=$($matches[2])" | tr -d '-' ' ' | tr '[:upper:]' '[:lower:]' >> $Env:GITHUB_OUTPUT } else { throw "Version number could not be extracted from file name: $($file.Name)" } @@ -107,7 +108,7 @@ jobs: - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: - name: "Greenshot ${{ steps.extract_version.outputs.version }} unstable" + name: "Greenshot ${{ steps.extract_version.outputs.version }}${{ steps.extract_version.outputs.attribs }}" tag_name: "v${{ steps.extract_version.outputs.version }}" files: drop/*.exe generate_release_notes: true