refactor: 모던 C# 관례 적용 및 테스트 보강 #9
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, Test, and Publish NuGet Package | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write # Trusted Publishing용 GitHub OIDC 토큰 발급 허용 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --configuration Release --no-restore | |
| - name: Test | |
| run: dotnet test --configuration Release --no-build --verbosity normal | |
| - name: Pack | |
| run: dotnet pack --configuration Release --no-build --output ./nupkg | |
| # Trusted Publishing: OIDC 토큰을 1시간짜리 임시 API 키로 교환 | |
| # (nuget.org -> 계정 -> Trusted Publishing 정책 등록 필요) | |
| - name: NuGet login (OIDC -> temp API key) | |
| if: github.ref == 'refs/heads/main' | |
| uses: NuGet/login@v1 | |
| id: login | |
| with: | |
| user: JaejoonHan # nuget.org 프로필명 | |
| - name: Publish to NuGet | |
| if: github.ref == 'refs/heads/main' # main 브랜치에서만 배포 | |
| run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate |