diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4483a7e..2456955 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,9 @@ on: pull_request: branches: [main] +permissions: + contents: read + jobs: test: name: Test @@ -32,8 +35,61 @@ jobs: working-directory: cli run: pytest -v --tb=short + build_addin: + name: Build add-in + runs-on: [self-hosted, windows, arcgispro] + steps: + - uses: actions/checkout@v4 + + - name: Set up .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: "8.0.x" + + - name: Locate MSBuild + id: msbuild + shell: pwsh + run: | + $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" + if (-not (Test-Path $vswhere)) { + throw "vswhere.exe not found at $vswhere" + } + + $msbuild = & $vswhere -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe | Select-Object -First 1 + if (-not $msbuild) { + throw "MSBuild.exe not found" + } + + "path=$msbuild" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + + - name: Build add-in + working-directory: ProExporter + shell: pwsh + run: | + & "${{ steps.msbuild.outputs.path }}" ProExporter.sln /restore /p:Configuration=Release + + - name: Collect add-in + shell: pwsh + run: | + New-Item -ItemType Directory -Force -Path cli/arcgispro_cli/addin | Out-Null + $addin = Get-ChildItem -Path ProExporter -Filter *.esriAddinX -Recurse | Select-Object -First 1 + if (-not $addin) { + throw "Built add-in (.esriAddinX) not found" + } + + Copy-Item $addin.FullName cli/arcgispro_cli/addin/ProExporter.addin + Get-Item cli/arcgispro_cli/addin/ProExporter.addin | Format-List FullName, Length, LastWriteTime + + - name: Upload add-in artifact + uses: actions/upload-artifact@v4 + with: + name: proexporter-addin + path: cli/arcgispro_cli/addin/ProExporter.addin + retention-days: 1 + build: name: Build check + needs: [test, build_addin] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -48,6 +104,15 @@ jobs: - name: Install build tools run: pip install build + - name: Download built add-in + uses: actions/download-artifact@v4 + with: + name: proexporter-addin + path: ${{ runner.temp }}/proexporter-addin + + - name: Install built add-in + run: cp "${{ runner.temp }}/proexporter-addin/ProExporter.addin" cli/arcgispro_cli/addin/ProExporter.addin + - name: Build package working-directory: cli run: python -m build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3997af8..eec5a75 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,9 +4,64 @@ on: release: types: [published] +permissions: + contents: read + jobs: + build_addin: + name: Build add-in + runs-on: [self-hosted, windows, arcgispro] + steps: + - uses: actions/checkout@v4 + + - name: Set up .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: "8.0.x" + + - name: Locate MSBuild + id: msbuild + shell: pwsh + run: | + $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" + if (-not (Test-Path $vswhere)) { + throw "vswhere.exe not found at $vswhere" + } + + $msbuild = & $vswhere -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe | Select-Object -First 1 + if (-not $msbuild) { + throw "MSBuild.exe not found" + } + + "path=$msbuild" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + + - name: Build add-in + working-directory: ProExporter + shell: pwsh + run: | + & "${{ steps.msbuild.outputs.path }}" ProExporter.sln /restore /p:Configuration=Release + + - name: Collect add-in + shell: pwsh + run: | + New-Item -ItemType Directory -Force -Path cli/arcgispro_cli/addin | Out-Null + $addin = Get-ChildItem -Path ProExporter -Filter *.esriAddinX -Recurse | Select-Object -First 1 + if (-not $addin) { + throw "Built add-in (.esriAddinX) not found" + } + + Copy-Item $addin.FullName cli/arcgispro_cli/addin/ProExporter.addin + + - name: Upload add-in artifact + uses: actions/upload-artifact@v4 + with: + name: proexporter-addin + path: cli/arcgispro_cli/addin/ProExporter.addin + retention-days: 1 + build: name: Build distribution + needs: build_addin runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -19,6 +74,15 @@ jobs: - name: Install build tools run: pip install build + - name: Download built add-in + uses: actions/download-artifact@v4 + with: + name: proexporter-addin + path: ${{ runner.temp }}/proexporter-addin + + - name: Install built add-in + run: cp "${{ runner.temp }}/proexporter-addin/ProExporter.addin" cli/arcgispro_cli/addin/ProExporter.addin + - name: Build package working-directory: cli run: python -m build diff --git a/README.md b/README.md index 71c4fac..a041886 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,10 @@ This happens if `C:\Program Files\ArcGIS\Pro\bin` is on your PATH. Options: ## Development -To build the add-in from source, you'll need: +The CLI test/build workflow now rebuilds the bundled add-in in CI on a self-hosted +Windows runner with ArcGIS Pro and the Pro SDK installed. + +To build the add-in from source locally, you'll need: - Visual Studio 2022 with ArcGIS Pro SDK extension - .NET 8 SDK @@ -113,7 +116,7 @@ git clone https://github.com/danmaps/arcgispro_cli.git cd arcgispro_cli/cli pip install -e . -# Build add-in in Visual Studio +# Build add-in in Visual Studio when testing add-in changes locally # Open ProExporter/ProExporter.sln # Build → Build Solution (Release) ```