diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml deleted file mode 100644 index ecb9c9a..0000000 --- a/.github/workflows/cd.yml +++ /dev/null @@ -1,42 +0,0 @@ -on: - push: - # Sequence of patterns matched against refs/tags - tags: - - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 - -name: Upload Release Asset - -jobs: - build: - name: Upload Release Asset - runs-on: windows-latest - steps: - # checkout code from repo - - name: Checkout - uses: actions/checkout@v1 - # Install Modules - - name: Setup Build Script - run: Install-Module -Name Invoke-MsBuild -Force - # use msbuild to build the solution - - name: Create Distribution - run: Bin\Build.ps1 - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: 'true' - prerelease: ${{ contains(github.ref, '-') }} - - name: Upload Release Asset - id: upload-release-asset - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: Data/EnVar-Plugin.zip - asset_name: EnVar-Plugin.zip - asset_content_type: application/zip diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index efcbc4e..9d3bd53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,89 +1,78 @@ name: Build NSIS Plugin Dll's and Artifacts on: pull_request: - types: [opened, reopened, synchronize] paths: - '*.sln' - - '*.vcproj' - '*.vcxproj' - 'Bin/Build.ps1' - - 'Src/**.c' - - 'Src/**.h' - - 'Src/**.lib' - - 'Tests/plugin_test.nsi' + - 'Src/**' + - 'Tests/PluginTest.nsi' + - '.github/workflows/**' push: - branches: + branches: - main - - master # remove onces migrated to main - tags: - - v* + # A tag push runs every time: GitHub doesn't apply path filters to tags + tags: + - 'v*' paths: - '*.sln' - - '*.vcproj' - '*.vcxproj' - 'Bin/Build.ps1' - - 'Src/**.c' - - 'Src/**.h' - - 'Src/**.lib' - - 'Tests/plugin_test.nsi' + - 'Src/**' + - 'Tests/PluginTest.nsi' + - '.github/workflows/**' + workflow_dispatch: jobs: build: - name: Build Dll's - runs-on: windows-latest + name: Build and test + # windows-2022 has Visual Studio 2022 (toolset v143) and NSIS 3.10, which the plugin test needs + runs-on: windows-2022 steps: - # checkout code from repo - name: Checkout - uses: actions/checkout@v1 - # Install Modules - - name: Setup Build Script + uses: actions/checkout@v7 + - name: Install Invoke-MsBuild run: Install-Module -Name Invoke-MsBuild -Force - # use msbuild to build the solution - - name: Build Plugin + - name: Build plugin run: Bin\Build.ps1 New-Build - # upload artifacts - - name: Publish Lib Artifact - uses: actions/upload-artifact@v1 + - name: Create EnVar-Plugin.zip + run: | + Bin\Build.ps1 New-Distribution + Bin\Build.ps1 Compress-Distribution + - name: Test plugin + run: | + Bin\Build.ps1 Deploy-Plugin + Bin\Build.ps1 Build-PluginTest + Bin\Build.ps1 Start-PluginTest + - name: Publish EnVar-Plugin.zip + uses: actions/upload-artifact@v7 with: - name: Lib-${{ github.sha }} - path: Lib - - name: Publish Obj Artifact - uses: actions/upload-artifact@v1 - with: - name: Obj-${{ github.sha }} - path: Obj - # Prepare distribution folder - - name: Create Distribution - run: Bin\Build.ps1 New-Distribution, Compress-Distribution - # Publish Distribution Artifact - - name: Publish Dist Artifact - uses: actions/upload-artifact@v1 - with: - name: Dist-${{ github.sha }} - path: Dist - - name: Publish Data Artifact - uses: actions/upload-artifact@v1 - with: - name: Data-${{ github.sha }} - path: Data - # Deploy plugin - - name: Deploy plugin - run: Bin\Build.ps1 Deploy-Plugin - # Build PluginTest - - name: Build PluginTest - run: Bin\Build.ps1 Build-PluginTest - # Publish PluginTest Artifact - - name: Publish PluginTest Artifact - uses: actions/upload-artifact@v1 - with: - name: PluginTest-${{ github.sha }} - path: Tests\PluginTest.exe - # Test Plugin - - name: Test Plugin - run: Bin\Build.ps1 Start-PluginTest - # Publish PluginTest Log Artifact - - name: Publish PluginTest Log Artifact + name: EnVar-Plugin + path: Data/EnVar-Plugin.zip + - name: Publish PluginTest log if: ${{ always() }} - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v7 + with: + name: PluginTest-Log + path: Tests/PluginTest.log + release: + name: Release + if: startsWith(github.ref, 'refs/tags/v') + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Download EnVar-Plugin.zip + uses: actions/download-artifact@v8 with: - name: PluginTest-Log-${{ github.sha }} - path: Tests\PluginTest.log + name: EnVar-Plugin + # A release made in the web UI already exists when its new tag starts this run, so it only gets the zip + - name: Create the release or attach EnVar-Plugin.zip to it + env: + GH_TOKEN: ${{ github.token }} + run: | + if gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then + gh release upload "$GITHUB_REF_NAME" EnVar-Plugin.zip --repo "$GITHUB_REPOSITORY" --clobber + else + gh release create "$GITHUB_REF_NAME" EnVar-Plugin.zip --repo "$GITHUB_REPOSITORY" --title "$GITHUB_REF_NAME" --generate-notes --verify-tag + fi diff --git a/Bin/Build.ps1 b/Bin/Build.ps1 index 3e8d2c1..9ba0c1d 100644 --- a/Bin/Build.ps1 +++ b/Bin/Build.ps1 @@ -111,6 +111,10 @@ function Update-Build Write-Host "succeeded" } else { Write-Host "failed" + if ($BuildResult.BuildLogFilePath -and (Test-Path $BuildResult.BuildLogFilePath)) { + Get-Content $BuildResult.BuildLogFilePath + } + Throw "Build of $Configuration for $Platform failed: $($BuildResult.Message)" } $BuildResults += $BuildResult diff --git a/EnVar.vcxproj b/EnVar.vcxproj index 21b786f..1f655b8 100644 --- a/EnVar.vcxproj +++ b/EnVar.vcxproj @@ -37,51 +37,51 @@ {BA0F65F4-BA26-4236-8A77-93B53AE9EF6F} EnVar - 10.0.16299.0 + 10.0 DynamicLibrary - v142 + v143 Unicode false DynamicLibrary - v142 + v143 Unicode DynamicLibrary - v142 + v143 MultiByte false DynamicLibrary - v142 + v143 MultiByte DynamicLibrary - v142 + v143 Unicode false DynamicLibrary - v142 + v143 Unicode DynamicLibrary - v142 + v143 MultiByte false DynamicLibrary - v142 + v143 MultiByte diff --git a/README.md b/README.md index f0382a9..dd9a1f5 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Copied/forked from https://github.com/GsNSIS/EnVar 2025-04-24 so that DDEV has a build version that it can depend on, since we don't know the maintenance status of the upstream. -![Build NSIS Plugin Dll's and Artifacts](https://github.com/GsNSIS/EnVar/workflows/Build%20NSIS%20Plugin%20Dll's%20and%20Artifacts/badge.svg) +[![Build NSIS Plugin Dll's and Artifacts](https://github.com/ddev/EnVar/actions/workflows/ci.yml/badge.svg)](https://github.com/ddev/EnVar/actions/workflows/ci.yml) Originally coded by Jason Ross aka JasonFriday13 on the forums. @@ -85,7 +85,7 @@ For a example NSIS script visit [Docs/example.nsi](https://github.com/GsNSIS/EnV ### System Requirements -* Visual Studio 2015 or higher +* Visual Studio 2022 or higher, with the v143 toolset * PowerShell 3.0 or higher (to run the build script) * PowerShell Module [Invoke-MsBuild](https://github.com/deadlydog/Invoke-MsBuild#readme) (to run the build script) @@ -101,12 +101,41 @@ Install-Module -Name Invoke-MsBuild -Force ### Build and deploy All build and deploy actions are implemented in a PowerShell -[build script](https://github.com/GsNSIS/EnVar/tree/master/Bin/Build.ps1). +[build script](Bin/Build.ps1). Run `help Bin\Build` to get a detailed description of the available steps. For a normal build and deploy run simply call the script without any parameters. +### Releasing + +DDEV's installer build (`.ci-scripts/nsis_setup.sh` in ddev/ddev) downloads +`EnVar-Plugin.zip` from the latest release here. + +1. Merge the changes to `main` and wait for the CI run to pass. +2. Tag `main` with the next version and push the tag: + + ```bash + git switch main && git pull + git tag v0.3.2 + git push origin v0.3.2 + ``` + +3. The tag push runs the [CI workflow](https://github.com/ddev/EnVar/actions/workflows/ci.yml). + Its `release` job publishes the release with `EnVar-Plugin.zip`, and with notes + generated from the merged pull requests. + +If the build fails, delete the tag with `git push --delete origin v0.3.2`, +fix the problem, and tag again. + +You can also create the release in the web UI: "Draft a new release", a new tag +such as `v0.3.2` on `main`, "Generate release notes", and "Publish release". The +new tag runs the same workflow, which attaches `EnVar-Plugin.zip` to that release +a few minutes later. Until then the latest release has no zip, so DDEV's installer +build fails to download it. If the build fails, the release stays without the zip +until you fix the problem and run the +[workflow](https://github.com/ddev/EnVar/actions/workflows/ci.yml) again for the tag. + ## License This project is released under the terms of the [zlib License](LICENSE)