ifdef #3
Workflow file for this run
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: Publish release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - v* | |
| jobs: | |
| publish: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up .NET SDK | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 8.0.x | |
| - name: Restore | |
| run: dotnet restore LiteDB.sln | |
| - name: Build | |
| run: dotnet build LiteDB.sln --configuration Release --no-restore | |
| - name: Test | |
| timeout-minutes: 5 | |
| run: dotnet test LiteDB.sln --configuration Release --no-build --verbosity normal --settings tests.runsettings --logger "trx;LogFileName=TestResults.trx" --logger "console;verbosity=detailed" | |
| - name: Pack | |
| run: | | |
| dotnet pack LiteDB/LiteDB.csproj --configuration Release --no-build -o artifacts | |
| - name: Capture package version | |
| id: version | |
| run: | | |
| PACKAGE_PATH=$(ls artifacts/LiteDB.*.nupkg | head -n 1) | |
| PACKAGE_FILENAME=$(basename "$PACKAGE_PATH") | |
| PACKAGE_VERSION=${PACKAGE_FILENAME#LiteDB.} | |
| PACKAGE_VERSION=${PACKAGE_VERSION%.nupkg} | |
| echo "package_version=${PACKAGE_VERSION}" >> "$GITHUB_OUTPUT" | |
| - name: Retrieve secrets from Bitwarden | |
| uses: bitwarden/sm-action@v2 | |
| with: | |
| access_token: ${{ secrets.BW_ACCESS_TOKEN }} | |
| base_url: https://vault.bitwarden.eu | |
| secrets: | | |
| 265b2fb6-2cf0-4859-9bc8-b24c00ab4378 > NUGET_API_KEY | |
| - name: Push package to NuGet | |
| run: | | |
| dotnet nuget push "artifacts/*.nupkg" --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| - name: Publish GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.version.outputs.package_version }} | |
| name: LiteDB ${{ steps.version.outputs.package_version }} | |
| generate_release_notes: true | |
| files: artifacts/*.nupkg | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |