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/ci.yml
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 ./...
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
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 }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist/
*.bak
*.test
vendor/
95 changes: 95 additions & 0 deletions .goreleaser.yaml
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}}
Comment on lines +23 to +25

Copilot AI Apr 23, 2026

Copy link

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 the main packages don’t define a version variable. go build fails when an -X ldflag targets a missing symbol. Remove this ldflag (the internal package Version is already set) or add a matching var version string in the main package.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 1feb285.


# 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}}

Copilot AI Apr 23, 2026

Copy link

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 the main packages don’t define a version variable. This will make the goreleaser build fail for this binary. Remove this ldflag (the atlasplugin Version is already set) or add a matching var version string in the main package.

Suggested change
- -X main.version={{.Version}}

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 1feb285.

- -X github.com/GoCodeAlone/workflow-plugin-migrations/internal/atlasplugin.Version={{.Version}}

# Standalone migration binary for pre-deploy jobs
- id: workflow-migrate
main: ./cmd/workflow-migrate
binary: workflow-migrate
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
- arm64
ldflags:
- -s -w

archives:
- id: workflow-plugin-migrations
builds: [workflow-plugin-migrations]
formats: [tar.gz]
name_template: "workflow-plugin-migrations-{{ .Os }}-{{ .Arch }}"
files:
- plugin.json
- LICENSE

- id: workflow-plugin-atlas-migrate
builds: [workflow-plugin-atlas-migrate]
formats: [tar.gz]
name_template: "workflow-plugin-atlas-migrate-{{ .Os }}-{{ .Arch }}"
files:
- plugin.json
- LICENSE

- id: workflow-migrate
builds: [workflow-migrate]
formats: [tar.gz]
name_template: "workflow-migrate-{{ .Os }}-{{ .Arch }}"
files:
- LICENSE

sboms:
- artifacts: archive

checksum:
name_template: "checksums.txt"

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
- "^chore:"
28 changes: 28 additions & 0 deletions cmd/workflow-migrate/main.go
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)
}
}
17 changes: 17 additions & 0 deletions cmd/workflow-plugin-atlas-migrate/main.go
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())
}
21 changes: 21 additions & 0 deletions cmd/workflow-plugin-migrations/main.go
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)
}
Loading