From 838cf7b773c6e3182dfc85d24cb5831495404ced Mon Sep 17 00:00:00 2001 From: Fabio Bonelli Date: Sat, 11 Nov 2023 18:59:01 +0100 Subject: [PATCH] feat: change the CLI tool name to publiccode-parser (#156) Fix #124. --- .gitignore | 1 + .goreleaser.yml | 8 ++++---- Dockerfile | 16 +++++++++------- Dockerfile.goreleaser | 5 +++-- README.md | 10 +++++----- pcvalidate | 1 + .../publiccode_parser.go | 0 .../publiccode_parser_test.go | 0 8 files changed, 23 insertions(+), 18 deletions(-) create mode 120000 pcvalidate rename pcvalidate/pcvalidate.go => publiccode-parser/publiccode_parser.go (100%) rename pcvalidate/pcvalidate_test.go => publiccode-parser/publiccode_parser_test.go (100%) diff --git a/.gitignore b/.gitignore index 5721ea2..8bdba50 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ pcvalidate/pcvalidate +publiccode-parser/publiccode-parser .vscode .history .DS_Store diff --git a/.goreleaser.yml b/.goreleaser.yml index 4a8030b..6103cea 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -8,9 +8,9 @@ before: - go generate ./... builds: - - id: pcvalidate - binary: pcvalidate - main: ./pcvalidate/pcvalidate.go + id: publiccode-parser + binary: publiccode-parser + main: ./publiccode-parser/publiccode_parser.go ldflags: - -s -w -X main.version={{.Version}} -X main.date={{.Date}} env: @@ -46,7 +46,7 @@ dockers: goos: linux goarch: amd64 ids: - - pcvalidate + - publiccode-parser skip_push: false dockerfile: Dockerfile.goreleaser image_templates: diff --git a/Dockerfile b/Dockerfile index 5085d28..f5f2251 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,20 +4,22 @@ # # Accept the Go version for the image to be set as a build argument. -ARG GO_VERSION=1.16-alpine +ARG GO_VERSION=1.18-alpine -FROM golang:${GO_VERSION} as build +FROM docker.io/golang:${GO_VERSION} as build WORKDIR /go/src COPY . . -RUN cd pcvalidate && \ - go build -ldflags="-s -w" pcvalidate.go +RUN cd publiccode-parser && go build -ldflags="-s -w" -FROM alpine:3 +FROM docker.io/alpine:3 -COPY --from=build /go/src/pcvalidate/pcvalidate /usr/local/bin/pcvalidate +COPY --from=build /go/src/publiccode-parser/publiccode-parser /usr/local/bin/publiccode-parser -ENTRYPOINT ["/usr/local/bin/pcvalidate"] +# Keep the old name for backward compatibility +RUN ln -s /usr/local/bin/publiccode-parser /usr/local/bin/pcvalidate + +ENTRYPOINT ["/usr/local/bin/publiccode-parser"] CMD ["files/publiccode.yml"] diff --git a/Dockerfile.goreleaser b/Dockerfile.goreleaser index 2740ae4..d692404 100644 --- a/Dockerfile.goreleaser +++ b/Dockerfile.goreleaser @@ -4,11 +4,12 @@ # FROM alpine:3 -COPY pcvalidate /usr/local/bin/pcvalidate +COPY publiccode-parser /usr/local/bin/publiccode-parser +RUN ln -s /usr/local/bin/publiccode-parser /usr/local/bin/pcvalidate # git and openssh-client are needed by CircleCI when using # publiccode-parser-orb, which uses this image. RUN apk --no-cache add git openssh-client -ENTRYPOINT ["/usr/local/bin/pcvalidate"] +ENTRYPOINT ["/usr/local/bin/publiccode-parser"] CMD ["files/publiccode.yml"] diff --git a/README.md b/README.md index 8c2abcb..55a5866 100644 --- a/README.md +++ b/README.md @@ -39,20 +39,20 @@ publiccode := parser.PublicCode ## Validation from command line -This repository also contains `pcvalidate` which can be used for validating a -`publiccode.yml` from the command line. +The `publiccode-parser` binary which be used for validating a `publiccode.yml` +from the command line. To get the latest development version use: ```shell -go install github.com/italia/publiccode-parser-go/v3/pcvalidate@latest -pcvalidate mypubliccode.yml +go install github.com/italia/publiccode-parser-go/v3/publiccode-parser@latest +publiccode-parser mypubliccode.yml ``` To get the latest stable version go to the [release page](https://github.com/italia/publiccode-parser-go/releases/latest) and grab the one for your arch. -Run `pcvalidate --help` for the available command line flags. +Run `publiccode-parser --help` for the available command line flags. The tool returns 0 in case of successful validation, 1 otherwise. diff --git a/pcvalidate b/pcvalidate new file mode 120000 index 0000000..a0d9f77 --- /dev/null +++ b/pcvalidate @@ -0,0 +1 @@ +publiccode-parser/ \ No newline at end of file diff --git a/pcvalidate/pcvalidate.go b/publiccode-parser/publiccode_parser.go similarity index 100% rename from pcvalidate/pcvalidate.go rename to publiccode-parser/publiccode_parser.go diff --git a/pcvalidate/pcvalidate_test.go b/publiccode-parser/publiccode_parser_test.go similarity index 100% rename from pcvalidate/pcvalidate_test.go rename to publiccode-parser/publiccode_parser_test.go