plugin-barman-cloud/dagger/check-doc-version/main.go
Francesco Canovai a592793572
docs: publish docs with docusaurus (#268)
Rework the documentation to be a static website instead of just the
GitHub README.md. Use docusaurus to create the website, and the CI to
publish to GitHub pages on commits to main.
Block `release-please` releases unless the documentation for that version
has been generated.

Closes #244

Signed-off-by: Francesco Canovai <francesco.canovai@enterprisedb.com>
Signed-off-by: Gabriele Bartolini <gabriele.bartolini@enterprisedb.com>
Co-authored-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
Co-authored-by: Gabriele Bartolini <gabriele.bartolini@enterprisedb.com>
2025-04-30 12:17:57 +02:00

46 lines
1.5 KiB
Go

// The CheckDocVersion module is designed to check if the version of the
// documentation exists for the version specified in the release-please manifest.
// This is used to ensure that we do not release a new version of the plugin
// without having the corresponding documentation ready.
package main
import (
"context"
"fmt"
"strings"
"dagger/check-doc-version/internal/dagger"
)
type CheckDocVersion struct{}
// HasVersionDocumentation checks if a version of the documentation exists for the
// version in the release-please manifest.
func (m *CheckDocVersion) HasVersionDocumentation(ctx context.Context, src *dagger.Directory) (bool, error) {
releasePleaseManifest := ".release-please-manifest.json"
docusaurusVersions := "web/versions.json"
ctr := dag.Container().From("alpine:latest").
WithDirectory("/src", src).
WithWorkdir("/src").
WithExec([]string{"apk", "add", "jq"})
nextVersion, err := ctr.
WithExec([]string{"jq", "-r", ".[\".\"]", releasePleaseManifest}).
Stdout(ctx)
nextVersion = strings.TrimSpace(nextVersion)
if err != nil {
return false, fmt.Errorf("cannot find proposed release-please version in %v: %w", releasePleaseManifest,
err)
}
currVersion, err := ctr.WithExec([]string{"jq", "-r", fmt.Sprintf(". | index(\"%v\")", nextVersion),
docusaurusVersions}).Stdout(ctx)
currVersion = strings.TrimSpace(currVersion)
if err != nil {
return false, fmt.Errorf("error querying versions in %v: %w", docusaurusVersions, err)
}
if currVersion == "null" {
return false, nil
}
return true, nil
}