align table #26
This file contains hidden or 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
| # This is a basic workflow to help you get started with Actions | |
| name: 'CI' | |
| # Controls when the workflow will run | |
| on: | |
| # Triggers the workflow on push or pr to master | |
| push: | |
| branches: [ "master" ] | |
| pull_request: | |
| branches: [ "master" ] | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| inputs: | |
| reason: | |
| description: 'The reason for running the workflow' | |
| required: true | |
| default: 'Manual Run' | |
| # A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
| jobs: | |
| # This workflow contains a single job called "main-job" | |
| main-job: | |
| # The type of runner that the job will run on | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| # Steps represent a sequence of tasks that will be executed as part of the job | |
| steps: | |
| # Log run info | |
| - name: Log run info | |
| run: | | |
| echo 🎉 The job was automatically triggered by a ${{ github.event_name }} event. | |
| echo 🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub! | |
| echo Current directory is: ${{ github.workspace }} | |
| # Print the reason for the manual run if applicable | |
| - name: Print Manual Run Reason | |
| if: ${{ github.event_name == 'workflow_dispatch' }} | |
| run: | | |
| echo 'Reason: ${{ github.event.inputs.reason }}' | |
| # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
| - name: Check out code in repository | |
| uses: actions/checkout@v4 | |
| # Install the .NET Core | |
| - name: Install .NET Core | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| # Check if release is needed | |
| - name: Check if release is needed | |
| if: > # is a push event and sanity check on master branch | |
| github.event_name == 'push' | |
| && github.ref == 'refs/heads/master' | |
| run: | # RELEASE_NEEDED is set to a string value (keep that in mind that if you don't check value) | |
| git fetch origin master --depth=2 | |
| CHANGED=$(git diff --name-only HEAD^ HEAD || true) | |
| echo "Changed files:" | |
| echo "$CHANGED" | |
| if echo "$CHANGED" | grep -qE '^FInt\/FInt\.cs$'; then | |
| echo "RELEASE_NEEDED=true" >> $GITHUB_ENV | |
| echo "Release is needed." | |
| fi | |
| # Restore | |
| - name: Restore | |
| run: dotnet restore | |
| # Build | |
| - name: Build | |
| run: dotnet build FInt.sln --no-restore | |
| # Run Tests -- output test results in the Visual Studio Test Results (TRX) format. | |
| - name: Run Tests | |
| run: dotnet test FInt.sln --no-build --logger "trx" | |
| # Set Version | |
| - name: Set Version | |
| if: success() && env.RELEASE_NEEDED | |
| run: echo "VERSION=v.$(date +'%Y.%m.%d.%H.%M.%S')-$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
| # Create Release | |
| - name: Create New Release | |
| if: success() && env.RELEASE_NEEDED | |
| run: | | |
| VERSION="v.$(date +'%Y.%m.%d.%H.%M.%S')-$(git rev-parse --short HEAD)" | |
| echo "Creating release with version $VERSION" | |
| gh release create "${VERSION}" FInt/FInt.cs \ | |
| --title "Release $VERSION" \ | |
| --notes "Release generated on $(date +'%Y.%m.%d') from commit $(git rev-parse --short HEAD)" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Upload Test Artifacts | |
| - name: Upload Test Results | |
| if: always() # ensures results are uploaded even if tests fail | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results | |
| path: '**/TestResults/*.trx' | |
| # Publish Test Report | |
| - name: Publish Test Report | |
| if: always() | |
| uses: dorny/test-reporter@v2 | |
| with: | |
| name: .NET Test Results | |
| path: '**/TestResults/*.trx' | |
| reporter: dotnet-trx | |
| fail-on-error: false |