Skip to content

Commit a499646

Browse files
committed
add github action for publish release tags + split version
1 parent 5c7a9fb commit a499646

File tree

5 files changed

+70
-4
lines changed

5 files changed

+70
-4
lines changed

.github/workflows/publish.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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/meta/version.go
28+
CHANGELOG_FILE: CHANGELOG.md
29+
steps:
30+
- uses: actions/checkout@v3
31+
with:
32+
fetch-depth: 0
33+
- run: |
34+
MAJOR=$(cat $VERSION_FILE | grep VersionMajor | sed -e 's/^.*\ \(=\ \)*\(\"\)*\([0-9]*\)\(\"\)*.*/\3/g');
35+
MINOR=$(cat $VERSION_FILE | grep VersionMinor | sed -e 's/^.*\ \(=\ \)*\(\"\)*\([0-9]*\)\(\"\)*.*/\3/g');
36+
PATCH=$(cat $VERSION_FILE | grep VersionPatch | sed -e 's/^.*\ \(=\ \)*\(\"\)*\([0-9]*\)\(\"\)*.*/\3/g');
37+
if [ "$VERSION_CHANGE" = "MINOR" ]
38+
then
39+
MINOR=$((MINOR+1));
40+
PATCH=0;
41+
fi;
42+
if [ "$VERSION_CHANGE" = "PATCH" ]
43+
then
44+
PATCH=$((PATCH+1));
45+
fi;
46+
if [ "$RELEASE_CANDIDATE" = true ]
47+
then
48+
RC=$(git tag | grep "v$MAJOR.$MINOR.$PATCH-rc" | wc -l);
49+
git tag v$MAJOR.$MINOR.$PATCH-rc$RC;
50+
else
51+
sed -e 's/VersionMinor = "\([0-9]*\)"/VersionMinor = "'$MINOR'"/g' -i $VERSION_FILE;
52+
sed -e 's/VersionPatch = "\([0-9]*\)"/VersionPatch = "'$PATCH'"/g' -i $VERSION_FILE;
53+
git add $VERSION_FILE;
54+
echo "## v$MAJOR.$MINOR.$PATCH" >> $CHANGELOG_FILE.tmp && cat $CHANGELOG_FILE >> $CHANGELOG_FILE.tmp && mv $CHANGELOG_FILE.tmp $CHANGELOG_FILE;
55+
git add $CHANGELOG_FILE;
56+
git config --global user.email "robot@umbrella";
57+
git config --global user.name "robot";
58+
git commit -m "Release v$MAJOR.$MINOR.$PATCH";
59+
git tag v$MAJOR.$MINOR.$PATCH;
60+
fi;
61+
git push
62+
git push --tags
63+

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
## 3.15.0
1+
* Added github action for publish release tags
2+
* Refactored version constant (split to major, minor and patch constants)
23
* Added `table.types.Nullable{*}Value` helpers and `table.types.Nullable()` common helper
34
* Fixed race on check trailer on closing table grpc-stream
45
* Refactored traces (start and done struct names have prefix about trace)

internal/meta/meta.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (m *meta) meta(ctx context.Context) (_ metadata.MD, err error) {
9797
md.Set(HeaderDatabase, m.database)
9898
}
9999
if len(md.Get(HeaderVersion)) == 0 {
100-
md.Set(HeaderVersion, Version)
100+
md.Set(HeaderVersion, "ydb-go-sdk/"+VersionMajor+"."+VersionMinor+"."+VersionPatch)
101101
}
102102
if m.requestsType != "" {
103103
if len(md.Get(HeaderRequestType)) == 0 {

internal/meta/version.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package meta
22

33
const (
4-
Version = "ydb-go-sdk/3.15.0"
4+
VersionMajor = "3"
5+
VersionMinor = "14"
6+
VersionPatch = "4"
57
)

version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ package ydb
33
import "github.com/ydb-platform/ydb-go-sdk/v3/internal/meta"
44

55
// Version alias for except cycle import
6-
const Version = meta.Version
6+
const Version = meta.VersionMajor + "." + meta.VersionMinor + "." + meta.VersionPatch

0 commit comments

Comments
 (0)