This commit is contained in:
Christian Schulz 2025-08-21 22:11:19 +02:00 committed by GitHub
commit 082d2d3540
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 215 additions and 27 deletions

View file

@ -17,12 +17,15 @@ on:
- 'build-and-deploy.ps1' - 'build-and-deploy.ps1'
jobs: jobs:
# Build Greenshot with MSBuild
# Upload installer to artifacts-installer
# Upload build output to artifacts-greenshot-build
build: build:
name: Build Greenshot
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v5
with: with:
fetch-depth: 0 fetch-depth: 0
@ -71,36 +74,44 @@ jobs:
mkdir -p ${{ github.workspace }}/artifacts mkdir -p ${{ github.workspace }}/artifacts
cp installer/Greenshot-INSTALLER-*.exe ${{ github.workspace }}/artifacts/ cp installer/Greenshot-INSTALLER-*.exe ${{ github.workspace }}/artifacts/
- name: Upload Artifact - name: Upload Insaller Artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: drop name: artifacts-installer
path: ${{ github.workspace }}/artifacts path: ${{ github.workspace }}/artifacts
if-no-files-found: error
deploy: - name: Upload build artifacts
runs-on: windows-latest uses: actions/upload-artifact@v4
with:
name: artifacts-greenshot-build
path: src/Greenshot/bin/Release/net472/**
if-no-files-found: error
pre_deploy:
# Prepare for deployment
# Determine version and release tag name
name: Prepare for Deployment
runs-on: ubuntu-latest
needs: build needs: build
outputs:
steps: version: ${{ steps.version_info.outputs.version }}
tag_name: ${{ env.IS_RELEASE_BRANCH == 'true' && format('v{0}', steps.version_info.outputs.version) || env.BRANCH_NAME }}
- name: Checkout repository steps:
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Download build artifacts - name: Download build artifacts
uses: actions/download-artifact@v4 uses: actions/download-artifact@v5
with: with:
name: drop # Name of the artifact uploaded in previous steps name: artifacts-installer # Name of the artifact uploaded in previous steps
path: drop # Local folder where artifacts are downloaded path: artifacts-installer # Local folder where artifacts are downloaded
- name: Extract version from file name - name: Extract version from file name
if: env.IS_RELEASE_BRANCH == 'true' if: env.IS_RELEASE_BRANCH == 'true'
id: version_from_filename id: version_from_filename
run: | run: |
$file = Get-ChildItem drop -Filter "Greenshot-INSTALLER-*.exe" | Select-Object -First 1 $file = Get-ChildItem artifacts-installer -Filter "Greenshot-INSTALLER-*.exe" | Select-Object -First 1
if (-not $file) { if (-not $file) {
throw "No matching file found in 'drop' directory." throw "No matching file found in 'artifacts-installer' directory."
} }
if ($file.Name -match "Greenshot-INSTALLER-([\d\.]+)(.*)\.exe") { if ($file.Name -match "Greenshot-INSTALLER-([\d\.]+)(.*)\.exe") {
echo "version=$($matches[1])" >> $Env:GITHUB_OUTPUT echo "version=$($matches[1])" >> $Env:GITHUB_OUTPUT
@ -123,30 +134,96 @@ jobs:
run: | run: |
echo "version=${{ steps.version_from_filename.outputs.version || steps.version_from_branchname.outputs.version }}" >> $GITHUB_OUTPUT echo "version=${{ steps.version_from_filename.outputs.version || steps.version_from_branchname.outputs.version }}" >> $GITHUB_OUTPUT
shell: bash shell: bash
portable:
# Creates a portable app from the build output
# Creates a ZIP archive and uploads it to artifacts-greenshot-portable
name: Build Portable ZIP
runs-on: ubuntu-latest
needs: pre_deploy
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Download build artifacts
uses: actions/download-artifact@v5
with:
name: artifacts-greenshot-build
path: artifacts-greenshot-build
- name: Prepare portable folder
run: |
$buildArtifacts = "${{ github.workspace }}/artifacts-greenshot-build"
$portableDir = "${{ github.workspace }}/portable"
pwsh -File "${{ github.workspace }}/prepare-portable.ps1" -RepositoryRootPath ${{ github.workspace }} -BuildArtifactsPath $buildArtifacts -OutputPath $portableDir
shell: pwsh
- name: Create ZIP archive
run: |
$zipName = "greenshot-portable-${{ needs.pre_deploy.outputs.version }}.zip"
Compress-Archive -Path "${{ github.workspace }}/portable/*" -DestinationPath $zipName -Force
shell: pwsh
- name: Upload portable build artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-greenshot-portable
path: greenshot-portable-*.zip
if-no-files-found: error
deploy:
# Deploy the release
# Creates a GitHub Release
# Creates a version tag if release branch
# Trigger GitHub Pages rebuild
name: Deploy (continuous build)
runs-on: ubuntu-latest
needs:
- pre_deploy
- portable
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Download build artifacts
uses: actions/download-artifact@v5
with:
name: artifacts-installer
path: artifacts-installer
- name: Download portable artifacts
uses: actions/download-artifact@v5
with:
name: artifacts-greenshot-portable
path: artifacts-greenshot-portable
- name: Create tag - name: Create tag
if: env.IS_RELEASE_BRANCH == 'true' if: env.IS_RELEASE_BRANCH == 'true'
run: | run: |
git config user.name "github-actions[bot]" git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com" git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ steps.version_info.outputs.version }}" -m "v${{ steps.version_info.outputs.version }}" git tag -a "v${{ needs.pre_deploy.outputs.version }}" -m "v${{ needs.pre_deploy.outputs.version }}"
git push origin "v${{ steps.version_info.outputs.version }}" git push origin "v${{ needs.pre_deploy.outputs.version }}"
- name: Rename installer for non-release branch - name: Rename installer for non-release branch
if: env.IS_RELEASE_BRANCH != 'true' if: env.IS_RELEASE_BRANCH != 'true'
run: | run: |
branch="${BRANCH_NAME:-${GITHUB_REF#refs/heads/}}" branch="${BRANCH_NAME:-${GITHUB_REF#refs/heads/}}"
sanitized=$(echo "$branch" | sed 's/[^a-zA-Z0-9._-]/_/g') sanitized=$(echo "$branch" | sed 's/[^a-zA-Z0-9._-]/_/g')
mv drop/Greenshot-INSTALLER-*.exe "drop/Greenshot-INSTALLER-${sanitized}.exe" mv artifacts-installer/Greenshot-INSTALLER-*.exe "artifacts-installer/Greenshot-INSTALLER-${sanitized}.exe"
shell: bash shell: bash
- name: Create GitHub Release - name: Create GitHub Release
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
with: with:
name: "Greenshot ${{ steps.version_info.outputs.version }} (continuous build)" name: "Greenshot ${{ needs.pre_deploy.outputs.version }} (continuous build)"
tag_name: ${{ env.IS_RELEASE_BRANCH == 'true' && format('v{0}', steps.version_info.outputs.version) || env.BRANCH_NAME }} tag_name: ${{ needs.pre_deploy.outputs.tag_name }}
files: drop/*.exe files: artifacts-installer/*.exe, artifacts-greenshot-portable/*.zip
generate_release_notes: true generate_release_notes: true
draft: ${{ env.IS_RELEASE_BRANCH != 'true' }} draft: ${{ env.IS_RELEASE_BRANCH != 'true' }}
prerelease: true prerelease: true
@ -160,4 +237,3 @@ jobs:
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github+json" \ -H "Accept: application/vnd.github+json" \
https://api.github.com/repos/${{ github.repository }}/pages/builds https://api.github.com/repos/${{ github.repository }}/pages/builds

112
prepare-portable.ps1 Normal file
View file

@ -0,0 +1,112 @@
param(
[Parameter(Mandatory=$true)]
[string]$RepositoryRootPath,
[Parameter(Mandatory=$true)]
[string]$BuildArtifactsPath,
[Parameter(Mandatory=$true)]
[string]$OutputPath
)
# Create portable directory
New-Item -ItemType Directory -Path "$OutputPath" -Force | Out-Null
# Copy greenshot.exe
Copy-Item "$BuildArtifactsPath\Greenshot.exe" "$OutputPath" -Force
# Copy greenshot.exe.config
Copy-Item "$BuildArtifactsPath\Greenshot.exe.config" "$OutputPath" -Force
# Copy all dlls
Copy-Item "$BuildArtifactsPath\*.dll" "$OutputPath" -Force
# Copy help files
New-Item -ItemType Directory -Path "$OutputPath\Help" -Force | Out-Null
Copy-Item "$RepositoryRootPath\src\Greenshot\Languages\*.html" "$OutputPath\Help" -Force
# Copy languages files
New-Item -ItemType Directory -Path "$OutputPath\Languages" -Force | Out-Null
Copy-Item "$RepositoryRootPath\src\Greenshot\Languages\*.xml" "$OutputPath\Languages" -Force
# Create Dummy-INI
";dummy config, used to make greenshot store the configuration in this directory" | Set-Content "$OutputPath\greenshot.ini" -Encoding UTF8
# Create Dummy-defaults-INI
";In this file you should add your default settings" | Set-Content "$OutputPath\greenshot-defaults.ini" -Encoding UTF8
# Create Dummy-fixed-INI
";In this file you should add your fixed settings" | Set-Content "$OutputPath\greenshot-fixed.ini" -Encoding UTF8
# Copy license file
Copy-Item "$RepositoryRootPath\installer\additional_files\license.txt" "$OutputPath" -Force
# Copy readme file
Copy-Item "$RepositoryRootPath\installer\additional_files\readme.txt" "$OutputPath" -Force
# Copy and rename log config file
Copy-Item "$RepositoryRootPath\src\Greenshot\log4net-zip.xml" "$OutputPath\log4net.xml" -Force
# Copy Box Plugin
New-Item -ItemType Directory -Path "$OutputPath\Languages\Greenshot.Plugin.Box" -Force | Out-Null
New-Item -ItemType Directory -Path "$OutputPath\Plugins\Greenshot.Plugin.Box" -Force | Out-Null
Copy-Item "$RepositoryRootPath\src\Greenshot.Plugin.Box\Languages\language_box*.xml" "$OutputPath\Languages\Greenshot.Plugin.Box" -Force
Copy-Item "$BuildArtifactsPath\Plugins\Greenshot.Plugin.Box\Greenshot.Plugin.Box.dll" "$OutputPath\Plugins\Greenshot.Plugin.Box" -Force
# Copy Confluence Plugin
New-Item -ItemType Directory -Path "$OutputPath\Languages\Greenshot.Plugin.Confluence" -Force | Out-Null
New-Item -ItemType Directory -Path "$OutputPath\Plugins\Greenshot.Plugin.Confluence" -Force | Out-Null
Copy-Item "$RepositoryRootPath\src\Greenshot.Plugin.Confluence\Languages\language_confluence*.xml" "$OutputPath\Languages\Greenshot.Plugin.Confluence" -Force
Copy-Item "$BuildArtifactsPath\Plugins\Greenshot.Plugin.Confluence\Greenshot.Plugin.Confluence.dll" "$OutputPath\Plugins\Greenshot.Plugin.Confluence" -Force
# Copy Dropbox Plugin
New-Item -ItemType Directory -Path "$OutputPath\Languages\Greenshot.Plugin.Dropbox" -Force | Out-Null
New-Item -ItemType Directory -Path "$OutputPath\Plugins\Greenshot.Plugin.Dropbox" -Force | Out-Null
Copy-Item "$RepositoryRootPath\src\Greenshot.Plugin.Dropbox\Languages\language_dropbox*.xml" "$OutputPath\Languages\Greenshot.Plugin.Dropbox" -Force
Copy-Item "$BuildArtifactsPath\Plugins\Greenshot.Plugin.Dropbox\Greenshot.Plugin.Dropbox.dll" "$OutputPath\Plugins\Greenshot.Plugin.Dropbox" -Force
# Copy ExternalCommand Plugin
New-Item -ItemType Directory -Path "$OutputPath\Languages\Greenshot.Plugin.ExternalCommand" -Force | Out-Null
New-Item -ItemType Directory -Path "$OutputPath\Plugins\Greenshot.Plugin.ExternalCommand" -Force | Out-Null
Copy-Item "$RepositoryRootPath\src\Greenshot.Plugin.ExternalCommand\Languages\language_externalcommand*.xml" "$OutputPath\Languages\Greenshot.Plugin.ExternalCommand" -Force
Copy-Item "$BuildArtifactsPath\Plugins\Greenshot.Plugin.ExternalCommand\Greenshot.Plugin.ExternalCommand.dll" "$OutputPath\Plugins\Greenshot.Plugin.ExternalCommand" -Force
# Copy Flickr Plugin
New-Item -ItemType Directory -Path "$OutputPath\Languages\Greenshot.Plugin.Flickr" -Force | Out-Null
New-Item -ItemType Directory -Path "$OutputPath\Plugins\Greenshot.Plugin.Flickr" -Force | Out-Null
Copy-Item "$RepositoryRootPath\src\Greenshot.Plugin.Flickr\Languages\language_flickr*.xml" "$OutputPath\Languages\Greenshot.Plugin.Flickr" -Force
Copy-Item "$BuildArtifactsPath\Plugins\Greenshot.Plugin.Flickr\Greenshot.Plugin.Flickr.dll" "$OutputPath\Plugins\Greenshot.Plugin.Flickr" -Force
# Copy GooglePhotos Plugin
New-Item -ItemType Directory -Path "$OutputPath\Languages\Greenshot.Plugin.GooglePhotos" -Force | Out-Null
New-Item -ItemType Directory -Path "$OutputPath\Plugins\Greenshot.Plugin.GooglePhotos" -Force | Out-Null
Copy-Item "$RepositoryRootPath\src\Greenshot.Plugin.GooglePhotos\Languages\language_googlephotos*.xml" "$OutputPath\Languages\Greenshot.Plugin.GooglePhotos" -Force
Copy-Item "$BuildArtifactsPath\Plugins\Greenshot.Plugin.GooglePhotos\Greenshot.Plugin.GooglePhotos.dll" "$OutputPath\Plugins\Greenshot.Plugin.GooglePhotos" -Force
# Copy Imgur Plugin
New-Item -ItemType Directory -Path "$OutputPath\Languages\Greenshot.Plugin.Imgur" -Force | Out-Null
New-Item -ItemType Directory -Path "$OutputPath\Plugins\Greenshot.Plugin.Imgur" -Force | Out-Null
Copy-Item "$RepositoryRootPath\src\Greenshot.Plugin.Imgur\Languages\language_imgur*.xml" "$OutputPath\Languages\Greenshot.Plugin.Imgur" -Force
Copy-Item "$BuildArtifactsPath\Plugins\Greenshot.Plugin.Imgur\Greenshot.Plugin.Imgur.dll" "$OutputPath\Plugins\Greenshot.Plugin.Imgur" -Force
# Copy Jira Plugin
New-Item -ItemType Directory -Path "$OutputPath\Languages\Greenshot.Plugin.Jira" -Force | Out-Null
New-Item -ItemType Directory -Path "$OutputPath\Plugins\Greenshot.Plugin.Jira" -Force | Out-Null
Copy-Item "$RepositoryRootPath\src\Greenshot.Plugin.Jira\Languages\language_jira*.xml" "$OutputPath\Languages\Greenshot.Plugin.Jira" -Force
Copy-Item "$BuildArtifactsPath\Plugins\Greenshot.Plugin.Jira\Greenshot.Plugin.Jira.dll" "$OutputPath\Plugins\Greenshot.Plugin.Jira" -Force
Copy-Item "$BuildArtifactsPath\Plugins\Greenshot.Plugin.Jira\Dapplo.Jira.dll" "$OutputPath\Plugins\Greenshot.Plugin.Jira" -Force
Copy-Item "$BuildArtifactsPath\Plugins\Greenshot.Plugin.Jira\Dapplo.Jira.SvgWinForms.dll" "$OutputPath\Plugins\Greenshot.Plugin.Jira" -Force
# Copy Office Plugin
New-Item -ItemType Directory -Path "$OutputPath\Plugins\Greenshot.Plugin.Office" -Force | Out-Null
Copy-Item "$BuildArtifactsPath\Plugins\Greenshot.Plugin.Office\Greenshot.Plugin.Office.dll" "$OutputPath\Plugins\Greenshot.Plugin.Office" -Force
# Copy Photobucket Plugin
New-Item -ItemType Directory -Path "$OutputPath\Languages\Greenshot.Plugin.Photobucket" -Force | Out-Null
New-Item -ItemType Directory -Path "$OutputPath\Plugins\Greenshot.Plugin.Photobucket" -Force | Out-Null
Copy-Item "$RepositoryRootPath\src\Greenshot.Plugin.Photobucket\Languages\language_photobucket*.xml" "$OutputPath\Languages\Greenshot.Plugin.Photobucket" -Force
Copy-Item "$BuildArtifactsPath\Plugins\Greenshot.Plugin.Photobucket\Greenshot.Plugin.Photobucket.dll" "$OutputPath\Plugins\Greenshot.Plugin.Photobucket" -Force
# Copy Win10 Plugin
New-Item -ItemType Directory -Path "$OutputPath\Languages\Greenshot.Plugin.Win10" -Force | Out-Null
New-Item -ItemType Directory -Path "$OutputPath\Plugins\Greenshot.Plugin.Win10" -Force | Out-Null
Copy-Item "$BuildArtifactsPath\Plugins\Greenshot.Plugin.Win10\Greenshot.Plugin.Win10.dll" "$OutputPath\Plugins\Greenshot.Plugin.Win10" -Force
Copy-Item "$BuildArtifactsPath\Plugins\Greenshot.Plugin.Win10\Microsoft.Toolkit.Uwp.Notifications.dll" "$OutputPath\Plugins\Greenshot.Plugin.Win10" -Force