Skip to content

Commit

Permalink
Add single file portable build + autocreation of release after tagging
Browse files Browse the repository at this point in the history
Single file portable build:
- No .Net installation necessary, but big file and slow execution

Auto creation of release after tagging:
- Workflow is triggered after a tag is created. Release is in state prereleased and includes all files from the github action workflow and are scanned by virus total
  • Loading branch information
Edi61 committed Mar 14, 2023
1 parent c864430 commit a6bf497
Show file tree
Hide file tree
Showing 15 changed files with 299 additions and 46 deletions.
143 changes: 114 additions & 29 deletions .github/workflows/AntiDupl_CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ name: AntiDupl CI Build

on:
push:
branches: [ "master" ]
branches:
- master
tags:
- v*
pull_request:
branches: [ "master" ]

Expand All @@ -12,10 +15,10 @@ env:
jobs:

build:

strategy:
matrix:
configuration: [Debug, Release]
configuration: [Debug, Release, Publish]

runs-on: windows-latest

Expand All @@ -25,7 +28,13 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3


- name: Read version.txt
id: version
uses: juliangruber/read-file-action@v1
with:
path: ./src/version.txt

- name: Setup MSBuild.exe
uses: microsoft/[email protected]

Expand All @@ -46,44 +55,120 @@ jobs:
run: |
${{ github.workspace }}/vcpkg/vcpkg.exe integrate install
- name: Build
- if: matrix.configuration == 'Release' || matrix.configuration == 'Debug'
name: Build
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /m /p:Configuration=$env:Configuration $env:Solution_Name
env:
Configuration: ${{ matrix.configuration }}

- name: Make release binary and source files

- if: matrix.configuration == 'Publish'
name: Build
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /m $env:Solution_Name /p:Configuration=$env:Configuration -restore -t:Publish -p:PublishProfile="AntiDuplPublishSingleFile"
env:
Configuration: ${{ matrix.configuration }}

- if: matrix.configuration == 'Release'
name: Make release binary and source files
working-directory: ${{env.GITHUB_WORKSPACE}}
run: |
cd cmd
.\MakeBin.cmd
.\MakeSrc.cmd
- name: VirusTotal Scan
uses: crazy-max/ghaction-virustotal@v3
env:
VT_API_KEY: ${{ secrets.VT_API_KEY }}
if: matrix.configuration == 'Release' && env.VT_API_KEY != null
with:
vt_api_key: ${{ secrets.VT_API_KEY }}
files: |
${{ github.workspace }}\bin\Release\AntiDupl.NET.WinForms.exe
- if: matrix.configuration == 'Publish'
name: Make release binary and source files
working-directory: ${{env.GITHUB_WORKSPACE}}
run: |
cd cmd
.\MakePublish.cmd
- if: matrix.configuration == 'Release'
name: Upload build
uses: actions/upload-artifact@v3
with:
name: AntiDupl.NET-2.3.11 build
name: "AntiDupl.NET-${{ steps.version.outputs.content }} build"
path: |
${{ github.workspace }}\out\bin\AntiDupl.NET-2.3.11.exe
${{ github.workspace }}\out\bin\AntiDupl.NET-2.3.11.exe.hash.txt
${{ github.workspace }}\out\bin\AntiDupl.NET-2.3.11.7z
${{ github.workspace }}\out\bin\AntiDupl.NET-2.3.11.7z.hash.txt
- name: Upload source
${{ github.workspace }}\out\bin\AntiDupl.NET-${{ steps.version.outputs.content }}.exe
${{ github.workspace }}\out\bin\AntiDupl.NET-${{ steps.version.outputs.content }}.exe.hash.txt
${{ github.workspace }}\out\bin\AntiDupl.NET-${{ steps.version.outputs.content }}.zip
${{ github.workspace }}\out\bin\AntiDupl.NET-${{ steps.version.outputs.content }}.zip.hash.txt
- if: matrix.configuration == 'Publish'
name: Upload build SingleFilePortable
uses: actions/upload-artifact@v3
with:
name: AntiDupl.NET-2.3.11 sources
name: "AntiDupl.NET-${{ steps.version.outputs.content }} build SingleFilePortable"
path: |
${{ github.workspace }}\out\src\AntiDupl.NET-2.3.11_Sources.7z
${{ github.workspace }}\out\src\AntiDupl.NET-2.3.11_Sources.7z.hash.txt
${{ github.workspace }}\out\Publish\AntiDupl.NET-${{ steps.version.outputs.content }}_SingleFilePortable.exe
${{ github.workspace }}\out\Publish\AntiDupl.NET-${{ steps.version.outputs.content }}_SingleFilePortable.exe.hash.txt
${{ github.workspace }}\out\Publish\AntiDupl.NET-${{ steps.version.outputs.content }}_SingleFilePortable.zip
${{ github.workspace }}\out\Publish\AntiDupl.NET-${{ steps.version.outputs.content }}_SingleFilePortable.zip.hash.txt
create-draft-release:
if: startsWith(github.ref, 'refs/tags/')
needs: build

