From c4d231fbb1cb5026b1e1c75f2751b96f3f2b16b3 Mon Sep 17 00:00:00 2001 From: ikpil Date: Tue, 3 Oct 2023 15:42:01 +0900 Subject: [PATCH] feat: ready nuget publish --- .github/workflows/dotnet.yml | 3 ++ .github/workflows/publish.yml | 55 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 2 ++ 3 files changed, 60 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index bc7c7ac..e1bbbc0 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -23,6 +23,9 @@ jobs: steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Get all history to allow automatic versioning using MinVer + - name: Setup .NET uses: actions/setup-dotnet@v3 with: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..905dc07 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,55 @@ +name: Nuget Publish + +on: + workflow_dispatch: + inputs: + version: + description: version + required: true + type: string + +jobs: + publish-to-nuget: + runs-on: ubuntu-latest + steps: + - name: version pattern + id: check-version + run: | + version="${{ github.event.inputs.version }}" + if [[ $version =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then + echo "Input matches pattern: $version" + else + echo "Input does not match pattern: $version" + exit 1 + fi + + - name: version check + if: success() + run: echo ok + + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 # Get all history to allow automatic versioning using MinVer + + - name: Setup Dotnet + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '7.x' + + - name: restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build -c Release --no-restore + + - name: Test + run: dotnet test -c Release --no-build --verbosity normal + + - name: Pack + run: dotnet pack -p:PackageVersion=${{ github.event.inputs.version }} -c Release --nologo --output working-nuget + + - name: Publish the package to nuget.org + run: dotnet nuget push ./working-nuget/*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json + env: + NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 57b1153..f474aa3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,6 +11,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 # Get all history to allow automatic versioning using MinVer - name: Setup Dotnet uses: actions/setup-dotnet@v3