diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 58b7d8c..5459b5d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -11,6 +11,15 @@ jobs: name: 'Build and publish Docker image' runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set version + run: | + (git describe --tags --exact-match \ + || git symbolic-ref -q --short HEAD \ + || git rev-parse --short HEAD) > version.txt 2> /dev/null + - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -47,6 +56,7 @@ jobs: - name: Build and push uses: docker/build-push-action@v2 with: + context: . file: Dockerfile push: true platforms: linux/amd64,linux/arm64,linux/arm/v7 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3a2a8b3..5c4d65d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,6 +33,13 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v2 + - name: Set version + shell: bash + run: | + (git describe --tags --exact-match \ + || git symbolic-ref -q --short HEAD \ + || git rev-parse --short HEAD) > version.txt 2> /dev/null + - name: Get dependencies run: go get diff --git a/config/config.go b/config/config.go index 572e455..a8a305d 100644 --- a/config/config.go +++ b/config/config.go @@ -4,10 +4,10 @@ import ( "encoding/json" "flag" "fmt" - uuid "github.com/satori/go.uuid" "io/ioutil" "net/http" "os" + "regexp" "strings" "time" @@ -16,6 +16,7 @@ import ( "github.com/jinzhu/configor" "github.com/muety/wakapi/data" "github.com/muety/wakapi/models" + uuid "github.com/satori/go.uuid" "gorm.io/gorm" ) @@ -363,7 +364,13 @@ func Load(version string) *Config { } env = config.Env + config.Version = strings.TrimSpace(version) + tagVersionMatch, _ := regexp.MatchString(`\d+\.\d+\.\d+`, version) + if tagVersionMatch { + config.Version = "v" + config.Version + } + config.InstanceId = uuid.NewV4().String() config.App.Colors = readColors() config.Db.Dialect = resolveDbDialect(config.Db.Type) diff --git a/routes/routes.go b/routes/routes.go index 53ea260..44e9e3d 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -2,15 +2,15 @@ package routes import ( "fmt" - "github.com/duke-git/lancet/v2/datetime" - "github.com/muety/wakapi/views" "html/template" "net/http" "strings" + "github.com/duke-git/lancet/v2/datetime" "github.com/muety/wakapi/config" "github.com/muety/wakapi/models" "github.com/muety/wakapi/utils" + "github.com/muety/wakapi/views" ) type action func(w http.ResponseWriter, r *http.Request) (int, string, string) diff --git a/version.txt b/version.txt index 3b26524..38f8e88 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -2.3.5 \ No newline at end of file +dev diff --git a/views/footer.tpl.html b/views/footer.tpl.html index 9b88827..2e85302 100644 --- a/views/footer.tpl.html +++ b/views/footer.tpl.html @@ -1,6 +1,6 @@