runs-on: windows-latest

steps:
- uses: msys2/setup-msys2@v2

- name: Checkout
uses: actions/checkout@v3

- name: Read version.txt
id: version
uses: juliangruber/read-file-action@v1
with:
path: ./src/version.txt

- name: Load all artifacts
uses: actions/download-artifact@v3
with:
name: "AntiDupl.NET-${{ steps.version.outputs.content }} build"

- name: Load all artifacts
uses: actions/download-artifact@v3
with:
name: "AntiDupl.NET-${{ steps.version.outputs.content }} build SingleFilePortable"

- name: Virus Total Scan
id: scan_files
uses: crazy-max/ghaction-virustotal@v3
with:
vt_api_key: ${{ secrets.VT_API_KEY }}
files: |
AntiDupl.NET-${{ steps.version.outputs.content }}.exe
AntiDupl.NET-${{ steps.version.outputs.content }}.zip
AntiDupl.NET-${{ steps.version.outputs.content }}_SingleFilePortable.exe
AntiDupl.NET-${{ steps.version.outputs.content }}_SingleFilePortable.zip
- name: Generate VirusTotal Body
shell: msys2 {0}
run: |
echo "🛡 [VirusTotal GitHub Action](https://github.com/crazy-max/ghaction-virustotal) analysis:" >> body.txt
echo "" >> body.txt
analysis="${{ steps.scan_files.outputs.analysis }}"
while read -d, -r pair; do
IFS='=' read -r filename analysisURL <<<"$pair"
echo "* [$(basename $filename)]($analysisURL)" >> body.txt
done <<<"$analysis,"
- name: GitHub Release
uses: softprops/action-gh-release@v1
with:
name: "AntiDupl.NET v${{ steps.version.outputs.content }}"
body_path: body.txt
prerelease: true
files: |
AntiDupl.NET-${{ steps.version.outputs.content }}.exe
AntiDupl.NET-${{ steps.version.outputs.content }}.exe.hash.txt
AntiDupl.NET-${{ steps.version.outputs.content }}.zip
AntiDupl.NET-${{ steps.version.outputs.content }}.zip.hash.txt
AntiDupl.NET-${{ steps.version.outputs.content }}_SingleFilePortable.exe
AntiDupl.NET-${{ steps.version.outputs.content }}_SingleFilePortable.exe.hash.txt
AntiDupl.NET-${{ steps.version.outputs.content }}_SingleFilePortable.zip
AntiDupl.NET-${{ steps.version.outputs.content }}_SingleFilePortable.zip.hash.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ publish/
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
#*.pubxml
#*.publishproj

# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
Expand Down
4 changes: 2 additions & 2 deletions cmd/MakeBin.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ certutil -hashfile %OUT_DIR%\AntiDupl.NET-%VERSION%.zip SHA256 > %OUT_DIR%\AntiD
) else (
.\7-zip\7za_2201.exe a -sfx7z.sfx %OUT_DIR%\AntiDupl.NET-%VERSION%.exe %TMP_DIR%
certutil -hashfile %OUT_DIR%\AntiDupl.NET-%VERSION%.exe SHA256 > %OUT_DIR%\AntiDupl.NET-%VERSION%.exe.hash.txt
.\7-zip\7za_2201.exe a %OUT_DIR%\AntiDupl.NET-%VERSION%.7z .\%TMP_DIR%\*
certutil -hashfile %OUT_DIR%\AntiDupl.NET-%VERSION%.7z SHA256 > %OUT_DIR%\AntiDupl.NET-%VERSION%.7z.hash.txt
.\7-zip\7za_2201.exe a -tzip %OUT_DIR%\AntiDupl.NET-%VERSION%.zip .\%TMP_DIR%\*
certutil -hashfile %OUT_DIR%\AntiDupl.NET-%VERSION%.zip SHA256 > %OUT_DIR%\AntiDupl.NET-%VERSION%.zip.hash.txt
)
53 changes: 53 additions & 0 deletions cmd/MakePublish.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
@echo off

