[devops] add GitHub release job and trigger CI on pull requests #596
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
| name: Build Package | |
| on: | |
| push: | |
| pull_request: | |
| defaults: | |
| run: | |
| working-directory: src | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| include: | |
| - os: windows-latest | |
| solution: Simplify.slnx | |
| tests-exclude-category: Linux | |
| - os: ubuntu-latest | |
| solution: Simplify.NetCore.slnx | |
| tests-exclude-category: Windows | |
| test-framework-command: --framework net10.0 | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Install DotNet | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: "10.0.x" | |
| - name: Restore Dependencies | |
| run: dotnet restore ${{ matrix.solution }} | |
| - name: Build Packages | |
| run: dotnet build ${{ matrix.solution }} --no-restore -c Release | |
| - name: Perform Unit Testing | |
| run: dotnet test ${{ matrix.solution }} --no-build -c Release ${{ matrix.test-framework-command }} --filter "TestCategory != Integration & TestCategory != ${{ matrix.tests-exclude-category }}" --verbosity normal | |
| - name: Create Packages | |
| run: dotnet pack ${{ matrix.solution }} --no-build -c Release -o ./publish | |
| - name: Create Source Packages | |
| if: ${{ matrix.os == 'windows-latest' }} | |
| shell: pwsh | |
| working-directory: . | |
| run: ./MakeSourcePackages.ps1 | |
| - name: Create packages artifact | |
| if: ${{ matrix.os == 'windows-latest' }} | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: Packages | |
| path: ./src/publish/ | |
| release: | |
| if: startsWith(github.ref, 'refs/tags/') | |
| needs: build | |
| permissions: | |
| contents: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Parse tag | |
| id: tag | |
| run: | | |
| tag="${{ github.ref_name }}" | |
| name=$(echo "$tag" | sed 's/\.[0-9][0-9]*.*//') | |
| version=$(echo "$tag" | sed 's/^[^0-9]*//') | |
| echo "name=$name" >> $GITHUB_OUTPUT | |
| echo "version=$version" >> $GITHUB_OUTPUT | |
| - name: Extract changelog entry | |
| run: | | |
| awk '/^## \[/{if(f) exit; f=1; next} f' \ | |
| "src/${{ steps.tag.outputs.name }}/CHANGELOG.md" \ | |
| > /tmp/release_notes.md | |
| - name: Create release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release create "${{ github.ref_name }}" \ | |
| --title "${{ steps.tag.outputs.name }} ${{ steps.tag.outputs.version }}" \ | |
| --notes-file /tmp/release_notes.md |