feat: automatic version.txt updates

Resolves #387
This commit is contained in:
Steven Tang 2022-07-09 13:58:16 +10:00
parent d5a85639b1
commit 20993a1182
No known key found for this signature in database
GPG Key ID: C7B961512342C50E
6 changed files with 29 additions and 5 deletions

View File

@ -11,6 +11,15 @@ jobs:
name: 'Build and publish Docker image' name: 'Build and publish Docker image'
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: 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 - name: Set up QEMU
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v1
@ -47,6 +56,7 @@ jobs:
- name: Build and push - name: Build and push
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: .
file: Dockerfile file: Dockerfile
push: true push: true
platforms: linux/amd64,linux/arm64,linux/arm/v7 platforms: linux/amd64,linux/arm64,linux/arm/v7

View File

@ -33,6 +33,13 @@ jobs:
- name: Check out code into the Go module directory - name: Check out code into the Go module directory
uses: actions/checkout@v2 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 - name: Get dependencies
run: go get run: go get

View File

@ -4,10 +4,10 @@ import (
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
uuid "github.com/satori/go.uuid"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"os" "os"
"regexp"
"strings" "strings"
"time" "time"
@ -16,6 +16,7 @@ import (
"github.com/jinzhu/configor" "github.com/jinzhu/configor"
"github.com/muety/wakapi/data" "github.com/muety/wakapi/data"
"github.com/muety/wakapi/models" "github.com/muety/wakapi/models"
uuid "github.com/satori/go.uuid"
"gorm.io/gorm" "gorm.io/gorm"
) )
@ -363,7 +364,13 @@ func Load(version string) *Config {
} }
env = config.Env env = config.Env
config.Version = strings.TrimSpace(version) 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.InstanceId = uuid.NewV4().String()
config.App.Colors = readColors() config.App.Colors = readColors()
config.Db.Dialect = resolveDbDialect(config.Db.Type) config.Db.Dialect = resolveDbDialect(config.Db.Type)

View File

@ -2,15 +2,15 @@ package routes
import ( import (
"fmt" "fmt"
"github.com/duke-git/lancet/v2/datetime"
"github.com/muety/wakapi/views"
"html/template" "html/template"
"net/http" "net/http"
"strings" "strings"
"github.com/duke-git/lancet/v2/datetime"
"github.com/muety/wakapi/config" "github.com/muety/wakapi/config"
"github.com/muety/wakapi/models" "github.com/muety/wakapi/models"
"github.com/muety/wakapi/utils" "github.com/muety/wakapi/utils"
"github.com/muety/wakapi/views"
) )
type action func(w http.ResponseWriter, r *http.Request) (int, string, string) type action func(w http.ResponseWriter, r *http.Request) (int, string, string)

View File

@ -1 +1 @@
2.3.5 dev

View File

@ -1,6 +1,6 @@
<footer class="flex justify-between w-full text-center text-gray-500 text-xs mt-20"> <footer class="flex justify-between w-full text-center text-gray-500 text-xs mt-20">
<div class="text-xs font-mono font-semibold"> <div class="text-xs font-mono font-semibold">
v{{ getVersion }} @ {{ getDbType }} {{ getVersion }} @ {{ getDbType }}
</div> </div>
<div class="font-semibold text-sm hidden sm:inline-block"> <div class="font-semibold text-sm hidden sm:inline-block">
Made with &nbsp; <span class="iconify inline" data-icon="bi:heart-fill"></span> &nbsp; by <a href="https://muetsch.io" class="text-gray-400 hover:text-gray-300">Ferdinand Mütsch</a> as <a Made with &nbsp; <span class="iconify inline" data-icon="bi:heart-fill"></span> &nbsp; by <a href="https://muetsch.io" class="text-gray-400 hover:text-gray-300">Ferdinand Mütsch</a> as <a