set RAR_EXE="C:\Program Files\WinRAR\WinRar.exe"

set ROOT_DIR=..
set VERSION_FILE=%ROOT_DIR%\src\version.txt

if not exist %VERSION_FILE% (
echo Can't find "%VERSION_FILE%" file!
exit 0
)

set VERSION=
for /f "delims=" %%i in ('type %VERSION_FILE%') do set VERSION=%%i

set OUT_DIR=%ROOT_DIR%\out\publish
set TMP_DIR=%ROOT_DIR%\out\publish\AntiDupl.NET-%VERSION%

if not exist %OUT_DIR% mkdir %OUT_DIR%

if exist %TMP_DIR% (
echo Delete old files:
erase %TMP_DIR%\* /q /s /f
rmdir %TMP_DIR% /q /s
)

if not exist %TMP_DIR% mkdir %TMP_DIR%

set PUBLISH_DIR=%ROOT_DIR%\out\publish\AntiDupl.NET

robocopy "%ROOT_DIR%\data\resources" "%PUBLISH_DIR%\data\resources" /MIR
if %ERRORLEVEL% GEQ 8 exit 0
robocopy "%ROOT_DIR%\docs\data\resources" "%PUBLISH_DIR%\data\resources" /S
if %ERRORLEVEL% GEQ 8 exit 0

xcopy %ROOT_DIR%\bin\Publish\AntiDupl.dll %PUBLISH_DIR% /y
xcopy %ROOT_DIR%\bin\Publish\AntiDupl.pdb %PUBLISH_DIR% /y
xcopy %ROOT_DIR%\bin\Publish\AntiDupl.NET.WinForms.runtimeconfig.json %PUBLISH_DIR% /y
xcopy %ROOT_DIR%\bin\Publish\AntiDupl.NET.WPF.runtimeconfig.json %PUBLISH_DIR% /y

xcopy %PUBLISH_DIR% %TMP_DIR% /y /i /s

