diff --git a/.github/scripts/get_release_version.py b/.github/scripts/get_release_version.py new file mode 100644 index 00000000..d464cd9f --- /dev/null +++ b/.github/scripts/get_release_version.py @@ -0,0 +1,30 @@ +# ------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------------------------------ + +# This script parses release version from Git tag and set the parsed version to +# environment variable, REL_VERSION. + +import os +import sys + +gitRef = os.getenv("GITHUB_REF") +tagRefPrefix = "refs/tags/v" + +if gitRef is None or not gitRef.startswith(tagRefPrefix): + print ("##[set-env name=REL_VERSION;]edge") + print ("This is daily build from {}...".format(gitRef)) + sys.exit(0) + +releaseVersion = gitRef[len(tagRefPrefix):] +releaseNotePath="docs/release_notes/v{}.md".format(releaseVersion) + +if gitRef.find("-rc.") > 0: + print ("Release Candidate build from {}...".format(gitRef)) +else: + # Set LATEST_RELEASE to true + print ("##[set-env name=LATEST_RELEASE;]true") + print ("Release build from {}...".format(gitRef)) + +print ("##[set-env name=REL_VERSION;]{}".format(releaseVersion)) \ No newline at end of file diff --git a/.github/workflows/sdk_build.yml b/.github/workflows/sdk_build.yml index d5902fcb..69ce685f 100644 --- a/.github/workflows/sdk_build.yml +++ b/.github/workflows/sdk_build.yml @@ -16,24 +16,47 @@ on: jobs: build: name: Build Projects - runs-on: windows-latest - strategy: - matrix: - configuration: [release, debug] + runs-on: ubuntu-latest + env: + NUPKG_OUTDIR: bin/Release/nugets steps: - uses: actions/checkout@v1 + - name: Parse release version + run: python ./.github/scripts/get_release_version.py - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: dotnet-version: 3.1.100 - - name: Build solution - ${{ matrix.configuration }} - run: dotnet build all.sln --configuration ${{ matrix.configuration }} - - name: Test solution - ${{ matrix.configuration }} - run: dotnet test test/test.sln --configuration ${{ matrix.configuration }} - - name: Generate Nuget Packages - ${{ matrix.configuration }} - run: dotnet pack src/prod.sln --configuration ${{ matrix.configuration }} --include-symbols --no-build + - name: Build solution - release + run: dotnet build all.sln --configuration release + - name: Test solution - release + run: dotnet test test/test.sln --configuration release + - name: Generate Nuget Packages - release + run: dotnet pack src/prod.sln --configuration release --include-symbols --no-build - name: upload artifacts uses: actions/upload-artifact@master with: - name: ${{ matrix.configuration }}_drop - path: bin/${{ matrix.configuration }}/nugets + name: release_drop + path: ${{ env.NUPKG_OUTDIR }} + - name: Publish binaries to github for tags + if: startswith(github.ref, 'refs/tags/v') + run: | + sudo npm install --silent --no-progress -g github-release-cli + + # Parse repository to get owner and repo names + OWNER_NAME="${GITHUB_REPOSITORY%%/*}" + REPO_NAME="${GITHUB_REPOSITORY#*/}" + + # Get the list of files + RELEASE_ARTIFACT=(${{ env.NUPKG_OUTDIR }}/*) + + export GITHUB_TOKEN=${{ secrets.DAPR_BOT_TOKEN }} + echo "Uploading Nuget packages to GitHub Release" + github-release upload \ + --owner $OWNER_NAME \ + --repo $REPO_NAME \ + --body "Release dapr dotnet SDK v${REL_VERSION}" \ + --tag "v${REL_VERSION}" \ + --name "Dapr dotnet SDK v${REL_VERSION}" \ + --prerelease true \ + ${RELEASE_ARTIFACT[*]}