Skip to content

Deploy Blazor.QrCode with auto version support #4

Deploy Blazor.QrCode with auto version support

Deploy Blazor.QrCode with auto version support #4

# https://medium.com/@fran6_ca/how-to-version-and-release-net-application-e7b5811dfe4b
name: Deploy Blazor.QrCode with auto version support
on:
# --Manual run--
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout files
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
- name: Restore dependencies
run: dotnet restore ./Blazor.QrCode/Blazor.QrCode.csproj
- name: Build nuget
run: dotnet build ./Blazor.QrCode/Blazor.QrCode.csproj --no-restore --configuration Release --output ./publish
- name: Install Versionize
run: dotnet tool install --global Versionize
- name: Setup git
run: |
git config --local user.email "[email protected]"
git config --local user.name "AlexNek"
- name: Versionize Release
id: versionize
run: versionize --changelog-all --skip-dirty
continue-on-error: true
- name: No release required
if: steps.versionize.outcome != 'success'
run: echo "Skipping Release. No release required."
# - name: Push changes to GitHub
# if: steps.versionize.outcome == 'success'
# uses: ad-m/github-push-action@master
# with:
# github_token: ${{ secrets.PAT }}
# branch: ${{ github.ref }}
# tags: true
- name: "Create release"
if: steps.versionize.outcome == 'success'
uses: "actions/github-script@v5"
with:
github-token: "${{ secrets.PAT }}"
script: |
try {
const tags_url = context.payload.repository.tags_url + "?per_page=1"
const result = await github.request(tags_url)
const current_tag = result.data[0].name
await github.rest.repos.createRelease({
draft: false,
generate_release_notes: true,
name: current_tag,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: current_tag,
changelog : {
title: "Changelog",
body: "This is the changelog"
}
});
} catch (error) {
core.setFailed(error.message);
}