From 2e0ae8c7f2621b6425bbc2b4da6d1a5351e14dec Mon Sep 17 00:00:00 2001 From: Eduard Date: Sat, 4 Apr 2026 21:15:44 +0300 Subject: [PATCH 1/2] =?UTF-8?q?ci:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20installer=20and=20updater=20Velopack.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 31 ++++++++++++++++++++++++++++--- MyLibrary/MyLibrary.csproj | 4 ++++ MyLibrary/Program.cs | 29 +++++++++++++++++++++++++++-- 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ada8092..e9f83f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,15 +1,16 @@ -name: CI +name: CI/CD on: push: branches: [ main, master ] pull_request: branches: [ main, master ] + release: + types: [created] jobs: build-and-test: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 @@ -25,4 +26,28 @@ jobs: run: dotnet build --no-restore - name: Test - run: dotnet test --no-build --verbosity normal \ No newline at end of file + run: dotnet test --no-build --verbosity normal + + deploy-windows: + needs: build-and-test + if: github.event_name == 'release' + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '10.0.x' + + - name: Install Velopack CLI + run: dotnet tool install -g vpk + + - name: Publish + run: dotnet publish MyLibrary/MyLibrary.csproj -c Release -r win-x64 --self-contained -o publish/win + + - name: Pack with Velopack + run: vpk pack -u MyLibrary -v ${{ github.event.release.tag_name }} -p publish/win -e MyLibrary.exe + + - name: Upload to GitHub Release + run: vpk upload github --repoUrl https://github.com/edwardyum/MyLibrary --token ${{ secrets.GITHUB_TOKEN }} --tag ${{ github.event.release.tag_name }} \ No newline at end of file diff --git a/MyLibrary/MyLibrary.csproj b/MyLibrary/MyLibrary.csproj index ed9781c..c57fec1 100644 --- a/MyLibrary/MyLibrary.csproj +++ b/MyLibrary/MyLibrary.csproj @@ -7,4 +7,8 @@ enable + + + + diff --git a/MyLibrary/Program.cs b/MyLibrary/Program.cs index 3751555..4d7a77b 100644 --- a/MyLibrary/Program.cs +++ b/MyLibrary/Program.cs @@ -1,2 +1,27 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +using Velopack; +using Velopack.Sources; + +VelopackApp.Build().Run(); + +var mgr = new UpdateManager( + new GithubSource("https://github.com/edwardyum/MyLibrary", null, false)); + +Console.WriteLine("Проверяем обновления..."); +var newVersion = await mgr.CheckForUpdatesAsync(); + +if (newVersion != null) +{ + Console.WriteLine($"Доступна новая версия: {newVersion.TargetFullRelease.Version}"); + Console.WriteLine("Устанавливаем обновление..."); + await mgr.DownloadUpdatesAsync(newVersion); + mgr.ApplyUpdatesAndRestart(newVersion); +} +else +{ + Console.WriteLine("Обновлений нет."); +} + +var calculator = new MyLibrary.Calculator(); +Console.WriteLine($"2 + 3 = {calculator.Add(2, 3)}"); +Console.WriteLine("Нажмите любую клавишу..."); +Console.ReadKey(); \ No newline at end of file From 674215ee875d4be94e850e3d8cc9ab44c94c4dfd Mon Sep 17 00:00:00 2001 From: Eduard Date: Sat, 4 Apr 2026 21:50:45 +0300 Subject: [PATCH 2/2] =?UTF-8?q?ci:=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D1=8B=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B0=20(=D0=BD=D0=B5)=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80?= =?UTF-8?q?=D0=B6=D0=BA=D0=B8=20"v"=20=D0=B2=20=D1=82=D0=B5=D0=B3=D0=B0?= =?UTF-8?q?=D1=85=20=D0=B2=20=D0=B8=D0=BD=D1=81=D1=82=D1=83=D1=80=D0=BA?= =?UTF-8?q?=D1=86=D0=B8=D0=B8=20=D0=BA=20CICD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e9f83f7..15115d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,8 +46,15 @@ jobs: - name: Publish run: dotnet publish MyLibrary/MyLibrary.csproj -c Release -r win-x64 --self-contained -o publish/win + - name: Get version + id: version + run: | + $version = "${{ github.event.release.tag_name }}" -replace '^v', '' + echo "VERSION=$version" >> $env:GITHUB_OUTPUT + shell: pwsh + - name: Pack with Velopack - run: vpk pack -u MyLibrary -v ${{ github.event.release.tag_name }} -p publish/win -e MyLibrary.exe + run: vpk pack -u MyLibrary -v ${{ steps.version.outputs.VERSION }} -p publish/win -e MyLibrary.exe - name: Upload to GitHub Release run: vpk upload github --repoUrl https://github.com/edwardyum/MyLibrary --token ${{ secrets.GITHUB_TOKEN }} --tag ${{ github.event.release.tag_name }} \ No newline at end of file