Skip to content

Commit

Permalink
chore!: auto-update version via tag in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
wolffshots committed Apr 9, 2024
1 parent 43fa6c5 commit adcc99f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,19 @@ jobs:
go-version: 1.21.9

- name: Build for linux/arm
run: env GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-s -w" -o ./phocus -v main.go
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
TAG_NAME="${GITHUB_REF#refs/tags/}"
echo "Current tag is $TAG_NAME"
env GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-X 'main.version=$TAG_NAME' -s -w" -o ./phocus -v main.go
else
echo "Not on a tag. The commit SHA is $GITHUB_SHA"
env GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-X 'main.version=$GITHUB_SHA' -s -w" -o ./phocus -v main.go
fi
env:
GITHUB_REF: ${{ github.ref }}
GITHUB_SHA: ${{ github.sha }}

test:
runs-on: ubuntu-latest
needs: [build]
Expand Down
1 change: 1 addition & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var upgrader = websocket.Upgrader{
}

// AddQPGSnMessages is the meat of the QueueQPGSn functionality
// TODO refactor to take a number in for how many inverters
func AddQPGSnMessages(timeBetween time.Duration) error {
QueueMutex.Lock()
if len(Queue) < 2 {
Expand Down
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
serial "github.com/wolffshots/phocus/v2/serial" // comms with inverter
)

const version = "v2.11.1"
var version = "development"

type Configuration struct {
Serial struct {
Expand Down Expand Up @@ -72,9 +72,12 @@ func Router(client mqtt.Client, profiling bool) error {
func main() {
log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds | log.Llongfile)
log.Println("Starting up phocus")
log.Printf("Phocus Version: %s\n\n", version)

configuration, err := ParseConfig("config.json")

// TODO log some other useful info here

// just give a chance to see the http server coming up
time.Sleep(3 * time.Second)

Expand Down
1 change: 1 addition & 0 deletions sensors/sensors.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Sensor struct {
Icon string // "icon": "mdi:battery",
}

// TODO refactor to take a number in for how many inverters
var sensors = []Sensor{
{
SensorTopic: "homeassistant/sensor/phocus/version/config",
Expand Down

0 comments on commit adcc99f

Please sign in to comment.