Performance Report #1
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: Performance Report | |
on: | |
push: | |
tags: | |
- 'v*' # Trigger on push to version tags | |
workflow_dispatch: # Allow manual triggering | |
jobs: | |
report: | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 # Allow 1 hour for the job to complete | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Ensure all tags are fetched | |
- name: Determine Tag Name | |
id: determine_tag | |
run: | | |
if [[ "${{ github.event_name }}" == "push" ]]; then | |
# For push events, get the tag from github.ref | |
TAG_NAME="${GITHUB_REF#refs/tags/}" | |
else | |
# For manual trigger, get the latest tag | |
TAG_NAME=$(git describe --tags $(git rev-list --tags --max-count=1)) | |
fi | |
echo "Using tag: $TAG_NAME" | |
echo "::set-output name=tag::$TAG_NAME" | |
- name: Check out Repository at Tag | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ steps.determine_tag.outputs.tag }} # Checkout at the determined tag | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ vars.DOTNET_VERSION }} # Using repository-level environment variable | |
- name: Run benchmarks | |
run: | | |
cd src/Nino.Benchmark | |
dotnet run -c Release | |
- name: Fetch report | |
id: fetch_report | |
run: | | |
cd src/Nino.Benchmark/BenchmarkDotNet.Artifacts/results | |
PERF_CONTENT=$(cat Nino.Benchmark.SimpleTest-report-github.md) | |
echo "$PERF_CONTENT" | |
echo "::set-output name=perf_content::$PERF_CONTENT" | |
- name: Install GitHub CLI | |
run: sudo apt-get install -y gh | |
- name: Authenticate GitHub CLI | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token | |
- name: Update Release Body | |
env: | |
TAG_NAME: ${{ steps.determine_tag.outputs.tag }} | |
PERF_CONTENT: ${{ steps.fetch_report.outputs.perf_content }} | |
run: | | |
# Retrieve the existing release body | |
RELEASE_BODY=$(gh release view "$TAG_NAME" --json body --jq '.body') | |
echo "Current release body: $RELEASE_BODY" | |
# Prepare new content and update the release body | |
NEW_CONTENT="\n## Performance Report\n$PERF_CONTENT" | |
UPDATED_BODY="${RELEASE_BODY}${NEW_CONTENT}" | |
# Update the release notes | |
gh release edit "$TAG_NAME" --notes "$UPDATED_BODY" |