diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f1d546ad..d7cc5cc3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,43 +38,6 @@ jobs: run: dotnet build --configuration ${{ env.CONFIGURATION }} --configfile nuget.config - name: Run Unit Tests - ${{ env.CONFIGURATION }} run: dotnet test --configuration ${{ env.CONFIGURATION }} --no-build --verbosity normal - - name: Generate NuGet Packages - ${{ env.CONFIGURATION }} - if: startswith(github.ref, 'refs/tags/v') - run: dotnet pack --configuration ${{ env.CONFIGURATION }} -p:PackageVersion=${REL_VERSION} - # Since we create local development nuget packages, we need to clean them up. - - name: Clean up development Nuget packages - if: startswith(github.ref, 'refs/tags/v') - run: rm -rf ${{ env.NUPKG_OUTDIR }}/*${{ env.DEV_VERSION_SUFFIX }}*.nupkg - - name: Upload artifacts - uses: actions/upload-artifact@master - with: - 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.GITHUB_TOKEN }} - echo "Uploading Nuget packages to GitHub Release" - github-release upload \ - --owner $OWNER_NAME \ - --repo $REPO_NAME \ - --body "Release dapr azure functions extension v${REL_VERSION}" \ - --tag "v${REL_VERSION}" \ - --name "Dapr Azure Functions Extension v${REL_VERSION}" \ - ${RELEASE_ARTIFACT[*]} - - name: Publish nuget packages to nuget.org for tags - if: startswith(github.ref, 'refs/tags/v') && !(endsWith(github.ref, '-rc') || endsWith(github.ref, '-dev') || endsWith(github.ref, '-prerelease')) - run: | - dotnet nuget push "${{ env.NUPKG_OUTDIR }}/*.nupkg" --skip-duplicate --api-key ${{ secrets.NUGETORG_DAPR_API_KEY }} --source https://api.nuget.org/v3/index.json # The docker image is not pushed for pull requests, # but the image is built to ensure that the Dockerfile and the sample app are valid. - name: Set a sample app registry when it is a pull request @@ -91,8 +54,45 @@ jobs: - name: Push samples docker images if: github.event_name != 'pull_request' run: | - echo performing docker login + echo performing docker login docker login -u ${{ secrets.DOCKER_REGISTRY_ID }} -p ${{ secrets.DOCKER_REGISTRY_PASS }} echo pushing docker image for ${{ env.DOTNET_SAMPLE_APP_IMAGE_NAME }} echo image with tag ${{ env.APP_REGISTRY }}/${{ env.DOTNET_SAMPLE_APP_IMAGE_NAME }}:${{ env.REL_VERSION }} will be pushed docker push ${{ env.APP_REGISTRY }}/${{ env.DOTNET_SAMPLE_APP_IMAGE_NAME }}:${{ env.REL_VERSION }} + - name: Generate NuGet Packages - ${{ env.CONFIGURATION }} + if: startswith(github.ref, 'refs/tags/v') + run: dotnet pack --configuration ${{ env.CONFIGURATION }} -p:PackageVersion=${REL_VERSION} + # Since we create local development nuget packages, we need to clean them up. + - name: Clean up development Nuget packages + if: startswith(github.ref, 'refs/tags/v') + run: rm -rf $NUPKG_OUTDIR/*${DEV_VERSION_SUFFIX}.*{nupkg,snupkg} + - name: Upload artifacts + uses: actions/upload-artifact@master + if: startswith(github.ref, 'refs/tags/v') + with: + name: release_drop + path: ${{ env.NUPKG_OUTDIR }} + - name: Create a GitHub Release + if: startswith(github.ref, 'refs/tags/v') + run: | + RELEASE_ARTIFACT=(${NUPKG_OUTDIR}/*) + export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} + echo "Uploading Nuget packages to GitHub Release" + + gh release create "v${REL_VERSION}" ${RELEASE_ARTIFACT[*]} \ + --repo "${GITHUB_REPOSITORY}" \ + --title "Azure Functions Dapr Extension v${REL_VERSION}" \ + --notes "Release Azure Functions Dapr Extension v${REL_VERSION}" + - name: Upload NuGet packages to Azure blob storage + if: | + startsWith(github.ref, 'refs/tags/v') && + !(endsWith(github.ref, '-rc') || endsWith(github.ref, '-dev') || endsWith(github.ref, '-prerelease')) && + github.repository == 'Azure/azure-functions-dapr-extension' + run: | + # Install azcopy + wget -O azcopy_v10.tar.gz https://aka.ms/downloadazcopy-v10-linux && tar -xf azcopy_v10.tar.gz --strip-components=1 + + # Upload nuget packages to Azure blob storage + export AZCOPY_SPA_CLIENT_SECRET=${{ secrets.AZCOPY_SPA_CLIENT_SECRET }} + ./azcopy login --service-principal --application-id ${{ secrets.AZCOPY_SPA_APPLICATION_ID }} + ./azcopy copy "${{ env.NUPKG_OUTDIR }}/*" "https://azuresdkpartnerdrops.blob.core.windows.net/drops/azure-functions-dapr-extension/dotnet/${{ env.REL_VERSION }}/" diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 00000000..6a6d4c7c --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,2 @@ +# These owners are the maintainers of this repo +* @Azure/maintainers-azure-functions-dapr-extension \ No newline at end of file diff --git a/docs/development/README.md b/docs/development/README.md new file mode 100644 index 00000000..da5c70e4 --- /dev/null +++ b/docs/development/README.md @@ -0,0 +1,5 @@ +# Development + +* [Development](./development.md) - How to setup local development environment and build/test Azure Functions Dapr Extension. +* [Release Process](./release-process.md) - How to release Azure Functions Dapr Extension. +* [Setup Continuous Integration](./setup-ci.md) - How to setup GitHub Actions for Azure Functions Dapr Extension. \ No newline at end of file diff --git a/docs/development/development.md b/docs/development/development.md new file mode 100644 index 00000000..048a217b --- /dev/null +++ b/docs/development/development.md @@ -0,0 +1,13 @@ +# Setup Local Development + +This document is a TODO. + +## Prerequisites + +## Clone the repository + +## Build the project + +## Run tests + +## Debugging diff --git a/docs/development/release-process.md b/docs/development/release-process.md new file mode 100644 index 00000000..02d90220 --- /dev/null +++ b/docs/development/release-process.md @@ -0,0 +1,19 @@ +# Release Process + +This document describes the release process for Azure Functions Dapr Extension. + +## Trigger a release + +1. Create a new branch from `master` branch in the format of `release-.` (e.g. `release-0.14`). +2. Add a tag and push it. +```bash +$ git tag "v0.14.0-preview01" -m "v0.14.0-preview01" +$ git push --tags +``` +3. CI will create a new release in GitHub, push the NuGet packages to Azure blob storage, and upload the sample image to Docker registry. +4. [MICROSOFT PROCESS] Upload the NuGet packages to NuGet.org using the Azure DevOps pipeline. +5. Edit the release notes if necessary. +6. Test and validate the functionalities with the specific version +7. If there are regressions and bugs, fix them in `release-*` branch and merge back to master +8. Create new tags (with suffix -preview02, -preview03, etc.) and push them to trigger CI to create new releases +9. Repeat from 6 to 8 until all bugs are fixed \ No newline at end of file diff --git a/docs/development/setup-ci.md b/docs/development/setup-ci.md new file mode 100644 index 00000000..aee6b03b --- /dev/null +++ b/docs/development/setup-ci.md @@ -0,0 +1,32 @@ +# Setup Continuous Integration + +This repository uses GitHub Actions to automate the build and release. As long as you have a GitHub Account, you can set up your own private Actions in your own fork. This document helps you set up the continuous integration for Azure Functions Dapr Extension. + +## Prerequisites + +A GitHub account. + +## Setup + +1. Fork [Azure/azure-functions-dapr-extension](https://github.com/Azure/azure-functions-dapr-extension) to your GitHub account. +2. Go to `Settings`-> `Secrets and variables` -> `Actions`. +3. Add the required repository secrets. + +### Required repository secrets + +| Name | Description | +|--|--| +| DOCKER_REGISTRY_ID | Username for Docker registry, required for uploading sample image| +| DOCKER_REGISTRY_PASS | Password for Docker registry, required for uploading sample image| +| DOCKER_REGISTRY | URL to Docker registry, required for uploading sample image | +| AZCOPY_SPA_APPLICATION_ID | Service principal application ID for AzCopy, required for uploading NuGet packages | +| AZCOPY_SPA_CLIENT_SECRET | Service principal client secret for AzCopy, required for uploading NuGet packages | +| GITHUB_TOKEN | GitHub token, required for creating release | + +Notes +- `GITHUB_TOKEN` is automatically set by GitHub Actions, so you don't need to set it manually. +- `AZCOPY_*` secrets should not be set for forks, as they are only required for uploading NuGet packages for official release. The step that requires these secrets will be skipped for forks. + +4. Go to `Settings` -> `Actions` -> `General` and make sure to allow running GitHub Actions. + + diff --git a/properties/common.props b/properties/common.props index 06bff13f..fdec7e47 100644 --- a/properties/common.props +++ b/properties/common.props @@ -30,10 +30,11 @@ - + +