Skip to content

Changed to deploy pages to GithubActions only when released #8

Changed to deploy pages to GithubActions only when released

Changed to deploy pages to GithubActions only when released #8

name: "Publish BlazorApp"
on:
release:
types: [released]
push:
branches:
- main
permissions:
contents: read
pages: write
id-token: write
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# Checkout the code
- uses: actions/checkout@v2
# Install .NET Core SDK
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.x
# Generate the website
- name: Install wasm tool
run: dotnet workload install wasm-tools
- name: Build and Test
run: |
dotnet build
dotnet test
- name : Set Version variable from tag
if: (github.event_name == 'release')
run: |
TAG=${{ github.event.release.tag_name }}
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
- name: Pack NuGet Package
if: (github.event_name == 'release')
run: dotnet pack -c Release --include-symbols --include-source -p:PackageVersion=${VERSION}
- name: Publish NuGet Package
if: (github.event_name == 'release')
run: dotnet nuget push 'src/**/*.nupkg' -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
# Generate the website
- name: Publish Sample Page
if: (github.event_name == 'release')
run: dotnet publish ./demo/Squircle.Blazor.Demo/Squircle.Blazor.Demo.csproj -c Release -p:GHPages=true
- name: Setup Pages
if: (github.event_name == 'release')
uses: actions/configure-pages@v4
- name: Upload artifact
if: (github.event_name == 'release')
uses: actions/upload-pages-artifact@v3
with:
path: './demo/Squircle.Blazor.Demo/bin/Release/net8.0/publish/wwwroot'
# Deploy the site
- name: Deploy to GitHub Pages
if: (github.event_name == 'release')
id: deployment
uses: actions/deploy-pages@v4