From 2e0ae8c7f2621b6425bbc2b4da6d1a5351e14dec Mon Sep 17 00:00:00 2001 From: Eduard Date: Sat, 4 Apr 2026 21:15:44 +0300 Subject: [PATCH 1/3] =?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 1f7c4e1050d5a95fa6bd9c954e708165f7a99be7 Mon Sep 17 00:00:00 2001 From: Eduard Date: Sun, 5 Apr 2026 11:21:16 +0300 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82?= =?UTF-8?q?=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B8=20=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15115d7..2f22a3b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,15 +46,11 @@ jobs: - name: Publish run: dotnet publish MyLibrary/MyLibrary.csproj -c Release -r win-x64 --self-contained -o publish/win - - name: Get version - id: version + - name: Pack with Velopack run: | $version = "${{ github.event.release.tag_name }}" -replace '^v', '' - echo "VERSION=$version" >> $env:GITHUB_OUTPUT + vpk pack -u MyLibrary -v $version -p publish/win -e MyLibrary.exe shell: pwsh - - name: Pack with Velopack - 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 From c539a57afe6a95eef4ece54adbf564a777e6bf05 Mon Sep 17 00:00:00 2001 From: Eduard Date: Sun, 5 Apr 2026 11:40:54 +0300 Subject: [PATCH 3/3] ci: permisions to write in releae after Action on CD. --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f22a3b..909a22c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,8 @@ jobs: needs: build-and-test if: github.event_name == 'release' runs-on: windows-latest + permissions: + contents: write steps: - uses: actions/checkout@v4