diff --git a/.drone.yml b/.drone.yml index 78d3552..d6f5bc4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,7 +15,7 @@ steps: username: abra-bot password: from_secret: git_coopcloud_tech_token_abra_bot - repo: git.coopcloud.tech/toolshed/drone-xgotext + repo: git.coopcloud.tech/toolshed/drone-xgettext-go registry: git.coopcloud.tech tags: latest purge: true diff --git a/Dockerfile b/Dockerfile index a00a8db..7744a49 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,15 @@ FROM golang:1.24-alpine AS build -RUN go install github.com/leonelquinteros/gotext/cli/xgotext@latest +RUN apk add git && \ + git clone https://github.com/snapcore/snapd/ /tmp/snapd/ && \ + cd /tmp/snapd/i18n/xgettext-go && \ + go build + +FROM golang:1.24-alpine WORKDIR /drone/src +COPY --from=build /tmp/snapd/i18n/xgettext-go/xgettext-go /bin/xgettext-go COPY plugin.sh /plugin/plugin.sh ENTRYPOINT ["/plugin/plugin.sh"] diff --git a/README.md b/README.md index c00152d..c65b424 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,18 @@ -# drone-abra +# drone-xgettext-go [![Build Status](https://build.coopcloud.tech/api/badges/toolshed/drone-abra/status.svg?ref=refs/heads/main)](https://build.coopcloud.tech/toolshed/drone-abra) -Use [`xgotext` ](https://github.com/leonelquinteros/gotext/tree/master/cli/xgotext) as a Drone plugin. +Use `xgettext-go` as a Drone plugin. + +!!! warning "Caution!" + This is currently configured very specifically for use with Co-op Cloud abra. More customisability Coming Soon™, see #1 ## Settings ### Optional -- **in**: (default: `/drone/src`) The source directory to scan for Gettext settings -- **out:** (default: `/drone/src/locales`) The target directory in which to create a `pot` file. -- **exclude** (default: `.git`) Comma-separated directories to exclude from processing +- **in**: (default: `/drone/src`) The source directory to scan for source files +- **out:** (default: `/drone/src/locales/default.pot`) The target directory in which to create a `pot` file. ## Example @@ -19,8 +21,8 @@ Use [`xgotext` ](https://github.com/leonelquinteros/gotext/tree/master/cli/xgote kind: pipeline name: Update Gettext catalog template steps: - - name: Run xgotext - image: git.coopcloud.tech/toolshed/drone-xgotext + - name: Run xgettext-go + image: git.coopcloud.tech/toolshed/drone-xgettext-go ``` ## Publishing diff --git a/plugin.sh b/plugin.sh index 2e134b3..6a3d599 100755 --- a/plugin.sh +++ b/plugin.sh @@ -1,22 +1,26 @@ #!/bin/sh -set -e +set -ex PLUGIN_IN=${PLUGIN_IN:-/drone/src/} -PLUGIN_OUT=${PLUGIN_OUT:-/drone/src/locales/} -PLUGIN_EXCLUDE=${PLUGIN_EXCLUDE:-} +PLUGIN_OUT=${PLUGIN_OUT:-/drone/src/locales/default.pot} +# PLUGIN_KEYWORD=${PLUGIN_KEYWORD:-gotext.Get} -run_xgotext_cmd() { +run_xgettext_cmd() { echo "--- start command ---" - xgotext -v -in "$PLUGIN_IN" -out "$PLUGIN_OUT" ${PLUGIN_EXCLUDE:+-exclude} "$PLUGIN_EXCLUDE" + xgettext-go \ + -o "$PLUGIN_OUT" \ + --keyword="i18n.G" \ + --sort-output \ + $(find "$PLUGIN_IN" -name "*.go" -not -path '*vendor*') echo "--- end command ---" } run_plugin() { echo "--- start drone-xgotext ---" - run_xgotext_cmd + run_xgettext_cmd echo "--- end drone-xgotext ---" }