Files
git.stella-ops.org/Mongo2Go-4.1.0/.github/workflows/continuous-integration.yml

76 lines
2.8 KiB
YAML

name: Continuous Integration
on:
push:
branches:
- '**' # Trigger on all branches for commits
tags:
- 'v*' # Trigger only on version tags for deployments
env:
Configuration: Release
ContinuousIntegrationBuild: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
jobs:
build:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
name: Build and Test
steps:
- name: Install libssl1.1 (restores libcrypto.so.1.1 which is required by MongoDB binaries v4.4.4)
if: runner.os == 'Linux'
run: |
echo "deb http://security.ubuntu.com/ubuntu focal-security main" | sudo tee /etc/apt/sources.list.d/focal-security.list
sudo apt update
sudo apt install -y libssl1.1
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Retrieve cached NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
- name: Restore NuGet packages
run: dotnet restore --locked-mode --verbosity normal
- name: Build solution
run: dotnet build --configuration ${{ env.Configuration }} --verbosity normal
- name: Run tests
run: dotnet test --configuration ${{ env.Configuration }} --no-build --verbosity normal
publish:
runs-on: macos-latest
needs: build
if: startsWith(github.ref, 'refs/tags/')
name: Deploy NuGet and GitHub Release
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Restore NuGet packages
run: dotnet restore --locked-mode --verbosity normal
- name: Build solution
run: dotnet build --configuration ${{ env.Configuration }} --verbosity normal
- name: Create NuGet package
run: dotnet pack --output ./artifacts --configuration ${{ env.Configuration }} --verbosity normal
- name: Upload NuGet package artifact
uses: actions/upload-artifact@v4
with:
name: mongo2go-nuget-package
path: ./artifacts/*.nupkg
- name: Publish NuGet package
run: dotnet nuget push ./artifacts/*.nupkg --source https://api.nuget.org/v3/index.json --api-key "${{ secrets.NUGET_API_KEY }}" --skip-duplicate
- name: Create GitHub Release
run: |
gh release create ${{ github.ref_name }} ./artifacts/*.nupkg \
--title "${{ github.ref_name }}" \
--notes "A new release has been created. Please update the release notes manually with details about changes and improvements." \
--draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}