diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index df7f6ad2..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,34 +0,0 @@ -# release: on a version tag (e.g. v1.0.1), build the linux/amd64 tarball that -# cloud66/central installs from S3 and attach it to a GitHub Release. -name: release - -on: - push: - tags: [ 'v*' ] - -jobs: - release: - runs-on: ubuntu-latest - permissions: - contents: write # required to create the GitHub Release - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: 'stable' - # produces builds/gotty_linux_amd64_.tar.gz (executable only) - - name: build linux/amd64 tarball - run: make dist - - name: attach tarball to GitHub Release - uses: softprops/action-gh-release@v2 - with: - files: builds/gotty_linux_amd64_*.tar.gz - # optional: publish to the bucket central's installer downloads from. - # only runs when AWS credentials are configured as repo secrets. - - name: upload to downloads.cloud66.com (optional) - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: us-east-1 - if: env.AWS_ACCESS_KEY_ID != '' - run: aws s3 cp builds/gotty_linux_amd64_*.tar.gz s3://downloads.cloud66.com/gotty/ diff --git a/.name b/.name new file mode 100644 index 00000000..ac820ce7 --- /dev/null +++ b/.name @@ -0,0 +1 @@ +gotty diff --git a/Makefile b/Makefile index 9fa741cd..57ab02ee 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,16 @@ -# gotty build — modern Go modules flow (replaces the old godep / go-bindata setup). -# web assets are pre-generated and committed in app/resource.go (Code generated, DO NOT EDIT), -# so they are not rebuilt here: the libapps submodule and go-bindata are no longer required. +# gotty build. +# Local builds use the stock Go toolchain (`make` / `go build`). Release builds and +# publishing to S3 are handled by GoBob (cloud66's centralized build/publish tool) via +# the `gobob` target below. Web assets are pre-generated and committed in app/resource.go +# (Code generated, DO NOT EDIT), so go-bindata and the old libapps submodule aren't needed. -# single source of truth for the version is the Version var in app/app.go -VERSION := $(shell grep -oE 'Version = "[0-9][^"]*"' app/app.go | head -1 | sed -E 's/.*"([^"]+)".*/\1/') -# cloud66/central's installer fetches the tarball with dots replaced by underscores -VERSION_US := $(subst .,_,$(VERSION)) - -OUTPUT_DIR := ./builds # hand-written Go files only — exclude vendored deps and the generated bindata file GOFILES := $(shell find . -name '*.go' -not -path './vendor/*' -not -name 'resource.go') +# version is the single source of truth in app/app.go; GoBob stamps it into the binary +VERSION := $(shell grep -oE 'Version = "[0-9][^"]*"' app/app.go | head -1 | sed -E 's/.*"([^"]+)".*/\1/') +BRANCH := $(shell git rev-parse --abbrev-ref HEAD) +# gotty needs a pty, so it is unix-only: exclude GoBob's default windows/* targets +GOBOB_TARGETS := darwin/arm64,darwin/amd64,linux/386,linux/amd64,linux/arm,linux/arm64 # default target: build a local binary for the host platform gotty: $(GOFILES) go.mod @@ -26,17 +27,14 @@ test: fmt: gofmt -w $(GOFILES) -# build the linux/amd64 release artifact that central installs from S3. -# CGO is disabled so the binary is static and runs across all supported Ubuntu releases. -# output: builds/gotty_linux_amd64_.tar.gz containing only the gotty executable. -dist: - mkdir -p $(OUTPUT_DIR) - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(OUTPUT_DIR)/gotty . - tar -czf $(OUTPUT_DIR)/gotty_linux_amd64_$(VERSION_US).tar.gz -C $(OUTPUT_DIR) gotty - @echo "built $(OUTPUT_DIR)/gotty_linux_amd64_$(VERSION_US).tar.gz (version $(VERSION))" +# cross-compile every supported release target via GoBob (build only — no S3 upload). +# GoBob builds from committed state, so this needs a clean, pushed branch. To publish: +# gobob build+push -t '$(GOBOB_TARGETS)' -v $(VERSION) -b $(BRANCH) +# gobob publish -v $(VERSION) +gobob: + gobob build -t '$(GOBOB_TARGETS)' -v $(VERSION) -b $(BRANCH) clean: rm -f gotty - rm -rf $(OUTPUT_DIR) -.PHONY: test fmt dist clean +.PHONY: test fmt gobob clean diff --git a/main.go b/main.go index 1fe4a82d..a08cb9c1 100644 --- a/main.go +++ b/main.go @@ -11,9 +11,25 @@ import ( "github.com/cloud66/gotty/app" ) +// injected at build time by GoBob via -ldflags "-X main.VERSION=... -X main.BUILDDATE=...". +// empty for a plain `go build`/`go install`, where the version baked into app.Version is used. +var ( + VERSION string + BUILDDATE string +) + func main() { + // when built through GoBob, prefer the injected version over the hard-coded default + if VERSION != "" { + app.Version = VERSION + } + cmd := cli.NewApp() cmd.Version = app.Version + // released binaries also carry the build date so `gotty --version` is traceable + if BUILDDATE != "" { + cmd.Version = app.Version + " (" + BUILDDATE + ")" + } cmd.Name = "gotty" cmd.Usage = "Share your terminal as a web application" cmd.HideHelp = true