Merge pull request #357 from dymaptic/develop #28
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build a .NET project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
name: Main Branch Release Build | |
on: | |
push: | |
branches: [ "main", "gh-action-testing" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repository to the GitHub Actions runner | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Restore dependencies | |
run: dotnet restore ./src/dymaptic.GeoBlazor.Core/dymaptic.GeoBlazor.Core.csproj | |
- name: Copy Assets and Generate JS | |
shell: pwsh | |
run: | | |
cd ./src/dymaptic.GeoBlazor.Core | |
npm install | |
npm run releaseBuild | |
./assetCopy.ps1 | |
cd ../.. | |
- name: Build Core | |
run: dotnet build ./src/dymaptic.GeoBlazor.Core/dymaptic.GeoBlazor.Core.csproj --no-restore /p:OptOutFromCoreEsBuild=true /p:GenerateDocs=false -c Release | |
- name: Install xmllint | |
shell: bash | |
run: | | |
sudo apt update | |
sudo apt install -y libxml2-utils | |
- name: Copy Build Versions | |
run: | | |
CORE_VERSION=$(xmllint --xpath "//PropertyGroup/CoreVersion/text()" ./Directory.Build.props) | |
echo "CORE_VERSION=$CORE_VERSION" >> $GITHUB_ENV | |
- name: Verify JS Files and Assets | |
shell: pwsh | |
continue-on-error: false | |
# Verify that the JS files are present in the output directory | |
run: | | |
$nugetPath = "./src/dymaptic.GeoBlazor.Core/bin/Release/dymaptic.GeoBlazor.Core.${{env.CORE_VERSION}}.nupkg" | |
$extractPath = "./src/dymaptic.GeoBlazor.Core/bin/Release/extract" | |
$jsFilePath = "staticwebassets/js/arcGisJsInterop.js" | |
Expand-Archive -Path $nugetPath -Force -DestinationPath $extractPath | |
$contents = Get-ChildItem -Path $extractPath -Recurse | |
$fileExists = $contents -match [regex]::Escape($jsFilePath) | |
if ($fileExists) { | |
Write-Output "JS file exists" | |
} else { | |
Write-Error "JS file does not exist" | |
Exit 1 | |
} | |
- name: Copy PR Release Notes | |
run: | | |
PR_DESCRIPTION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
"https://api.github.com/repos/${{ github.repository }}/pulls?state=closed&sort=updated&direction=desc" | \ | |
jq -r '.[0].body') | |
DESC_PLUS_EOF="${PR_DESCRIPTION}\nEOF" | |
echo "PR_DESCRIPTION<<EOF" >> $GITHUB_ENV | |
echo "$DESC_PLUS_EOF" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Create Release | |
if: github.ref == 'refs/heads/main' | |
uses: softprops/action-gh-release@v1 | |
with: | |
body: "${{env.PR_DESCRIPTION}}" | |
tag_name: "v${{env.CORE_VERSION}}" | |
generate_release_notes: true | |
prerelease: true | |
files: | | |
./src/dymaptic.GeoBlazor.Core/bin/Release/dymaptic.GeoBlazor.Core.*.nupkg | |
- name: Upload nuget artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: .core-nuget | |
path: ./src/dymaptic.GeoBlazor.Core/bin/Release/dymaptic.GeoBlazor.Core.*.nupkg | |
nuget-push: | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Download artifact from build job | |
uses: actions/download-artifact@v3 | |
with: | |
name: .core-nuget | |
- name: Publish Core to Nuget | |
run: dotnet nuget push ./dymaptic.GeoBlazor.Core.*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json --skip-duplicate |