waveterm/Taskfile.yml

355 lines
12 KiB
YAML
Raw Permalink Normal View History

# Copyright 2024, Command Line Inc.
# SPDX-License-Identifier: Apache-2.0
version: "3"
vars:
2024-09-19 23:04:47 +02:00
APP_NAME: "Wave"
BIN_DIR: "bin"
VERSION:
sh: node version.cjs
RM: '{{if eq OS "windows"}}cmd --% /c del /S{{else}}rm {{end}}'
2024-08-13 08:37:08 +02:00
RMRF: '{{if eq OS "windows"}}powershell Remove-Item -Force -Recurse{{else}}rm -rf{{end}}'
DATE: '{{if eq OS "windows"}}powershell Get-Date -UFormat{{else}}date{{end}}'
ARTIFACTS_BUCKET: waveterm-github-artifacts/staging-w2
RELEASES_BUCKET: dl.waveterm.dev/releases-w2
WINGET_PACKAGE: CommandLine.Wave
2024-06-12 02:42:10 +02:00
tasks:
electron:dev:
desc: Run the Electron application via the Vite dev server (enables hot reloading).
cmd: yarn dev
deps:
- yarn
- docsite:build:embedded
- build:backend
2024-08-09 03:24:54 +02:00
env:
WCLOUD_ENDPOINT: "https://ot2e112zx5.execute-api.us-west-2.amazonaws.com/dev"
WCLOUD_WS_ENDPOINT: "wss://5lfzlg5crl.execute-api.us-west-2.amazonaws.com/dev/"
electron:start:
desc: Run the Electron application directly.
cmd: yarn start
deps:
- yarn
- docsite:build:embedded
- build:backend
env:
WCLOUD_ENDPOINT: "https://ot2e112zx5.execute-api.us-west-2.amazonaws.com/dev"
WCLOUD_WS_ENDPOINT: "wss://5lfzlg5crl.execute-api.us-west-2.amazonaws.com/dev/"
storybook:
desc: Start the Storybook server.
cmd: yarn storybook
deps:
- yarn
storybook:build:
desc: Build the Storybook static site.
cmd: yarn build-storybook
generates:
- storybook-static/**/*
deps:
- yarn
docsite:start:
desc: Start the docsite dev server.
cmd: yarn start
dir: docs
deps:
- yarn
docsite:build:public:
desc: Build the full docsite.
cmds:
- cd docs && yarn build
- task: copyfiles:'storybook-static':'docs/build/storybook'
sources:
- "docs/*"
- "docs/src/**/*"
- "docs/docs/**/*"
- "docs/static/**/*"
- storybook-static/**/*
generates:
- "docs/build/**/*"
deps:
- yarn
- storybook:build
docsite:build:embedded:
2024-11-19 23:15:11 +01:00
desc: Build the embedded docsite and copy it to dist/docsite
sources:
- "docs/*"
- "docs/src/**/*"
- "docs/docs/**/*"
- "docs/static/**/*"
generates:
2024-11-19 23:15:11 +01:00
- "dist/docsite/**/*"
cmds:
- cd docs && yarn build-embedded
- task: copyfiles:'docs/build/':'dist/docsite'
deps:
- yarn
package:
desc: Package the application for the current platform.
cmds:
2024-08-13 08:37:08 +02:00
- cmd: '{{.RMRF}} "make"'
2024-07-19 00:16:49 +02:00
ignore_error: true
- yarn build:prod && yarn electron-builder -c electron-builder.config.cjs -p never
deps:
- yarn
2024-11-19 23:15:11 +01:00
- docsite:build:embedded
- build:backend
build:backend:
desc: Build the wavesrv and wsh components.
cmds:
- task: build:server
- task: build:wsh
2024-06-12 02:42:10 +02:00
build:server:
desc: Build the wavesrv component.
cmds:
- task: build:server:linux
- task: build:server:macos
- task: build:server:windows
deps:
- go:mod:tidy
- generate
sources:
- "cmd/server/*.go"
- "pkg/**/*.go"
generates:
- dist/bin/wavesrv.*
build:server:macos:
desc: Build the wavesrv component for macOS (Darwin) platforms (generates artifacts for both arm64 and amd64).
platforms: [darwin]
cmds:
- cmd: "{{.RM}} dist/bin/wavesrv*"
2024-07-19 00:16:49 +02:00
ignore_error: true
- task: build:server:internal
vars:
ARCHS: arm64,amd64
build:server:windows:
desc: Build the wavesrv component for Windows platforms (only generates artifacts for the current architecture).
platforms: [windows]
cmds:
- cmd: "{{.RM}} dist/bin/wavesrv*"
ignore_error: true
- task: build:server:internal
vars:
ARCHS:
sh: echo {{if eq "arm" ARCH}}arm64{{else}}{{ARCH}}{{end}}
build:server:linux:
desc: Build the wavesrv component for Linux platforms (only generates artifacts for the current architecture).
platforms: [linux]
cmds:
- cmd: "{{.RM}} dist/bin/wavesrv*"
2024-07-19 00:16:49 +02:00
ignore_error: true
- task: build:server:internal
vars:
ARCHS:
2024-07-19 00:53:20 +02:00
sh: echo {{if eq "arm" ARCH}}arm64{{else}}{{ARCH}}{{end}}
2024-09-25 06:56:45 +02:00
GO_ENV_VARS:
2024-09-25 07:50:08 +02:00
sh: echo "{{if eq "amd64" ARCH}}CC=\"zig cc -target x86_64-linux-gnu.2.28\"{{end}}"
2024-07-19 00:53:20 +02:00
build:server:internal:
requires:
vars:
- ARCHS
cmd:
cmd: CGO_ENABLED=1 GOARCH={{.GOARCH}} {{.GO_ENV_VARS}} go build -tags "osusergo,sqlite_omit_load_extension" -ldflags "{{.GO_LDFLAGS}} -X main.BuildTime=$({{.DATE}} +'%Y%m%d%H%M') -X main.WaveVersion={{.VERSION}}" -o dist/bin/wavesrv.{{if eq .GOARCH "amd64"}}x64{{else}}{{.GOARCH}}{{end}}{{exeExt}} cmd/server/main-server.go
for:
var: ARCHS
split: ","
as: GOARCH
internal: true
2024-06-21 23:44:11 +02:00
build:wsh:
desc: Build the wsh component for all possible targets.
2024-07-19 00:16:49 +02:00
cmds:
- cmd: "{{.RM}} dist/bin/wsh*"
2024-07-19 00:16:49 +02:00
ignore_error: true
- task: build:wsh:internal
vars:
2024-07-19 00:53:20 +02:00
GOOS: darwin
GOARCH: arm64
- task: build:wsh:internal
vars:
2024-07-19 00:53:20 +02:00
GOOS: darwin
GOARCH: amd64
- task: build:wsh:internal
vars:
2024-07-19 00:53:20 +02:00
GOOS: linux
GOARCH: arm64
- task: build:wsh:internal
vars:
2024-07-19 00:53:20 +02:00
GOOS: linux
GOARCH: amd64
- task: build:wsh:internal
vars:
2024-07-19 00:53:20 +02:00
GOOS: windows
GOARCH: amd64
- task: build:wsh:internal
vars:
2024-07-19 00:53:20 +02:00
GOOS: windows
GOARCH: arm64
deps:
- go:mod:tidy
- generate
sources:
- "cmd/wsh/**/*.go"
- "pkg/**/*.go"
generates:
- dist/bin/wsh-*
build:wsh:internal:
vars:
2024-07-19 00:53:20 +02:00
EXT:
sh: echo {{if eq .GOOS "windows"}}.exe{{end}}
NORMALIZEDARCH:
sh: echo {{if eq .GOARCH "amd64"}}x64{{else}}{{.GOARCH}}{{end}}
requires:
vars:
- GOOS
- GOARCH
- VERSION
cmd: (CGO_ENABLED=0 GOOS={{.GOOS}} GOARCH={{.GOARCH}} go build -ldflags="-s -w -X main.BuildTime=$({{.DATE}} +'%Y%m%d%H%M') -X main.WaveVersion={{.VERSION}}" -o dist/bin/wsh-{{.VERSION}}-{{.GOOS}}.{{.NORMALIZEDARCH}}{{.EXT}} cmd/wsh/main-wsh.go)
internal: true
2024-06-21 23:44:11 +02:00
generate:
desc: Generate Typescript bindings for the Go backend.
cmds:
- go run cmd/generatets/main-generatets.go
- go run cmd/generatego/main-generatego.go
sources:
2024-08-28 03:49:49 +02:00
- "cmd/generatego/*.go"
- "cmd/generatets/*.go"
- "pkg/**/*.go"
# don't add generates key (otherwise will always execute)
Add release channels (#385) ## New release flow 1. Run "Bump Version" workflow with the desired version bump and the prerelease flag set to `true`. This will push a new version bump to the target branch and create a new git tag. - See below for more info on how the version bumping works. 2. A new "Build Helper" workflow run will kick off automatically for the new tag. Once it is complete, test the new build locally by downloading with the [download script](https://github.com/wavetermdev/thenextwave/blob/main/scripts/artifacts/download-staged-artifact.sh). 3. Release the new build using the [publish script](https://github.com/wavetermdev/thenextwave/blob/main/scripts/artifacts/publish-from-staging.sh). This will trigger electron-updater to distribute the package to beta users. 4. Run "Bump Version" again with a release bump (either `major`, `minor`, or `patch`) and the prerelease flag set to `false`. 6. Release the new build to all channels using the [publish script](https://github.com/wavetermdev/thenextwave/blob/main/scripts/artifacts/publish-from-staging.sh). This will trigger electron-updater to distribute the package to all users. ## Change Summary Creates a new "Bump Version" workflow to manage versioning and tag creation. Build Helper is now automated. ### Version bumps Updates the `version.cjs` script so that an argument can be passed to trigger a version bump. Under the hood, this utilizes NPM's `semver` package. If arguments are present, the version will be bumped. If only a single argument is given, the following are valid inputs: - `none`: No-op. - `patch`: Bumps the patch version. - `minor`: Bumps the minor version. - `major`: Bumps the major version. - '1', 'true': Bumps the prerelease version. If two arguments are given, the first argument must be either `none`, `patch`, `minor`, or `major`. The second argument must be `1` or `true` to bump the prerelease version. ### electron-builder We are now using the release channels support in electron-builder. This will automatically detect the channel being built based on the package version to determine which channel update files need to be generated. See [here](https://www.electron.build/tutorials/release-using-channels.html) for more information. ### Github Actions #### Bump Version This adds a new "Bump Version" workflow for managing versioning and queuing new builds. When run, this workflow will bump the version, create a new tag, and push the changes to the target branch. There is a new dropdown when queuing the "Bump Version" workflow to select what kind of version bump to perform. A bump must always be performed when running a new build to ensure consistency. I had to create a GitHub App to grant write permissions to our main branch for the version bump commits. I've made a separate workflow file to manage the version bump commits, which should help prevent tampering. Thanks to using the GitHub API directly, I am able to make these commits signed! #### Build Helper Build Helper is now triggered when new tags are created, rather than being triggered automatically. This ensures we're always creating artifacts from known checkpoints. ### Settings Adds a new `autoupdate:channel` configuration to the settings file. If unset, the default from the artifact will be used (should correspond to the channel of the artifact when downloaded). ## Future Work I want to add a release workflow that will automatically copy over the corresponding version artifacts to the release bucket when a new GitHub Release is created. I also want to separate versions into separate subdirectories in the release bucket so we can clean them up more-easily. --------- Co-authored-by: wave-builder <builds@commandline.dev> Co-authored-by: wave-builder[bot] <181805596+wave-builder[bot]@users.noreply.github.com>
2024-09-17 22:10:35 +02:00
version:
desc: Get the current package version, or bump version if args are present. To pass args to `version.cjs`, add them after `--`. See `version.cjs` for usage definitions for the arguments.
Add release channels (#385) ## New release flow 1. Run "Bump Version" workflow with the desired version bump and the prerelease flag set to `true`. This will push a new version bump to the target branch and create a new git tag. - See below for more info on how the version bumping works. 2. A new "Build Helper" workflow run will kick off automatically for the new tag. Once it is complete, test the new build locally by downloading with the [download script](https://github.com/wavetermdev/thenextwave/blob/main/scripts/artifacts/download-staged-artifact.sh). 3. Release the new build using the [publish script](https://github.com/wavetermdev/thenextwave/blob/main/scripts/artifacts/publish-from-staging.sh). This will trigger electron-updater to distribute the package to beta users. 4. Run "Bump Version" again with a release bump (either `major`, `minor`, or `patch`) and the prerelease flag set to `false`. 6. Release the new build to all channels using the [publish script](https://github.com/wavetermdev/thenextwave/blob/main/scripts/artifacts/publish-from-staging.sh). This will trigger electron-updater to distribute the package to all users. ## Change Summary Creates a new "Bump Version" workflow to manage versioning and tag creation. Build Helper is now automated. ### Version bumps Updates the `version.cjs` script so that an argument can be passed to trigger a version bump. Under the hood, this utilizes NPM's `semver` package. If arguments are present, the version will be bumped. If only a single argument is given, the following are valid inputs: - `none`: No-op. - `patch`: Bumps the patch version. - `minor`: Bumps the minor version. - `major`: Bumps the major version. - '1', 'true': Bumps the prerelease version. If two arguments are given, the first argument must be either `none`, `patch`, `minor`, or `major`. The second argument must be `1` or `true` to bump the prerelease version. ### electron-builder We are now using the release channels support in electron-builder. This will automatically detect the channel being built based on the package version to determine which channel update files need to be generated. See [here](https://www.electron.build/tutorials/release-using-channels.html) for more information. ### Github Actions #### Bump Version This adds a new "Bump Version" workflow for managing versioning and queuing new builds. When run, this workflow will bump the version, create a new tag, and push the changes to the target branch. There is a new dropdown when queuing the "Bump Version" workflow to select what kind of version bump to perform. A bump must always be performed when running a new build to ensure consistency. I had to create a GitHub App to grant write permissions to our main branch for the version bump commits. I've made a separate workflow file to manage the version bump commits, which should help prevent tampering. Thanks to using the GitHub API directly, I am able to make these commits signed! #### Build Helper Build Helper is now triggered when new tags are created, rather than being triggered automatically. This ensures we're always creating artifacts from known checkpoints. ### Settings Adds a new `autoupdate:channel` configuration to the settings file. If unset, the default from the artifact will be used (should correspond to the channel of the artifact when downloaded). ## Future Work I want to add a release workflow that will automatically copy over the corresponding version artifacts to the release bucket when a new GitHub Release is created. I also want to separate versions into separate subdirectories in the release bucket so we can clean them up more-easily. --------- Co-authored-by: wave-builder <builds@commandline.dev> Co-authored-by: wave-builder[bot] <181805596+wave-builder[bot]@users.noreply.github.com>
2024-09-17 22:10:35 +02:00
cmd: node version.cjs {{.CLI_ARGS}}
artifacts:upload:
desc: Uploads build artifacts to the staging bucket in S3. To add additional AWS CLI arguments, add them after `--`.
vars:
ORIGIN: "make/"
DESTINATION: "{{.ARTIFACTS_BUCKET}}/{{.VERSION}}"
cmd: aws s3 cp {{.ORIGIN}}/ s3://{{.DESTINATION}}/ --recursive --exclude "*/*" --exclude "builder-*.yml" {{.CLI_ARGS}}
artifacts:download:*:
desc: Downloads the specified artifacts version from the staging bucket. To add additional AWS CLI arguments, add them after `--`.
vars:
DL_VERSION: '{{ replace "v" "" (index .MATCH 0)}}'
ORIGIN: "{{.ARTIFACTS_BUCKET}}/{{.DL_VERSION}}"
DESTINATION: "artifacts/{{.DL_VERSION}}"
cmds:
- '{{.RMRF}} "{{.DESTINATION}}"'
- aws s3 cp s3://{{.ORIGIN}}/ {{.DESTINATION}}/ --recursive {{.CLI_ARGS}}
artifacts:publish:*:
desc: Publishes the specified artifacts version from the staging bucket to the releases bucket. To add additional AWS CLI arguments, add them after `--`.
vars:
UP_VERSION: '{{ replace "v" "" (index .MATCH 0)}}'
ORIGIN: "{{.ARTIFACTS_BUCKET}}/{{.UP_VERSION}}"
DESTINATION: "{{.RELEASES_BUCKET}}"
cmd: |
OUTPUT=$(aws s3 cp s3://{{.ORIGIN}}/ s3://{{.DESTINATION}}/ --recursive {{.CLI_ARGS}})
for line in $OUTPUT; do
PREFIX=${line%%{{.DESTINATION}}*}
SUFFIX=${line:${#PREFIX}}
if [[ -n "$SUFFIX" ]]; then
echo "https://$SUFFIX"
fi
done
artifacts:snap:publish:*:
desc: Publishes the specified artifacts version to Snapcraft.
vars:
UP_VERSION: '{{ replace "v" "" (index .MATCH 0)}}'
CHANNEL: '{{if contains "beta" .UP_VERSION}}beta{{else}}beta,stable{{end}}'
cmd: |
echo "Releasing to channels: [{{.CHANNEL}}]"
snapcraft upload --release={{.CHANNEL}} waveterm_{{.UP_VERSION}}_arm64.snap
snapcraft upload --release={{.CHANNEL}} waveterm_{{.UP_VERSION}}_amd64.snap
artifacts:winget:publish:*:
desc: Submits a version bump request to WinGet for the latest release.
status:
- exit {{if contains "beta" .UP_VERSION}}0{{else}}1{{end}}
vars:
UP_VERSION: '{{ replace "v" "" (index .MATCH 0)}}'
cmd: |
wingetcreate update {{.WINGET_PACKAGE}} -s -v {{.UP_VERSION}} -u "https://{{.RELEASES_BUCKET}}/{{.APP_NAME}}-win32-x64-{{.UP_VERSION}}.msi" -t $env:GITHUB_TOKEN
dev:installwsh:
desc: quick shortcut to rebuild wsh and install for macos arm64
requires:
vars:
- VERSION
cmds:
- task: build:wsh:internal
vars:
GOOS: darwin
GOARCH: arm64
- cp dist/bin/wsh-{{.VERSION}}-darwin.arm64 ~/Library/Application\ Support/waveterm-dev/bin/wsh
dev:clearconfig:
desc: Clear the config directory for waveterm-dev
cmd: "{{.RMRF}} ~/.config/waveterm-dev"
dev:cleardata:
desc: Clear the data directory for waveterm-dev
cmds:
- task: dev:cleardata:windows
- task: dev:cleardata:linux
- task: dev:cleardata:macos
dev:cleardata:windows:
internal: true
platforms: [windows]
cmd: '{{.RMRF}} %LOCALAPPDATA%\waveterm-dev\Data'
dev:cleardata:linux:
internal: true
platforms: [linux]
cmd: "rm -rf ~/.local/share/waveterm-dev"
dev:cleardata:macos:
internal: true
platforms: [darwin]
cmd: 'rm -rf ~/Library/Application\ Support/waveterm-dev'
yarn:
desc: Runs `yarn`
internal: true
generates:
- node_modules/**/*
- yarn.lock
- .yarn/*
sources:
- yarn.lock
- package.json
2024-08-26 22:35:10 +02:00
- .yarnrc.yml
cmd: yarn
go:mod:tidy:
desc: Runs `go mod tidy`
internal: true
generates:
- go.sum
sources:
- go.mod
cmd: go mod tidy
copyfiles:*:*:
desc: Recursively copy directory and its contents.
internal: true
2024-11-19 23:15:11 +01:00
cmd: '{{if eq OS "windows"}}powershell Copy-Item -Recurse -Force -Path {{index .MATCH 0}} -Destination {{index .MATCH 1}}{{else}}mkdir -p "$(dirname {{index .MATCH 1}})" && cp -r {{index .MATCH 0}} {{index .MATCH 1}}{{end}}'