From fa0a8565c367a48b24225895b84c7c17add9ced8 Mon Sep 17 00:00:00 2001 From: Anton Kuznetcov Date: Tue, 3 Dec 2024 18:00:10 +0600 Subject: [PATCH] release v1.0.2 --- Dockerfiles/ImageBuild/Dockerfile | 2 +- Dockerfiles/LocalCompile/Dockerfile | 2 +- VERSION.txt | 2 +- main.go | 10 +++++++++- shell-code/build-short.sh | 4 ++-- shell-code/build-to-dockerhub.sh | 6 +++--- shell-code/upload-release.sh | 21 +++++---------------- 7 files changed, 22 insertions(+), 25 deletions(-) diff --git a/Dockerfiles/ImageBuild/Dockerfile b/Dockerfiles/ImageBuild/Dockerfile index c36711c..ec12b98 100644 --- a/Dockerfiles/ImageBuild/Dockerfile +++ b/Dockerfiles/ImageBuild/Dockerfile @@ -11,7 +11,7 @@ COPY . . RUN echo $BUILDPLATFORM > buildplatform RUN echo $TARGETARCH > targetarch -# RUN GOOS=linux GOARCH=$TARGETARCH go build -o output/go-ansible-vault +# RUN GOOS=linux GOARCH=$TARGETARCH go build -o /app/go-lcg . RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} garble -literals -tiny build -ldflags="-w -s" -o /app/go-lcg . FROM alpine:latest diff --git a/Dockerfiles/LocalCompile/Dockerfile b/Dockerfiles/LocalCompile/Dockerfile index 08ce606..26f0a9a 100644 --- a/Dockerfiles/LocalCompile/Dockerfile +++ b/Dockerfiles/LocalCompile/Dockerfile @@ -8,7 +8,7 @@ COPY go.* . RUN go mod download COPY . . -# RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /out/go-ansible-vault . +# RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /out/go-lcg . RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} garble -literals -tiny build -ldflags="-w -s" -o /out/go-lcg . FROM scratch AS bin-unix diff --git a/VERSION.txt b/VERSION.txt index b18d465..570c796 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -v1.0.1 +v1.0.2 diff --git a/main.go b/main.go index 53d3797..2631ab4 100644 --- a/main.go +++ b/main.go @@ -44,12 +44,20 @@ Usage: lcg [options] --help -h output usage information --version -v output the version number - --file -f read command from file + --file -f read part of command from file or bash feature $(...) --update-key -u update the API key --delete-key -d delete the API key Example Usage: lcg I want to extract linux-command-gpt.tar.gz file Example Usage: lcg --file /path/to/file.json I want to print object questions with jq + +Env Vars: + LCG_HOST - defaults to "http://192.168.87.108:11434/" - endpoint for Ollama or other LLM API + LCG_COMPLETIONS_PATH -defaults to "api/chat" - relative part of endpoint + LCG_MODEL - defaults to "codegeex4" + LCG_PROMPT - defaults to Reply with linux command and nothing else. Output with plain response - no need formatting. No need explanation. No need code blocks. + LCG_API_KEY_FILE - defaults to ${HOME}/.openai_api_key - file with API key + LCG_RESULT_FOLDER - defaults to $(pwd)/gpt_results - folder to save results ` VERSION = Version diff --git a/shell-code/build-short.sh b/shell-code/build-short.sh index 4b9ffe6..9a233df 100644 --- a/shell-code/build-short.sh +++ b/shell-code/build-short.sh @@ -4,5 +4,5 @@ docker build -f Dockerfiles/LocalCompile/Dockerfile --target bin-linux --output docker build -f Dockerfiles/LocalCompile/Dockerfile --target bin-linux --output bin-linux-arm64/ --platform linux/arm64 . # in linux setuid -# sudo chown root:root bin-linux/go-ansible-vault -# sudo chmod +s bin-linux/go-ansible-vault \ No newline at end of file +# sudo chown root:root bin-linux/lcg +# sudo chmod +s bin-linux/lcg \ No newline at end of file diff --git a/shell-code/build-to-dockerhub.sh b/shell-code/build-to-dockerhub.sh index cf6a481..879f454 100644 --- a/shell-code/build-to-dockerhub.sh +++ b/shell-code/build-to-dockerhub.sh @@ -1,13 +1,13 @@ #!/bin/bash -REPO=kuznetcovay/go-ansible-vault +REPO=kuznetcovay/go-lcg VERSION=$1 if [ -z "$VERSION" ]; then VERSION=v1.0.8 fi BRANCH=main -echo ${VERSION} > VERSION.txt +echo "${VERSION}" > VERSION.txt export GOCACHE="${HOME}/.cache/go-build" # Save the current branch @@ -34,7 +34,7 @@ if ! go test -v -run=^Test; then fi # Push multi-platform images -docker buildx build --push --platform linux/amd64,linux/arm64 -t ${REPO}:${VERSION} . || +docker buildx build --push --platform linux/amd64,linux/arm64 -t ${REPO}:"${VERSION}" . || { echo "docker buildx build --push failed. Exiting with code 1." exit 1 diff --git a/shell-code/upload-release.sh b/shell-code/upload-release.sh index d5ff88d..c8b4f1b 100644 --- a/shell-code/upload-release.sh +++ b/shell-code/upload-release.sh @@ -5,28 +5,18 @@ VERSION_FILE="VERSION.txt" GITHUB_TOKEN="${GITHUB_TOKEN}" # Replace with your GitHub token -REPO="Direct-Dev-Ru/binaries.git" # Replace with your GitHub username/repo +REPO="direct-dev-ru/binaries" # Replace with your GitHub username/repo -TAG=go-ansible-vault.$(cat "$VERSION_FILE") +TAG=lcg.$(cat "$VERSION_FILE") -echo $TAG +echo TAG: $TAG -RELEASE_NAME="Binaries ${TAG}" # Replace with your release title - -RELEASE_DIR="/home/su/projects/golang/ansible-vault/binaries-for-upload" - -# Create a new release -# response=$(curl -s -X POST \ -# -H "Authorization: Bearer ${GITHUB_TOKEN}" \ -# -H "Accept: application/vnd.github+json" \ -# -H "X-GitHub-Api-Version: 2022-11-28" \ -# https://api.github.com/repos/$REPO/releases \ -# -d "{\"tag_name\": \"$TAG\", \"name\": \"$RELEASE_NAME\"}") +RELEASE_DIR="/home/su/projects/golang/linux-command-gpt/binaries-for-upload" body="{\"tag_name\":\"${TAG}\", \"target_commitish\":\"main\", \"name\":\"${TAG}\", \ \"body\":\"${TAG}\", \"draft\":false, \"prerelease\":false, \"generate_release_notes\":false}" -echo $body +echo BODY: $body response=$(curl -L -X POST \ -H "Accept: application/vnd.github+json" \ @@ -35,7 +25,6 @@ response=$(curl -L -X POST \ https://api.github.com/repos/direct-dev-ru/binaries/releases \ -d $body) - echo $response # Extract the upload URL from the response