From ed79d8a3ceff24285359095777f4a6e8ddc8257f Mon Sep 17 00:00:00 2001 From: everpcpc Date: Tue, 23 Jul 2024 18:19:28 +0800 Subject: [PATCH] chore(ci): fix release workflow (#132) --- .github/workflows/release.yaml | 33 +++++++++++++++++++++++++++++++++ VERSION | 1 + go.mod | 1 - go.sum | 2 -- restful.go | 11 +++++++---- tests/docker-compose.yml | 3 +-- version.go | 7 ++++++- version_test.go | 16 ++++++++++++++++ 8 files changed, 64 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/release.yaml create mode 100644 VERSION create mode 100644 version_test.go diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..27f831f --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,33 @@ +name: Release + +on: + push: + paths: + - "VERSION" + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: "1.21" + + - name: Build + run: go build -v ./... + + - name: Create Release + env: + GH_TOKEN: ${{ github.token }} + run: | + version="v$(cat VERSION)" + if gh release view ${version} > /dev/null 2>&1; then + echo "Release ${version} already exists. Skipping release creation." + else + echo "Creating release ${version}." + gh release create ${version} --generate-notes + fi diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..bc8443e --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.6.8 \ No newline at end of file diff --git a/go.mod b/go.mod index 0835344..084406d 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( github.com/avast/retry-go v3.0.0+incompatible github.com/google/uuid v1.3.0 github.com/pkg/errors v0.9.1 - github.com/shopspring/decimal v1.3.1 github.com/sirupsen/logrus v1.9.0 github.com/stretchr/testify v1.8.4 github.com/test-go/testify v1.1.4 diff --git a/go.sum b/go.sum index 636861c..266d638 100644 --- a/go.sum +++ b/go.sum @@ -19,8 +19,6 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= -github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/restful.go b/restful.go index d36b588..b22030d 100644 --- a/restful.go +++ b/restful.go @@ -39,11 +39,14 @@ const ( Kill ) +type ContextKey string + const ( - ContextKeyQueryID string = "X-DATABEND-QUERY-ID" - ContextUserAgentID string = "USER-AGENT" - EMPTY_FIELD_AS string = "empty_field_as" - PURGE string = "purge" + ContextKeyQueryID ContextKey = "X-DATABEND-QUERY-ID" + ContextUserAgentID ContextKey = "USER-AGENT" + + EMPTY_FIELD_AS string = "empty_field_as" + PURGE string = "purge" ) type PresignedResponse struct { diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index 732674a..1493207 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -1,4 +1,3 @@ -version: '3' services: minio: image: docker.io/minio/minio @@ -7,7 +6,7 @@ services: volumes: - ./data:/data databend: - image: datafuselabs/databend:v1.2.367-nightly + image: datafuselabs/databend environment: - QUERY_DEFAULT_USER=databend - QUERY_DEFAULT_PASSWORD=databend diff --git a/version.go b/version.go index d05124a..0e3a3cb 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,8 @@ package godatabend -var version = "0.6.6" +import ( + _ "embed" +) + +//go:embed VERSION +var version string diff --git a/version_test.go b/version_test.go new file mode 100644 index 0000000..4487c37 --- /dev/null +++ b/version_test.go @@ -0,0 +1,16 @@ +package godatabend + +import ( + "os" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestVersion(t *testing.T) { + r := require.New(t) + content, err := os.ReadFile("VERSION") + r.NoError(err) + + r.Equal(string(content), version) +}