Remove redundant file from NuGet, roll out new version (#364) #74
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
name: Deploy to NuGet | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build-and-test: | |
name: Build & Test | |
uses: CropperBlazor/Cropper.Blazor/.github/workflows/build-test-template.yml@dev | |
secrets: inherit | |
with: | |
configuration: 'Release' | |
publish-coverage: true | |
deploy-to-nuget: | |
name: Deploy to NuGet | |
runs-on: ubuntu-latest | |
needs: build-and-test | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Restore dependencies | |
run: dotnet restore | |
working-directory: src/Cropper.Blazor/Cropper.Blazor | |
- name: Restore dotnet tool | |
run: dotnet tool restore | |
working-directory: src/Cropper.Blazor/Cropper.Blazor | |
- name: Build | |
run: dotnet build -c Release --no-restore | |
working-directory: src/Cropper.Blazor/Cropper.Blazor | |
- name: Pack package | |
run: dotnet pack -c Release | |
working-directory: src/Cropper.Blazor/Cropper.Blazor | |
- name: Verify file keys in Cropper.Blazor.staticwebassets.runtime.json | |
run: | | |
error_messages="" | |
for net_version in 6.0 7.0 8.0; do | |
json_path="src/Cropper.Blazor/Cropper.Blazor/bin/Release/net$net_version/Cropper.Blazor.staticwebassets.runtime.json" | |
if [ -f "$json_path" ]; then | |
if ! jq -e '.Root.Children["cropperJsInterop.min.js"]' "$json_path" > /dev/null; then | |
error_messages+="For .NET $net_version: Key 'cropperJsInterop.min.js' does not exist.\n" | |
fi | |
if ! jq -e '.Root.Children["cropperJsInterop.js"]' "$json_path" > /dev/null; then | |
error_messages+="For .NET $net_version: Key 'cropperJsInterop.js' does not exist.\n" | |
fi | |
if ! jq -e '.Root.Children["cropper.min.css"]' "$json_path" > /dev/null; then | |
error_messages+="For .NET $net_version: Key 'cropper.min.css' does not exist.\n" | |
fi | |
if ! jq -e '.Root.Children["cropper.min.js"]' "$json_path" > /dev/null; then | |
error_messages+="For .NET $net_version: Key 'cropper.min.js' does not exist.\n" | |
fi | |
else | |
error_messages+="File $json_path does not exist for .NET $net_version.\n" | |
fi | |
done | |
if [ -n "$error_messages" ]; then | |
echo -e "$error_messages" | |
exit 1 | |
else | |
echo "All keys exist for .NET 6, .NET 7, and .NET 8." | |
fi | |
- name: Push to NuGet Gallery | |
run: dotnet nuget push bin/Release/*.nupkg --source "https://api.nuget.org/v3/index.json" --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate | |
working-directory: src/Cropper.Blazor/Cropper.Blazor | |
- name: Add NuGet repository source | |
run: dotnet nuget add source --username CropperBlazor --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/CropperBlazor/index.json" | |
- name: Publish NuGet package to GitHub packages | |
run: dotnet nuget push bin/Release/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "github" --skip-duplicate | |
working-directory: src/Cropper.Blazor/Cropper.Blazor |