feat: version
Some checks failed
ci-build / lint (push) Has been cancelled
ci-build / build (push) Has been cancelled
ci-build / release (push) Has been cancelled

This commit is contained in:
Rob Watson 2025-03-25 04:58:35 +01:00
parent fe600ddcb8
commit f6b893d89c
6 changed files with 92 additions and 6 deletions

View File

@ -1,15 +1,19 @@
name: ci-build name: ci-build
run-name: Building ${{ github.ref_name }} run-name: Building ${{ github.ref_name }}
on: on:
- push push:
- pull_request branches:
- "**"
tags:
- "v[0-9]+*"
pull_request:
jobs: jobs:
lint: lint:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: ludeeus/action-shellcheck@2.0.0 - uses: ludeeus/action-shellcheck@2.0.0
backend: build:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
needs: needs:
- lint - lint
@ -50,3 +54,30 @@ jobs:
env: env:
DOCKER_API_VERSION: "1.45" DOCKER_API_VERSION: "1.45"
run: mise run test_integration_ci run: mise run test_integration_ci
release:
needs:
- lint
- build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- name: checkout
uses: actions/checkout@v4
- name: Setup Go 1.24.1
uses: actions/setup-go@v5
with:
go-version: '1.24.1'
- name: install OS dependencies
run: |
sudo apt-get -y update && \
sudo apt-get -y --no-install-recommends install \
libx11-dev
- name: release
uses: goreleaser/goreleaser-action@v5
with:
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
*.log *.log
/mediamtx.yml /mediamtx.yml
dist/

34
.goreleaser.yaml Normal file
View File

@ -0,0 +1,34 @@
version: 2
before:
hooks:
- go mod tidy
- go generate ./...
builds:
- env:
# - CGO_ENABLED=0
goos:
- linux
# - windows
- darwin
archives:
- formats: [tar.gz]
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
format_overrides:
- goos: windows
formats: [zip]
changelog:
sort: asc
filters:
exclude:
- "^doc:"
- "^test:"

View File

@ -25,6 +25,8 @@ func (s *AppState) Clone() AppState {
type BuildInfo struct { type BuildInfo struct {
GoVersion string GoVersion string
Version string Version string
Commit string
Date string
} }
// Source represents the source, currently always the mediaserver. // Source represents the source, currently always the mediaserver.

View File

@ -737,12 +737,19 @@ func (ui *UI) confirmQuit() {
} }
func (ui *UI) showAbout() { func (ui *UI) showAbout() {
commit := ui.buildInfo.Commit
if len(commit) > 8 {
commit = commit[:8]
}
ui.showModal( ui.showModal(
modalGroupAbout, modalGroupAbout,
fmt.Sprintf( fmt.Sprintf(
"%s: live stream multiplexer\n\nv0.0.0 %s (%s)", "%s: live stream multiplexer\n(c) Rob Watson\nhttps://git.netflux.io/rob/octoplex\n\nReleased under AGPL3.\n\nv%s (%s)\nBuilt on %s (%s).",
domain.AppName, domain.AppName,
ui.buildInfo.Version, cmp.Or(ui.buildInfo.Version, "0.0.0-devel"),
cmp.Or(commit, "unknown SHA"),
cmp.Or(ui.buildInfo.Date, "unknown date"),
ui.buildInfo.GoVersion, ui.buildInfo.GoVersion,
), ),
[]string{"Ok"}, []string{"Ok"},

13
main.go
View File

@ -17,6 +17,15 @@ import (
"golang.design/x/clipboard" "golang.design/x/clipboard"
) )
var (
// version is the version of the application.
version string
// commit is the commit hash of the application.
commit string
// date is the date of the build.
date string
)
func main() { func main() {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
@ -86,7 +95,9 @@ func run(ctx context.Context) error {
ConfigFilePath: configService.Path(), ConfigFilePath: configService.Path(),
BuildInfo: domain.BuildInfo{ BuildInfo: domain.BuildInfo{
GoVersion: buildInfo.GoVersion, GoVersion: buildInfo.GoVersion,
Version: buildInfo.Main.Version, Version: version,
Commit: commit,
Date: date,
}, },
Logger: logger, Logger: logger,
}, },