Get version for build-universal from the build-helper output, use package.json for all versioning (#321)

* store version for build in txt file

* get version from version.txt

* remove quotes

* Use version.js for Go version too

* test

* test

* simplify things more

* rename zips to consistent waveterm name

* remove newline

* always use v

* always use Wave rather than waveterm
This commit is contained in:
Evan Simkowitz 2024-02-23 17:44:00 -08:00 committed by GitHub
parent 7e21b80af0
commit f85067998f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 26 additions and 12 deletions

View File

@ -5,6 +5,8 @@ env:
NODE_VERSION: "21.5.0"
jobs:
runbuild:
outputs:
WAVETERM_VERSION: ${{ steps.set-version.outputs.WAVETERM_VERSION }}
strategy:
matrix:
include:
@ -43,9 +45,10 @@ jobs:
with:
node-version: ${{env.NODE_VERSION}}
cache: "yarn"
- run: |
- id: set-version
run: |
VERSION=$(node -e 'console.log(require("./version.js"))')
echo "WAVETERM_VERSION=${VERSION:1}" >> $GITHUB_ENV
echo "WAVETERM_VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
- run: yarn --frozen-lockfile
- run: ./scripthaus/scripthaus run ${{ matrix.scripthaus }}
- uses: actions/upload-artifact@v4
@ -62,6 +65,8 @@ jobs:
with:
merge-multiple: true
path: buildtemp
- run: |
echo "${{ needs.runbuild.outputs.WAVETERM_VERSION }}" > buildtemp/version.txt
- run: (cd buildtemp; zip ../waveterm-builds.zip *)
- run: aws s3 cp waveterm-builds.zip s3://waveterm-github-artifacts/
env:

View File

@ -67,8 +67,8 @@ node $SCRIPT_DIR/osx-sign.js
DEBUG=electron-notarize node $SCRIPT_DIR/osx-notarize.js
echo "universal app creation success (build/sign/notarize)"
UVERSION=$(node -e "console.log(require('${SCRIPT_DIR}/../version.js'))")
UPACKAGE_NAME="waveterm-macos-universal-${UVERSION}"
UVERSION=$(cat $BUILDS_DIR/version.txt)
UPACKAGE_NAME="Wave-macos-universal-${UVERSION}"
echo "creating universal zip"
ditto $TEMP_WAVE_DIR_UNIVERSAL $ZIP_DIR/Wave.app

View File

@ -2,7 +2,7 @@
"name": "waveterm",
"author": "Command Line Inc",
"productName": "Wave",
"version": "0.6.1",
"version": "v0.6.1",
"main": "dist/emain.js",
"license": "Apache-2.0",
"dependencies": {
@ -90,4 +90,4 @@
"webpack-merge": "^5.8.0"
},
"scripts": {}
}
}

View File

