diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml deleted file mode 100644 index 30be94164..000000000 --- a/.github/workflows/build-and-release.yml +++ /dev/null @@ -1,211 +0,0 @@ -name: Build and Release NuGet Package - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -env: - GLOBAL_JSON_PATH: "./src/global.json" - PROJECT_PATH: "./src/TurboHTTP.slnx" - PACKAGE_OUTPUT_DIRECTORY: "./packages" - TEST_OUTPUT_DIRECTORY: "${{ github.workspace }}/testresults" - COVERAGE_REPORT_DIRECTORY: "./coveragereport" - -permissions: - contents: write - deployments: write - checks: write - pull-requests: write - -jobs: - build: - permissions: - contents: read - checks: write - pull-requests: write - # For a list of available runner types, refer to - # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on - runs-on: ubuntu-latest - outputs: - releaseVersion: ${{ steps.gitversion.outputs.majorMinorPatch }} - - steps: - - name: Checkout - uses: actions/checkout@v6 - with: - fetch-depth: 0 - - # Install the .NET Core workload - - name: Install .NET Core - uses: actions/setup-dotnet@v5 - with: - global-json-file: ${{ env.GLOBAL_JSON_PATH }} - cache: true - cache-dependency-path: "**/packages.lock.json" - - - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v3 - with: - versionSpec: '5.x' - - - name: Determine Version - id: gitversion - uses: gittools/actions/gitversion/execute@v3 - - - name: Generate Release Notes for nuget - id: plain-notes - env: - VERSION: ${{ steps.gitversion.outputs.semVer }} - run: | - cat > notes.md << EOF - 🎯 TurboHTTP v$VERSION - - 📦 NuGet: https://nuget.org/packages/TurboHTTP - 🔗 Release: https://github.com/st0o0/TurboHTTP/releases/v$VERSION - - See release page for full changelog and details! - - Built with ❤️ - EOF - sed -i "s|v\$VERSION|v$VERSION|g" notes.md - echo "release-notes<> $GITHUB_OUTPUT - cat notes.md >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - - name: Display GitVersion outputs - run: | - echo "Release Version: ${{ steps.gitversion.outputs.majorMinorPatch }}" - echo "Nuget Version: ${{ steps.gitversion.outputs.fullSemVer }}" - - - name: Restore dependencies - run: > - dotnet - restore - ${{ env.PROJECT_PATH }} - - - name: Build - run: > - dotnet build - --configuration Release - --no-restore - ${{ env.PROJECT_PATH }} - /p:Version=${{ steps.gitversion.outputs.fullSemVer }} - /p:ContinuousIntegrationBuild=true - - - name: Install libmsquic for HTTP/3 support - run: | - sudo apt-get update - sudo apt-get install -y libmsquic - - - name: Run tests - working-directory: './src' - run: > - dotnet test - --configuration Release - --no-ansi - --no-build - --coverage - --coverage-output-format cobertura - --results-directory ${{ env.TEST_OUTPUT_DIRECTORY }} - --solution *.slnx - - - name: Create NuGet package - run: > - dotnet pack - --configuration Release - --no-build - --output ${{ env.PACKAGE_OUTPUT_DIRECTORY }} - ${{ env.PROJECT_PATH }} - /p:PackageVersion=${{ steps.gitversion.outputs.fullSemVer }} - /p:PackageReleaseNotes="${{ steps.plain-notes.outputs.release-notes }}" - - - name: Report Code Coverage - if: always() - uses: danielpalme/ReportGenerator-GitHub-Action@5 - with: - reports: '${{ env.TEST_OUTPUT_DIRECTORY }}/*cobertura.xml' - targetdir: '${{ env.COVERAGE_REPORT_DIRECTORY }}' - reporttypes: 'MarkdownSummaryGithub' - tag: '${{ steps.gitversion.outputs.fullSemVer }}' - - - name: Add Coverage Summary to Job Summary - if: always() - run: cat ${{ env.COVERAGE_REPORT_DIRECTORY }}/SummaryGithub.md >> $GITHUB_STEP_SUMMARY - - - name: Upload package artifacts - uses: actions/upload-artifact@v6 - with: - name: nuget-packages - path: ${{ env.PACKAGE_OUTPUT_DIRECTORY }}/*.nupkg - - publish: - permissions: - contents: write - deployments: write - runs-on: ubuntu-latest - needs: build - environment: - name: nuget - url: https://www.nuget.org/packages/TurboHTTP - if: github.ref == 'refs/heads/main' && github.event_name == 'push' - - steps: - - name: Checkout - uses: actions/checkout@v6 - with: - fetch-depth: 1 - - - name: Download package artifacts - uses: actions/download-artifact@v7 - with: - name: nuget-packages - path: ${{ env.PACKAGE_OUTPUT_DIRECTORY }} - - - name: Setup .NET Core - uses: actions/setup-dotnet@v5 - with: - global-json-file: ${{ env.GLOBAL_JSON_PATH }} - cache: true - cache-dependency-path: '**/packages.lock.json' - - - name: Publish to NuGet - run: | - dotnet nuget push --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate ${{ env.PACKAGE_OUTPUT_DIRECTORY }}/*.nupkg - - - name: Generate Release Notes - id: notes - env: - GH_TOKEN: ${{ github.token }} - VERSION: ${{ needs.build.outputs.releaseVersion }} - run: | - cat > notes.md << EOF - 🎯 TurboHTTP v$VERSION - - [![NuGet](https://img.shields.io/nuget/v/TurboHTTP?logo=nuget)](https://nuget.org/packages/TurboHTTP) - [![GitHub](https://img.shields.io/github/last-commit/st0o0/TurboHTTP/main?logo=github)](https://github.com/st0o0/TurboHTTP) - - EOF - - gh api repos/${{ github.repository }}/releases/generate-notes \ - -f tag_name="v\$VERSION" \ - --jq .body >> notes.md || echo "## 📋 Changes\nNo changelog available" >> notes.md - - sed -i "s|v\$VERSION|v$VERSION|g" notes.md - echo "Built with ❤️" >> notes.md - echo "release-notes<> $GITHUB_OUTPUT - cat notes.md >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - - name: Create & Publish Release - uses: softprops/action-gh-release@v3 - with: - tag_name: "v${{ needs.build.outputs.releaseVersion }}" - target_commitish: ${{ github.sha }} - name: "TurboHTTP v${{ needs.build.outputs.releaseVersion }}" - body: ${{ steps.notes.outputs.release-notes }} - draft: false - prerelease: false - make_latest: true - files: ${{ env.PACKAGE_OUTPUT_DIRECTORY }}/*.nupkg diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..6ba3757e8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,74 @@ +name: CI + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +env: + GLOBAL_JSON_PATH: "./src/global.json" + PROJECT_PATH: "./src/TurboHTTP.slnx" + TEST_OUTPUT_DIRECTORY: "${{ github.workspace }}/testresults" + COVERAGE_REPORT_DIRECTORY: "./coveragereport" + +permissions: + contents: read + checks: write + pull-requests: write + +jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Install .NET + uses: actions/setup-dotnet@v5 + with: + global-json-file: ${{ env.GLOBAL_JSON_PATH }} + cache: true + cache-dependency-path: "**/packages.lock.json" + + - name: Restore dependencies + run: dotnet restore ${{ env.PROJECT_PATH }} + + - name: Build + run: > + dotnet build + --configuration Release + --no-restore + ${{ env.PROJECT_PATH }} + + - name: Install libmsquic + run: | + sudo apt-get update + sudo apt-get install -y libmsquic + + - name: Run tests + working-directory: "./src" + run: > + dotnet test + --configuration Release + --no-ansi + --no-build + --coverage + --coverage-output-format cobertura + --results-directory ${{ env.TEST_OUTPUT_DIRECTORY }} + --solution *.slnx + + - name: Report Code Coverage + if: always() + uses: danielpalme/ReportGenerator-GitHub-Action@5 + with: + reports: "${{ env.TEST_OUTPUT_DIRECTORY }}/*cobertura.xml" + targetdir: "${{ env.COVERAGE_REPORT_DIRECTORY }}" + reporttypes: "MarkdownSummaryGithub" + + - name: Add Coverage Summary to Job Summary + if: always() + run: cat ${{ env.COVERAGE_REPORT_DIRECTORY }}/SummaryGithub.md >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml new file mode 100644 index 000000000..117dd1d3d --- /dev/null +++ b/.github/workflows/commitlint.yml @@ -0,0 +1,45 @@ +name: Commit Lint + +on: + pull_request: + branches: ["main"] + types: [opened, edited, synchronize] + +permissions: + contents: read + pull-requests: read + +jobs: + lint-pr-title: + runs-on: ubuntu-latest + + steps: + - name: Validate PR title + uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + types: | + feat + fix + perf + docs + chore + refactor + test + ci + build + + lint-commits: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Validate commit messages + uses: wagoid/commitlint-github-action@v6 + with: + configFile: commitlint.config.mjs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..cb79200c9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,86 @@ +name: Release + +on: + push: + branches: ["main"] + +env: + GLOBAL_JSON_PATH: "./src/global.json" + PROJECT_PATH: "./src/TurboHTTP.slnx" + PACKAGE_OUTPUT_DIRECTORY: "./packages" + +permissions: + contents: write + pull-requests: write + +jobs: + release-please: + runs-on: ubuntu-latest + outputs: + release_created: ${{ steps.release.outputs.release_created }} + tag_name: ${{ steps.release.outputs.tag_name }} + version: ${{ steps.release.outputs.version }} + + steps: + - name: Run release-please + id: release + uses: googleapis/release-please-action@v4 + with: + config-file: release-please-config.json + manifest-file: .release-please-manifest.json + + publish: + runs-on: ubuntu-latest + needs: release-please + if: needs.release-please.outputs.release_created == 'true' + environment: + name: nuget + url: https://www.nuget.org/packages/TurboHTTP + + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 1 + + - name: Install .NET + uses: actions/setup-dotnet@v5 + with: + global-json-file: ${{ env.GLOBAL_JSON_PATH }} + cache: true + cache-dependency-path: "**/packages.lock.json" + + - name: Restore dependencies + run: dotnet restore ${{ env.PROJECT_PATH }} + + - name: Build + run: > + dotnet build + --configuration Release + --no-restore + ${{ env.PROJECT_PATH }} + /p:Version=${{ needs.release-please.outputs.version }} + /p:ContinuousIntegrationBuild=true + + - name: Create NuGet package + run: > + dotnet pack + --configuration Release + --no-build + --output ${{ env.PACKAGE_OUTPUT_DIRECTORY }} + ${{ env.PROJECT_PATH }} + /p:PackageVersion=${{ needs.release-please.outputs.version }} + + - name: Publish to NuGet + run: > + dotnet nuget push + --api-key ${{ secrets.NUGET_API_KEY }} + --source https://api.nuget.org/v3/index.json + --skip-duplicate + ${{ env.PACKAGE_OUTPUT_DIRECTORY }}/*.nupkg + + - name: Attach package to GitHub Release + uses: softprops/action-gh-release@v3 + with: + tag_name: ${{ needs.release-please.outputs.tag_name }} + files: ${{ env.PACKAGE_OUTPUT_DIRECTORY }}/*.nupkg diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 000000000..319ef1a06 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + "src/TurboHTTP": "0.1.3" +} diff --git a/commitlint.config.mjs b/commitlint.config.mjs new file mode 100644 index 000000000..2291173ef --- /dev/null +++ b/commitlint.config.mjs @@ -0,0 +1,3 @@ +export default { + extends: ['@commitlint/config-conventional'] +}; diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 000000000..5fe564f4b --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "packages": { + "src/TurboHTTP": { + "release-type": "simple", + "changelog-path": "../../CHANGELOG.md", + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": false, + "include-component-in-tag": false, + "changelog-sections": [ + { "type": "feat", "section": "Features" }, + { "type": "fix", "section": "Bug Fixes" }, + { "type": "perf", "section": "Performance" }, + { "type": "docs", "section": "Documentation" }, + { "type": "chore", "hidden": true }, + { "type": "refactor", "hidden": true }, + { "type": "test", "hidden": true }, + { "type": "ci", "hidden": true }, + { "type": "build", "hidden": true } + ] + } + } +}