github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/.github/workflows/publish.yml (about)

     1  name: publish
     2  on:
     3    workflow_dispatch:
     4      inputs:
     5        version-change:
     6          description: Version part
     7          required: true
     8          type: choice
     9          options:
    10            - PATCH
    11            - MINOR
    12        release-candidate:
    13          description: Release candidate
    14          required: true
    15          type: boolean
    16          default: True
    17  
    18  permissions:
    19    contents: write
    20  
    21  jobs:
    22    publish:
    23      runs-on: ubuntu-latest
    24      env:
    25        VERSION_CHANGE: ${{ github.event.inputs.version-change }}
    26        RELEASE_CANDIDATE: ${{ github.event.inputs.release-candidate }}
    27        VERSION_FILE: internal/version/version.go
    28        CHANGELOG_FILE: CHANGELOG.md
    29        GITHUB_TOKEN: ${{ secrets.YDB_PLATFORM_BOT_TOKEN_REPO }}
    30      steps:
    31        - uses: actions/checkout@v3
    32          with:
    33            token: ${{ secrets.YDB_PLATFORM_BOT_TOKEN_REPO }}
    34            fetch-depth: 0
    35        - run: |
    36            CHANGELOG=$(cat $CHANGELOG_FILE | sed -e '/^## v.*$/,$d')
    37            if [[ -z "$CHANGELOG" ]]
    38            then
    39              echo "CHANGELOG empty"
    40              exit 1;
    41            fi;
    42            MAJOR=$(cat $VERSION_FILE | grep Major | sed -e 's/^.*\ \(=\ \)*\(\"\)*\([0-9]*\)\(\"\)*.*/\3/g');
    43            MINOR=$(cat $VERSION_FILE | grep Minor | sed -e 's/^.*\ \(=\ \)*\(\"\)*\([0-9]*\)\(\"\)*.*/\3/g');
    44            PATCH=$(cat $VERSION_FILE | grep Patch | sed -e 's/^.*\ \(=\ \)*\(\"\)*\([0-9]*\)\(\"\)*.*/\3/g');
    45            LAST_TAG="v$MAJOR.$MINOR.$PATCH";
    46            if [ "$VERSION_CHANGE" = "MINOR" ]
    47            then
    48              MINOR=$((MINOR+1));
    49              PATCH=0;
    50            fi;
    51            if [ "$VERSION_CHANGE" = "PATCH" ]
    52            then
    53              PATCH=$((PATCH+1));
    54            fi;
    55            if [ "$RELEASE_CANDIDATE" = true ]
    56            then
    57              RC=$(git tag | grep "v$MAJOR.$MINOR.$PATCH-rc" | wc -l);
    58              TAG="v$MAJOR.$MINOR.$PATCH-rc$RC";
    59            else
    60              sed -e 's/Minor = "\([0-9]*\)"/Minor = "'$MINOR'"/g' -i $VERSION_FILE;
    61              sed -e 's/Patch = "\([0-9]*\)"/Patch = "'$PATCH'"/g' -i $VERSION_FILE;
    62              git add $VERSION_FILE;
    63              echo "## v$MAJOR.$MINOR.$PATCH" >> $CHANGELOG_FILE.tmp
    64              cat $CHANGELOG_FILE >> $CHANGELOG_FILE.tmp
    65              mv $CHANGELOG_FILE.tmp $CHANGELOG_FILE;
    66              git add $CHANGELOG_FILE;
    67              git config --global user.email "robot@umbrella";
    68              git config --global user.name "robot";
    69              git commit -m "Release v$MAJOR.$MINOR.$PATCH";
    70              TAG="v$MAJOR.$MINOR.$PATCH";
    71            fi;
    72            git tag $TAG
    73            git push && git push --tags
    74            CHANGELOG="$CHANGELOG
    75            
    76            Full Changelog: [$LAST_TAG...$TAG](https://github.com/ydb-platform/ydb-go-sdk/compare/$LAST_TAG...$TAG)"
    77            if [ "$RELEASE_CANDIDATE" = true ]
    78            then
    79              gh release create -d $TAG -t "$TAG" --notes "$CHANGELOG"
    80            else
    81              gh release create $TAG -t "$TAG" --notes "$CHANGELOG"
    82            fi;
    83