if exist %RAR_EXE% (
%RAR_EXE% a -ep1 -s -m5 -r -sfx %OUT_DIR%\AntiDupl.NET-%VERSION%_SingleFilePortable.exe %TMP_DIR%
certutil -hashfile %OUT_DIR%\AntiDupl.NET-%VERSION%.exe SHA256 > %OUT_DIR%\AntiDupl.NET-%VERSION%_SingleFilePortable.exe.hash.txt
%RAR_EXE% a -afzip -ep1 -r %OUT_DIR%\AntiDupl.NET-%VERSION%_SingleFilePortable.zip %TMP_DIR%
certutil -hashfile %OUT_DIR%\AntiDupl.NET-%VERSION%.zip SHA256 > %OUT_DIR%\AntiDupl.NET-%VERSION%_SingleFilePortable.zip.hash.txt
) else (
.\7-zip\7za_2201.exe a -sfx7z.sfx %OUT_DIR%\AntiDupl.NET-%VERSION%_SingleFilePortable.exe %TMP_DIR%
certutil -hashfile %OUT_DIR%\AntiDupl.NET-%VERSION%_SingleFilePortable.exe SHA256 > %OUT_DIR%\AntiDupl.NET-%VERSION%_SingleFilePortable.exe.hash.txt
.\7-zip\7za_2201.exe a -tzip %OUT_DIR%\AntiDupl.NET-%VERSION%_SingleFilePortable.zip .\%TMP_DIR%\*
certutil -hashfile %OUT_DIR%\AntiDupl.NET-%VERSION%_SingleFilePortable.zip SHA256 > %OUT_DIR%\AntiDupl.NET-%VERSION%_SingleFilePortable.zip.hash.txt
)
4 changes: 2 additions & 2 deletions cmd/MakeSrc.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ if exist %RAR_EXE% (
%RAR_EXE% a -afzip -ep1 -r %OUT_DIR%\AntiDupl.NET-%VERSION%_Sources.zip %TMP_DIR%
certutil -hashfile %OUT_DIR%\AntiDupl.NET-%VERSION%_Sources.zip SHA256 > %OUT_DIR%\AntiDupl.NET-%VERSION%_Sources.zip.hash.txt
) else (
.\7-zip\7za_2201.exe a %OUT_DIR%\AntiDupl.NET-%VERSION%_Sources.7z .\%TMP_DIR%\*
certutil -hashfile %OUT_DIR%\AntiDupl.NET-%VERSION%_Sources.7z SHA256 > %OUT_DIR%\AntiDupl.NET-%VERSION%_Sources.7z.hash.txt
.\7-zip\7za_2201.exe a -tzip %OUT_DIR%\AntiDupl.NET-%VERSION%_Sources.zip .\%TMP_DIR%\*
certutil -hashfile %OUT_DIR%\AntiDupl.NET-%VERSION%_Sources.zip SHA256 > %OUT_DIR%\AntiDupl.NET-%VERSION%_Sources.zip.hash.txt
)
17 changes: 16 additions & 1 deletion src/AntiDupl.NET.Core/AntiDupl.NET.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<AssemblyVersion>2.3.11.1</AssemblyVersion>
<FileVersion>2.3.11.1</FileVersion>
<Platforms>x64</Platforms>
<Configurations>Debug;Release</Configurations>
<Configurations>Debug;Release;Publish</Configurations>
<Authors>ErmIg;Gigas002</Authors>
<Description>Bindings to native AntuDpl packages</Description>
<Copyright>ErmIg © 2002-2023</Copyright>
Expand All @@ -28,6 +28,12 @@
<BaseOutputPath>..\..\bin\Release\</BaseOutputPath>
<OutputPath>..\..\bin\Release\</OutputPath>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Publish|x64'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<BaseOutputPath>..\..\bin\Publish\</BaseOutputPath>
<OutputPath>..\..\bin\Publish\</OutputPath>
</PropertyGroup>

<PropertyGroup>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
Expand All @@ -47,6 +53,15 @@
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Publish'">
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\LICENSE">
<Pack>True</Pack>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Publish</Configuration>
<Platform>x64</Platform>
<PublishDir>..\..\bin\Publish\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>false</PublishSingleFile>
<PublishReadyToRun>false</PublishReadyToRun>
<PublishTrimmed>false</PublishTrimmed>
</PropertyGroup>
</Project>
6 changes: 5 additions & 1 deletion src/AntiDupl.NET.WPF/AntiDupl.NET.WPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<OutputType>WinExe</OutputType>
<PublishUrl>publish</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
Expand All @@ -24,6 +23,7 @@
<Platforms>x64</Platforms>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<Configurations>Debug;Release;Publish</Configurations>
</PropertyGroup>
<PropertyGroup>
<StartupObject>AntiDupl.NET.WPF.App</StartupObject>
Expand All @@ -37,6 +37,10 @@
<BaseOutputPath>..\..\bin\Release\</BaseOutputPath>
<OutputPath>..\..\bin\Release\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Publish|x64'">
<BaseOutputPath>..\..\bin\Publish\</BaseOutputPath>
<OutputPath>..\..\bin\Publish\</OutputPath>
</PropertyGroup>
<ItemGroup>
<AppDesigner Include="Properties\" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Publish</Configuration>
<Platform>x64</Platform>
<PublishDir>..\..\out\Publish\AntiDupl.NET</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>true</PublishReadyToRun>
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
</Project>
7 changes: 7 additions & 0 deletions src/AntiDupl.NET.WinForms/AntiDupl.NET.WinForms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<StartupObject>AntiDupl.NET.WinForms.Program</StartupObject>
<Configurations>Debug;Release;Publish</Configurations>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand All @@ -29,6 +30,12 @@
<OutputPath>..\..\bin\Release\</OutputPath>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Publish|x64'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<BaseOutputPath>..\..\bin\Publish\</BaseOutputPath>
<OutputPath>..\..\bin\Publish\</OutputPath>
</PropertyGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="$(SolutionDir)\..\cmd\CopyData.cmd $(SolutionDir)\.. $(SolutionDir)\..\bin\$(ConfigurationName)" />
</Target>
Expand Down
Loading

0 comments on commit a6bf497

Please sign in to comment.