Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: CI

"on":
push:
branches:
- develop
- "feature/**"
- "fix/**"
- "hotfix/**"
pull_request:
branches:
- develop
- master

# RUNNING_LOCALLY is set to 'true' by ci-cd-test-run.ps1 via act's --env flag.
# On real GitHub Actions the variable is empty, so steps gated on it run normally.
env:
RUNNING_LOCALLY: ""

jobs:
validate-branch:
name: Validate Branch Name
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Check branch naming convention
env:
BRANCH: ${{ github.head_ref }}
run: |
if [[ ! "$BRANCH" =~ ^(feature|fix|hotfix)/.+ ]] && [[ "$BRANCH" != "develop" ]]; then
echo "::error::Branch '$BRANCH' does not follow naming conventions."
echo "::error::PR source branches must be 'develop' or prefixed with 'feature/', 'fix/', or 'hotfix/'."
exit 1
fi
echo "Branch '$BRANCH' follows naming conventions."

build-and-test:
name: Build & Test (${{ matrix.framework }})
needs: validate-branch
# Run on push events (validate-branch skipped) OR on valid PRs (validate-branch succeeded)
if: always() && (needs.validate-branch.result == 'success' || needs.validate-branch.result == 'skipped')
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
framework: ["net8.0", "net9.0", "net10.0"]
steps:
- uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Restore
run: dotnet restore src/System.Text.Json.Stream.CI.slnf
- name: Build
run: dotnet build src/System.Text.Json.Stream.CI.slnf --no-restore --configuration Release -p:GeneratePackageOnBuild=false
- name: Test (${{ matrix.framework }})
run: |
dotnet test src/System.Text.Json.Stream.Tests/System.Text.Json.Stream.Tests.csproj \
--no-build --no-restore \
--configuration Release --framework ${{ matrix.framework }} \
--logger "trx;LogFileName=test-results-${{ matrix.framework }}.trx"
- name: Upload test results
uses: actions/upload-artifact@v7
# Skipped when running locally via act (RUNNING_LOCALLY=true passed by ci-cd-test-run.ps1).
# On real GitHub Actions RUNNING_LOCALLY is empty, so the step runs and failures are fatal.
if: always() && env.RUNNING_LOCALLY == ''
with:
name: test-results-${{ matrix.framework }}
path: "**/*.trx"
88 changes: 88 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Release

"on":
push:
branches:
- master

jobs:
release:
name: Build, Test & Publish to NuGet
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Restore
run: dotnet restore src/System.Text.Json.Stream.CI.slnf
- name: Build
run: dotnet build src/System.Text.Json.Stream.CI.slnf --no-restore --configuration Release -p:GeneratePackageOnBuild=false
- name: Test (net8.0)
run: |
dotnet test src/System.Text.Json.Stream.Tests/System.Text.Json.Stream.Tests.csproj \
--no-build --no-restore --configuration Release --framework net8.0
- name: Test (net9.0)
run: |
dotnet test src/System.Text.Json.Stream.Tests/System.Text.Json.Stream.Tests.csproj \
--no-build --no-restore --configuration Release --framework net9.0
- name: Test (net10.0)
run: |
dotnet test src/System.Text.Json.Stream.Tests/System.Text.Json.Stream.Tests.csproj \
--no-build --no-restore --configuration Release --framework net10.0
- name: Extract version from csproj
id: version
run: |
VERSION=$(grep -m1 '<Version>' src/System.Text.Json.Stream/System.Text.Json.Stream.csproj \
| sed 's/.*<Version>//;s/<\/Version>.*//' \
| tr -d '[:space:]')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
echo "Resolved version: $VERSION"
- name: Check if this version was already released
id: tag_check
run: |
if git ls-remote --tags origin "refs/tags/v${{ steps.version.outputs.version }}" | grep -q .; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Pack NuGet package
if: steps.tag_check.outputs.exists == 'false'
run: |
dotnet pack src/System.Text.Json.Stream/System.Text.Json.Stream.csproj \
--no-build --configuration Release --output ./artifacts
- name: Create GitHub Release
if: steps.tag_check.outputs.exists == 'false'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ steps.version.outputs.tag }}" \
--title "Release ${{ steps.version.outputs.tag }}" \
--generate-notes \
./artifacts/Utf8JsonAsyncStreamReader.${{ steps.version.outputs.version }}.nupkg \
./artifacts/Utf8JsonAsyncStreamReader.${{ steps.version.outputs.version }}.snupkg
- name: Push Utf8JsonAsyncStreamReader to NuGet.org
if: steps.tag_check.outputs.exists == 'false'
run: |
dotnet nuget push \
"./artifacts/Utf8JsonAsyncStreamReader.${{ steps.version.outputs.version }}.nupkg" \
--api-key ${{ secrets.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
- name: Push Utf8JsonAsyncStreamReader symbols to NuGet.org
if: steps.tag_check.outputs.exists == 'false'
run: |
dotnet nuget push \
"./artifacts/Utf8JsonAsyncStreamReader.${{ steps.version.outputs.version }}.snupkg" \
--api-key ${{ secrets.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
Loading