@ -43,12 +43,13 @@ rm -rf dist/
rm -rf bin/
rm -rf build/
node_modules/.bin/webpack --env prod
WAVESRV_VERSION=$(node -e 'console.log(require("./version.js"))')
GO_LDFLAGS="-s -w -X main.BuildTime=$(date +'%Y%m%d%H%M')"
(cd waveshell; CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.4-darwin.amd64 main-waveshell.go)
(cd waveshell; CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.4-darwin.arm64 main-waveshell.go)
(cd waveshell; CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.4-linux.amd64 main-waveshell.go)
(cd waveshell; CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.4-linux.arm64 main-waveshell.go)
(cd wavesrv; CGO_ENABLED=1 go build -tags "osusergo,netgo,sqlite_omit_load_extension" -ldflags "-X main.BuildTime=$(date +'%Y%m%d%H%M')" -o ../bin/wavesrv ./cmd)
(cd wavesrv; CGO_ENABLED=1 go build -tags "osusergo,netgo,sqlite_omit_load_extension" -ldflags "-X main.BuildTime=$(date +'%Y%m%d%H%M') -X main.WaveVersion=$WAVESRV_VERSION" -o ../bin/wavesrv ./cmd)
node_modules/.bin/electron-forge make
```
@ -59,13 +60,14 @@ rm -rf dist/
rm -rf bin/
rm -rf build/
node_modules/.bin/webpack --env prod
WAVESRV_VERSION=$(node -e 'console.log(require("./version.js"))')
GO_LDFLAGS="-s -w -X main.BuildTime=$(date +'%Y%m%d%H%M')"
(cd waveshell; CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.4-darwin.amd64 main-waveshell.go)
(cd waveshell; CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.4-darwin.arm64 main-waveshell.go)
(cd waveshell; CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.4-linux.amd64 main-waveshell.go)
(cd waveshell; CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.4-linux.arm64 main-waveshell.go)
# adds -extldflags=-static, *only* on linux (macos does not support fully static binaries) to avoid a glibc dependency
(cd wavesrv; CGO_ENABLED=1 go build -tags "osusergo,netgo,sqlite_omit_load_extension" -ldflags "-linkmode 'external' -extldflags=-static $GO_LDFLAGS" -o ../bin/wavesrv ./cmd)
(cd wavesrv; CGO_ENABLED=1 go build -tags "osusergo,netgo,sqlite_omit_load_extension" -ldflags "-linkmode 'external' -extldflags=-static $GO_LDFLAGS -X main.WaveVersion=$WAVESRV_VERSION" -o ../bin/wavesrv ./cmd)
node_modules/.bin/electron-forge make
```
@ -77,8 +79,9 @@ open out/Wave-darwin-x64/Wave.app
```bash
# @scripthaus command build-wavesrv
WAVESRV_VERSION=$(node -e 'console.log(require("./version.js"))')
cd wavesrv
CGO_ENABLED=1 go build -tags "osusergo,netgo,sqlite_omit_load_extension" -ldflags "-X main.BuildTime=$(date +'%Y%m%d%H%M')" -o ../bin/wavesrv ./cmd
CGO_ENABLED=1 go build -tags "osusergo,netgo,sqlite_omit_load_extension" -ldflags "-X main.BuildTime=$(date +'%Y%m%d%H%M') -X main.WaveVersion=$WAVESRV_VERSION" -o ../bin/wavesrv ./cmd
```
```bash

View File

@ -1,5 +1,5 @@
const path = require("path");
const packageJson = require(path.resolve(__dirname, "package.json"));
const VERSION = `v${packageJson.version}`;
const VERSION = `${packageJson.version}`;
module.exports = VERSION;

View File

@ -66,10 +66,13 @@ const TelemetryInterval = 8 * time.Hour
const MaxWriteFileMemSize = 20 * (1024 * 1024) // 20M
// these are set at build time
var WaveVersion = "v0.0.0"
var BuildTime = "0"
var GlobalLock = &sync.Mutex{}
var WSStateMap = make(map[string]*scws.WSState) // clientid -> WsState
var GlobalAuthKey string
var BuildTime = "0"
var shutdownOnce sync.Once
var ContentTypeHeaderValidRe = regexp.MustCompile(`^\w+/[\w.+-]+$`)
@ -804,6 +807,7 @@ func doShutdown(reason string) {
func main() {
scbase.BuildTime = BuildTime
scbase.WaveVersion = WaveVersion
base.ProcessType = base.ProcessType_WaveSrv
wlog.GlobalSubsystem = base.ProcessType_WaveSrv
wlog.LogConsumer = wlog.LogWithLogger

View File

@ -35,14 +35,16 @@ const WaveLockFile = "waveterm.lock"
const WaveDirName = ".waveterm" // must match emain.ts
const WaveDevDirName = ".waveterm-dev" // must match emain.ts
const WaveAppPathVarName = "WAVETERM_APP_PATH"
const WaveVersion = "v0.6.1"
const WaveAuthKeyFileName = "waveterm.authkey"
const MShellVersion = "v0.4.0"
var SessionDirCache = make(map[string]string)
var ScreenDirCache = make(map[string]string)
var BaseLock = &sync.Mutex{}
// these are set by the main-server using build-time variables
var BuildTime = "-"
var WaveVersion = "-"
func IsDevMode() bool {
pdev := os.Getenv(WaveDevVarName)