From 80a52eb892cc2262e35108f9de49a1b9a0afdf50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JasonXuDeveloper=20-=20=E5=82=91?= Date: Sat, 9 Nov 2024 21:47:05 +1100 Subject: [PATCH] ci modification --- .github/workflows/ci.yml | 48 ++++++++-------- .github/workflows/report.yml | 106 ++++++++++++++++++----------------- 2 files changed, 78 insertions(+), 76 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8923c3..70e7d98 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,32 +16,32 @@ jobs: runs-on: ubuntu-latest steps: - # Checkout the code - - name: Checkout code - uses: actions/checkout@v3 - - # Set up .NET Core using the repository-level DOTNET_VERSION environment variable - - name: Setup .NET - uses: actions/setup-dotnet@v3 - with: - dotnet-version: ${{ vars.DOTNET_VERSION }} # Using repository-level environment variable - - # Restore dependencies - - name: Restore dependencies - run: dotnet restore - - # Build the solution - - name: Build solution - run: dotnet build --no-restore - - # Run unit tests - - name: Test - run: dotnet test --no-build --verbosity normal + # Checkout the code + - name: Checkout code + uses: actions/checkout@v3 + + # Set up .NET Core using the repository-level DOTNET_VERSION environment variable + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: ${{ vars.DOTNET_VERSION }} # Using repository-level environment variable + + # Restore dependencies + - name: Restore dependencies + run: dotnet restore + + # Build the solution + - name: Build solution + run: dotnet build --no-restore + + # Run unit tests + - name: Test + run: dotnet test --no-build --verbosity normal bump-version: runs-on: ubuntu-latest if: ${{ startsWith(github.event.head_commit.message, 'release v') }} - needs: [build] + needs: [ build ] # override working directory for this job defaults: @@ -138,7 +138,7 @@ jobs: run: | git clone https://github.com/Lachee/Unity-Package-Exporter.git "../tools/unity-package-exporter" dotnet publish -c Release -o ../tools "../tools/unity-package-exporter/UnityPackageExporter" - + # Pack the assets - name: Package Project run: | @@ -203,4 +203,4 @@ jobs: echo "Current directory: $(pwd)" for package in ./artifacts/*.nupkg; do dotnet nuget push "$package" --api-key ${{ secrets.MYTOKEN }} --source https://api.nuget.org/v3/index.json - done + done \ No newline at end of file diff --git a/.github/workflows/report.yml b/.github/workflows/report.yml index 77db935..22b481f 100644 --- a/.github/workflows/report.yml +++ b/.github/workflows/report.yml @@ -1,10 +1,12 @@ name: Performance Report on: - push: - tags: - - 'v*' # Trigger on push to version tags - workflow_dispatch: # Allow manual triggering + workflow_dispatch: # Allow manual triggering + # When another workflow is completed and successful + workflow_run: + workflows: [ Code Check and Release ] + types: + - completed jobs: report: @@ -12,56 +14,56 @@ jobs: 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: 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 "tag=$TAG_NAME" >> $GITHUB_ENV + - 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 "tag=$TAG_NAME" >> $GITHUB_ENV - - name: Check out Repository at Tag - uses: actions/checkout@v2 - with: - ref: ${{ env.tag }} # Checkout at the determined tag + - name: Check out Repository at Tag + uses: actions/checkout@v2 + with: + ref: ${{ env.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: 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: Run benchmarks + run: | + cd src/Nino.Benchmark + dotnet run -c Release - - name: Update Release Body - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Set GH_TOKEN for GitHub CLI - TAG_NAME: ${{ env.tag }} - run: | - # Read PERF_CONTENT from the file - cd src/Nino.Benchmark/BenchmarkDotNet.Artifacts/results - PERF_CONTENT=$(cat Nino.Benchmark.SimpleTest-report-github.md) - echo "Performance report content: $PERF_CONTENT" - - # Retrieve the existing release body - RELEASE_BODY=$(gh release view "$TAG_NAME" --json body --jq '.body') - echo "Current release body: $RELEASE_BODY" - - # Prepare the new content by using printf to handle multiline content correctly - NEW_CONTENT=$(printf "\n\n## Performance Report\n
expand\n\n%s\n\n
\n" "$PERF_CONTENT") - UPDATED_BODY=$(printf "%s%s" "$RELEASE_BODY" "$NEW_CONTENT") - - # Update the release notes - gh release edit "$TAG_NAME" --notes "$UPDATED_BODY" + - name: Update Release Body + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Set GH_TOKEN for GitHub CLI + TAG_NAME: ${{ env.tag }} + run: | + # Read PERF_CONTENT from the file + cd src/Nino.Benchmark/BenchmarkDotNet.Artifacts/results + PERF_CONTENT=$(cat Nino.Benchmark.SimpleTest-report-github.md) + echo "Performance report content: $PERF_CONTENT" + + # Retrieve the existing release body + RELEASE_BODY=$(gh release view "$TAG_NAME" --json body --jq '.body') + echo "Current release body: $RELEASE_BODY" + + # Prepare the new content by using printf to handle multiline content correctly + NEW_CONTENT=$(printf "\n\n## Performance Report\n
expand\n\n%s\n\n
\n" "$PERF_CONTENT") + UPDATED_BODY=$(printf "%s%s" "$RELEASE_BODY" "$NEW_CONTENT") + + # Update the release notes + gh release edit "$TAG_NAME" --notes "$UPDATED_BODY"