diff --git a/.github/scripts/publish-ef.sh b/.github/scripts/publish-ef.sh new file mode 100644 index 00000000..7ff96047 --- /dev/null +++ b/.github/scripts/publish-ef.sh @@ -0,0 +1,55 @@ +#!/bin/bash +set -euxo pipefail + +CHANGELOG=$(cat $CHANGELOG_FILE | sed -e '/^## v.*$/,$d') +if [[ -z "$CHANGELOG" ]] +then + echo "CHANGELOG empty" + exit 1; +fi; + +LAST_EF_TAG=$(git tag --sort=-creatordate --list 'ef-*' | head -n 1 | cut -d '-' -f 2); +LAST_EF_TAG=${LAST_EF_TAG:-v0.0.0} +MAJOR=$(echo $LAST_EF_TAG | sed -E 's/v([0-9]+)\..*/\1/'); +MINOR=$(echo $LAST_EF_TAG | sed -E 's/v[0-9]+\.([0-9]+)\..*/\1/'); +PATCH=$(echo $LAST_EF_TAG | sed -E 's/v[0-9]+\.[0-9]+\.([0-9]+)($|-rc[0-9]+)/\1/'); +RC=0; + +if [ "$RELEASE_CANDIDATE" = true ] +then + RC=$(git tag | grep "ef-v$MAJOR.$MINOR.$PATCH-rc" | wc -l | xargs || true); +fi +if [ "$VERSION_CHANGE" = "MINOR" ] && [ $RC = 0 ] +then + MINOR=$((MINOR+1)); + PATCH=0; +fi; +if [ "$VERSION_CHANGE" = "PATCH" ] && [ $RC = 0 ] +then + PATCH=$((PATCH+1)); +fi; +if [ "$RELEASE_CANDIDATE" = true ] +then + VERSION="$MAJOR.$MINOR.$PATCH-rc$RC"; +else + VERSION="$MAJOR.$MINOR.$PATCH"; +fi; + +TAG="v$VERSION" +echo -e "## $TAG\n" >> $CHANGELOG_FILE.tmp +cat $CHANGELOG_FILE >> $CHANGELOG_FILE.tmp +mv $CHANGELOG_FILE.tmp $CHANGELOG_FILE; +git add $CHANGELOG_FILE; +git config --global user.email "robot@umbrella"; +git config --global user.name "robot"; +git commit -m "Release EF $TAG"; +git tag "ef-$TAG" +git push --tags && git push +CHANGELOG="$CHANGELOG + +Full Changelog: [$LAST_EF_TAG...$TAG](https://github.com/ydb-platform/ydb-dotnet-sdk/compare/$LAST_EF_TAG...$TAG)" + +cd src/EFCore.Ydb/src +dotnet pack -c Release -o out /p:Version=$VERSION +gh release create $TAG -t "ef-$TAG" --notes "$CHANGELOG" +dotnet nuget push out/EntityFrameworkCore.Ydb.$VERSION.nupkg --skip-duplicate --api-key $NUGET_TOKEN --source https://api.nuget.org/v3/index.json diff --git a/.github/scripts/publish.sh b/.github/scripts/publish.sh index 4547e06e..3e97d4cb 100644 --- a/.github/scripts/publish.sh +++ b/.github/scripts/publish.sh @@ -31,9 +31,6 @@ if [ "$RELEASE_CANDIDATE" = true ] then VERSION="$MAJOR.$MINOR.$PATCH-rc$RC"; else - sed -e "s/Minor = [0-9]*/Minor = $MINOR/g" -i $VERSION_FILE - sed -e "s/Patch = [0-9]*/Patch = $PATCH/g" -i $VERSION_FILE - git add $VERSION_FILE; VERSION="$MAJOR.$MINOR.$PATCH"; fi; TAG="v$VERSION" diff --git a/.github/workflows/publish-ef.yml b/.github/workflows/publish-ef.yml new file mode 100644 index 00000000..06c50ef4 --- /dev/null +++ b/.github/workflows/publish-ef.yml @@ -0,0 +1,46 @@ +name: publish +on: + workflow_dispatch: + inputs: + version-change: + description: Version part + required: true + type: choice + options: + - PATCH + - MINOR + release-candidate: + description: Release candidate + required: true + type: boolean + default: True + +permissions: + contents: write + +jobs: + publish: + runs-on: ubuntu-latest + env: + VERSION_CHANGE: ${{ github.event.inputs.version-change }} + RELEASE_CANDIDATE: ${{ github.event.inputs.release-candidate }} + CHANGELOG_FILE: ./src/EFCore.Ydb/CHANGELOG.md + GITHUB_TOKEN: ${{ secrets.YDB_PLATFORM_BOT_TOKEN_REPO }} + NUGET_TOKEN: ${{ secrets.YDB_PLATFORM_NUGET_TOKEN }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + token: ${{ secrets.YDB_PLATFORM_BOT_TOKEN_REPO }} + fetch-depth: 0 + - name: Setup dotnet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Build + run: | + cd src/EFCore.Ydb/src + dotnet build --configuration Release + - name: Publish + run: bash .github/scripts/publish-ef.sh + diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d0b7dc62..df5302b0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -24,7 +24,6 @@ jobs: env: VERSION_CHANGE: ${{ github.event.inputs.version-change }} RELEASE_CANDIDATE: ${{ github.event.inputs.release-candidate }} - VERSION_FILE: src/Ydb.Sdk/src/Version.cs CHANGELOG_FILE: CHANGELOG.md GITHUB_TOKEN: ${{ secrets.YDB_PLATFORM_BOT_TOKEN_REPO }} NUGET_TOKEN: ${{ secrets.YDB_PLATFORM_NUGET_TOKEN }} diff --git a/examples/src/EF/EF.csproj b/examples/src/EF/EF.csproj index 8686be97..489eb609 100644 --- a/examples/src/EF/EF.csproj +++ b/examples/src/EF/EF.csproj @@ -5,7 +5,7 @@ net8.0 enable enable - EfCore + EF diff --git a/src/Ydb.Sdk/src/Version.cs b/src/Ydb.Sdk/src/Version.cs deleted file mode 100644 index 76eff019..00000000 --- a/src/Ydb.Sdk/src/Version.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Ydb.Sdk; - -public static class Version -{ - public const uint Major = 0; - public const uint Minor = 16; - public const uint Patch = 0; -}