Repository navigation
feat: v0.1.0 — golang-migrate + goose drivers, module types, steps, conformance suite #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
58b19bc
ebd27f7
bda6d25
f6bf78c
180aae6
6f9c208
6d19d9d
23a9469
1feb285
d5a1d09
cd190ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| name: CI | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| services: | ||
| postgres: | ||
| image: postgres:16-alpine | ||
| env: | ||
| POSTGRES_USER: test | ||
| POSTGRES_PASSWORD: test | ||
| POSTGRES_DB: migrations_test | ||
| ports: | ||
| - 5432:5432 | ||
| options: >- | ||
| --health-cmd pg_isready | ||
| --health-interval 10s | ||
| --health-timeout 5s | ||
| --health-retries 5 | ||
|
|
||
| env: | ||
| WORKFLOW_MIGRATE_TEST_DSN: postgres://test:test@localhost:5432/migrations_test?sslmode=disable | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/setup-go@v6 | ||
| with: | ||
| go-version-file: go.mod | ||
| - run: go build ./... | ||
| - run: go test ./... -v -race -count=1 | ||
| - run: go vet ./... |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| name: Release | ||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*' | ||
|
|
||
| permissions: | ||
| contents: write | ||
| packages: write | ||
| id-token: write # for OIDC/cosign keyless signing (future) | ||
|
|
||
| jobs: | ||
| release: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| - uses: actions/setup-go@v6 | ||
| with: | ||
| go-version-file: go.mod | ||
| - uses: goreleaser/goreleaser-action@v7 | ||
| with: | ||
| distribution: goreleaser | ||
| version: '~> v2' | ||
| args: release --clean | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| dist/ | ||
| *.bak | ||
| *.test | ||
| vendor/ |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,95 @@ | ||||
| version: 2 | ||||
|
|
||||
| before: | ||||
| hooks: | ||||
| - go mod tidy | ||||
| - "sed -i.bak 's/\"version\": \".*\"/\"version\": \"{{ .Version }}\"/' plugin.json && rm -f plugin.json.bak" | ||||
|
|
||||
| builds: | ||||
| # Main plugin binary: golang-migrate + goose + wfctl CLI | ||||
| - id: workflow-plugin-migrations | ||||
| main: ./cmd/workflow-plugin-migrations | ||||
| binary: workflow-plugin-migrations | ||||
| env: | ||||
| - CGO_ENABLED=0 | ||||
| goos: | ||||
| - linux | ||||
| - darwin | ||||
| - windows | ||||
| goarch: | ||||
| - amd64 | ||||
| - arm64 | ||||
| ldflags: | ||||
| - -s -w | ||||
| - -X main.version={{.Version}} | ||||
| - -X github.com/GoCodeAlone/workflow-plugin-migrations/internal.Version={{.Version}} | ||||
|
|
||||
| # Atlas driver binary: atlas only (separate to keep main binary lean) | ||||
| - id: workflow-plugin-atlas-migrate | ||||
| main: ./cmd/workflow-plugin-atlas-migrate | ||||
| binary: workflow-plugin-atlas-migrate | ||||
| env: | ||||
| - CGO_ENABLED=0 | ||||
| goos: | ||||
| - linux | ||||
| - darwin | ||||
| goarch: | ||||
| - amd64 | ||||
| - arm64 | ||||
| ldflags: | ||||
| - -s -w | ||||
| - -X main.version={{.Version}} | ||||
|
||||
| - -X main.version={{.Version}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 1feb285.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // Command workflow-migrate is a standalone binary for running database migrations | ||
| // as a pre-deploy job in DO App Platform, Kubernetes, or any OCI-compatible runtime. | ||
| // It applies golang-migrate or goose migrations against a Postgres database. | ||
| // | ||
| // Usage: | ||
| // | ||
| // workflow-migrate up [flags] | ||
| // workflow-migrate down [flags] | ||
| // workflow-migrate status [flags] | ||
| // workflow-migrate goto <version> [flags] | ||
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os" | ||
|
|
||
| "github.com/GoCodeAlone/workflow-plugin-migrations/pkg/cli" | ||
| ) | ||
|
|
||
| func main() { | ||
| root := cli.NewRoot() | ||
| root.Use = "workflow-migrate" | ||
| root.Short = "Standalone migration runner for pre-deploy jobs" | ||
| if err := root.Execute(); err != nil { | ||
| fmt.Fprintln(os.Stderr, err) | ||
| os.Exit(1) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // Command workflow-plugin-atlas-migrate is a workflow engine external plugin | ||
| // that provides the Atlas migration driver only. Atlas has heavy dependencies | ||
| // (HCL toolchain) so it is published as a separate binary to keep the main | ||
| // plugin binary minimal. | ||
| package main | ||
|
|
||
| import ( | ||
| "github.com/GoCodeAlone/workflow-plugin-migrations/internal/atlasplugin" | ||
| sdk "github.com/GoCodeAlone/workflow/plugin/external/sdk" | ||
| ) | ||
|
|
||
| // version is set at build time via -X main.version=<version>. | ||
| var version string | ||
|
|
||
| func main() { | ||
| sdk.Serve(atlasplugin.NewPlugin()) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Command workflow-plugin-migrations is a workflow engine external plugin | ||
| // that provides golang-migrate and goose database migration drivers, | ||
| // module types (database.migrations, database.migration_driver), and | ||
| // pipeline step types (step.migrate_up/down/status/to). | ||
| // | ||
| // When invoked with --wfctl-cli, it serves as the entrypoint for | ||
| // `wfctl migrate *` dynamic CLI commands. | ||
| package main | ||
|
|
||
| import ( | ||
| "github.com/GoCodeAlone/workflow-plugin-migrations/internal" | ||
| "github.com/GoCodeAlone/workflow-plugin-migrations/pkg/cli" | ||
| sdk "github.com/GoCodeAlone/workflow/plugin/external/sdk" | ||
| ) | ||
|
|
||
| // version is set at build time via -X main.version=<version>. | ||
| var version string | ||
|
|
||
| func main() { | ||
| sdk.ServePluginFull(internal.NewPlugin(), cli.NewCLIProvider(), nil) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-X main.version={{.Version}}is set, but themainpackages don’t define aversionvariable.go buildfails when an-Xldflag targets a missing symbol. Remove this ldflag (the internal packageVersionis already set) or add a matchingvar version stringin themainpackage.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 1feb285.