Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/tag-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Tag and Release

on:
push:
branches: [main]
paths: [VERSION]

permissions:
contents: write

jobs:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just use normal github released. not super opinionated in this project though

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a way of having github do the go release as part of CI merge to main

tag-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Read version
id: version
run: echo "version=$(cat VERSION | tr -d '[:space:]')" >> "$GITHUB_OUTPUT"

- name: Check if tag exists
id: check
run: |
if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi

- name: Create tag and release
if: steps.check.outputs.exists == 'false'
run: gh release create "v${{ steps.version.outputs.version }}" --generate-notes --title "v${{ steps.version.outputs.version }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bin/
dist/
commit-msg.md
2 changes: 2 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
version: 2

project_name: temporal-ts-net

before:
hooks:
- go mod tidy
Expand Down
55 changes: 55 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## What this is

A Temporal CLI extension (`temporal ts-net`) that runs `temporal server start-dev` and exposes it on a Tailscale tailnet via tsnet. The binary must be named `temporal-ts_net` (underscores for subcommand separators, required by the Temporal extension system).

## Build and test commands

```bash
go run mage.go build # Build to ./bin/temporal-ts_net
go run mage.go test # All tests with -race -shuffle=on
go run mage.go install # Install to $GOPATH/bin
go test ./internal/app/ # Run only app package tests
go test -short ./... # Skip integration tests (tsnet e2e)
go test ./internal/app/ -run TestLoadConfig # Single test
```

## Architecture

```
cmd/temporal-ts_net/main.go Entry point, delegates to app.Run()
internal/app/
app.go Orchestration: parse args → load config → start temporal subprocess → start tsnet proxy
parse.go Hand-rolled arg parser. Extension flags extracted, everything else passed through to temporal server start-dev
config.go TOML config loading from [ts-net] section of the Temporal CLI config file
internal/tailscale/
tsnet.go TCP proxy: tsnet listeners accept tailnet connections, proxy to local temporal server
```

The extension starts `temporal server start-dev` as a child process, then starts a tsnet node that proxies tailnet connections to it. Both gRPC and UI ports are proxied.

## Config precedence

CLI flags > `TS_AUTHKEY` env var > `[ts-net]` section in `~/.config/temporalio/temporal.toml` > defaults.

The `flagsSet` map on `ExtensionOptions` tracks which flags were explicitly passed so config file values only fill in gaps.

## Key patterns

- **Flag tracking**: `opts.flagsSet["flag-name"] = true` in every parse branch. `IsSet()` checks this during config merge.
- **Pointer types in FileConfig**: `*int` and `*float64` distinguish "absent from TOML" (nil) from "set to zero."
- **Config file sharing**: Reads from the same `temporal.toml` the Temporal CLI uses. The CLI's TOML parser ignores unknown top-level sections (non-strict mode), so `[ts-net]` coexists safely.
- **Graceful shutdown**: SIGINT to child process, wait with timeout, then SIGKILL. tsnet listeners close first, WaitGroup drains active proxies.

## Testing

- `internal/app/`: Unit tests for arg parsing, config loading, config merging, precedence
- `internal/tailscale/`: Integration tests using Tailscale's testcontrol (in-memory coordination server, no real Tailscale needed)
- `internal/app/e2e_test.go`: Full workflow execution through the proxy using a real Temporal dev server

## Releases

Bump the `VERSION` file and merge to main. GitHub Actions creates the tag and release, GoReleaser builds cross-platform binaries. The goreleaser config targets the real GitHub repo name (`temporal-start-dev-ext`) since that can't be renamed yet, but `project_name` is set to `temporal-ts-net` for archive naming.
4 changes: 4 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Contributors

- [@masonegger](https://github.com/masonegger) - Mason Egger
- [@chaptersix](https://github.com/chaptersix) - Alex Stanfield
Loading
Loading