Skip to content

Add windows ci matrix (#2718) #32

Add windows ci matrix (#2718)

Add windows ci matrix (#2718) #32

name: Publish prerelease
on:
push:
branches:
- dev
paths:
- 'LiteDB/**'
- '.github/workflows/**'
# allow workflow_dispatch to trigger manually from GitHub UI
workflow_dispatch:
inputs:
ref:
description: Branch, tag, or SHA to release from
default: dev
required: true
jobs:
ci-checks:
uses: ./.github/workflows/_reusable-ci.yml
secrets: inherit
publish:
name: Pack & Publish
runs-on: ubuntu-latest
needs: ci-checks
permissions:
contents: write
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up .NET SDKs (8/9/10)
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
10.0.x
9.0.x
8.0.x
include-prerelease: true
- name: Restore .NET tools
run: dotnet tool restore
- name: Compute semantic version
id: gitversion
shell: bash
run: |
set -euo pipefail
JSON=$(dotnet tool run dotnet-gitversion /output json)
echo "$JSON"
NUGET_VERSION=$(echo "$JSON" | jq -r '.NuGetVersion')
FULL_SEMVER=$(echo "$JSON" | jq -r '.FullSemVer')
SHORT_SHA=$(echo "$JSON" | jq -r '.ShortSha')
MAJOR_MINOR_PATCH=$(echo "$JSON" | jq -r '.MajorMinorPatch')
PR_LABEL=$(echo "$JSON" | jq -r '.PreReleaseLabel')
PR_NUMBER=$(echo "$JSON" | jq -r '.PreReleaseNumber')
if [[ "$PR_LABEL" != "" && "$PR_LABEL" != "null" ]]; then
printf -v PR_PADDED '%04d' "$PR_NUMBER"
RELEASE_VERSION_PADDED="${MAJOR_MINOR_PATCH}-${PR_LABEL}.${PR_PADDED}"
else
RELEASE_VERSION_PADDED="$MAJOR_MINOR_PATCH"
fi
echo "nugetVersion=$NUGET_VERSION" >> "$GITHUB_OUTPUT"
echo "fullSemVer=$FULL_SEMVER" >> "$GITHUB_OUTPUT"
echo "releaseVersionPadded=$RELEASE_VERSION_PADDED" >> "$GITHUB_OUTPUT"
echo "informational=${NUGET_VERSION}+${SHORT_SHA}" >> "$GITHUB_OUTPUT"
- name: Restore
run: dotnet restore LiteDB.sln
- name: Build
run: dotnet build LiteDB/LiteDB.csproj --configuration Release --no-restore /p:ContinuousIntegrationBuild=true
- name: Pack
run: dotnet pack LiteDB/LiteDB.csproj --configuration Release --no-build -o artifacts /p:ContinuousIntegrationBuild=true
- name: Clean up detached packages
run: |
find artifacts -name "0.0.0-detached.nupkg" -delete
- 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
env:
PACKAGE_VERSION: ${{ steps.gitversion.outputs.nugetVersion }}
run: |
echo "Pushing LiteDB version $PACKAGE_VERSION"
dotnet nuget push "artifacts/*.nupkg" --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json --skip-duplicate