dont use DOTNET_ROOT variable #36
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: CI/CD | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
env: | |
VERSION: '' | |
EXISTING_VERSIONS: '' | |
ESCAPED_VERSION: '' | |
jobs: | |
lib_pack: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./DataGridVueDotnet | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up .NET Core | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: '8.x' | |
- name: dotnet pack | |
run: dotnet pack -c Release -o lib-pack | |
- name: Upload artifact for deployment job | |
uses: actions/upload-artifact@v3 | |
with: | |
name: lib-pack | |
path: ${{github.workflow}}/lib-pack | |
example_api_build: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./DataGridVueDotnetExample | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up .NET Core | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: '8.x' | |
- name: Build with dotnet | |
run: dotnet build --configuration Release | |
- name: dotnet publish | |
run: dotnet publish -c Release -o example-api-release | |
- name: Upload artifact for deployment job | |
uses: actions/upload-artifact@v3 | |
with: | |
name: example-api | |
path: ${{github.workflow}}/example-api-release | |
lib_should_publish: | |
runs-on: ubuntu-latest | |
needs: [example_api_build, lib_pack] | |
defaults: | |
run: | |
working-directory: ./DataGridVueDotnet | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Parse package version | |
run: echo "VERSION=$(grep -Po '(?<=<Version>)\d+\.\d+\.\d+(?=<\/Version>)' ./DataGridVueDotnet.csproj)" >> $GITHUB_ENV | |
- name: Get existing versions from NuGet | |
run: echo "EXISTING_VERSIONS=$(curl --silent https://api.nuget.org/v3-flatcontainer/DataGridVueDotnet/index.json | tr -d '\r\n ')" >> $GITHUB_ENV | |
outputs: | |
should_publish: ${{ env.VERSION != '' && fromJson(env.EXISTING_VERSIONS) != 0 && (contains(fromJson(env.EXISTING_VERSIONS).versions, env.VERSION) == false) }} | |
lib_publish: | |
runs-on: ubuntu-latest | |
needs: [lib_should_publish] | |
if: fromJson(needs.lib_should_publish.outputs.should_publish) | |
steps: | |
- name: Download artifact from build job | |
uses: actions/download-artifact@v3 | |
with: | |
name: lib-pack | |
- name: Set up .NET Core | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: '8.x' | |
- name: dotnet nuget push | |
run: dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} | |
create_release: | |
runs-on: ubuntu-latest | |
needs: [lib_publish] | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Escape version | |
run: echo "ESCAPED_VERSION=$(echo "${{ env.VERSION }}" | sed 's/[^^]/[&]/g; s/\^/\\^/g')" >> $GITHUB_ENV | |
- name: Parse release notes | |
run: (grep -Pzo '(?<=### v${{ env.ESCAPED_VERSION }}\n)\X+?(?=\n\n)' README.md)) | tr -d '\0' > release_notes.txt | |
- name: Create release | |
uses: actions/create-release@latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ env.VERSION }} | |
release_name: v${{ env.VERSION }} | |
body_path: ${{ github.workspace }}/release_notes.txt | |
example_api_deploy: | |
runs-on: ubuntu-latest | |
needs: [lib_publish] | |
defaults: | |
run: | |
working-directory: ./DataGridVueDotnetExample | |
steps: | |
- name: Download artifact from build job | |
uses: actions/download-artifact@v3 | |
with: | |
name: example-api | |
- name: Deploy to Azure Web App | |
id: deploy-to-webapp | |
uses: azure/webapps-deploy@v2 | |
with: | |
app-name: 'data-group-vue-api-example' | |
slot-name: 'Production' | |
package: . | |
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_05C66992EE1E4240856CA5FAB1D9FD64 }} |