From 529d38db9ffc77b1ec3f3bf2b9c03a274f78c2dc Mon Sep 17 00:00:00 2001 From: DeveloperDurp Date: Sun, 31 Mar 2024 10:02:00 -0500 Subject: [PATCH] update --- pipelines/golang.yml | 2 +- scripts/golang-build-api.sh | 13 ------------- scripts/golang-build.sh | 18 ++++++++++++++++++ templates/golang.tpl.yml | 4 ++-- 4 files changed, 21 insertions(+), 16 deletions(-) delete mode 100644 scripts/golang-build-api.sh create mode 100644 scripts/golang-build.sh diff --git a/pipelines/golang.yml b/pipelines/golang.yml index f607816..3d72e44 100644 --- a/pipelines/golang.yml +++ b/pipelines/golang.yml @@ -23,7 +23,7 @@ version: gobuild: variables: GOPROXY: https://nexus.durp.info/repository/go/ - extends: .golang-build-api + extends: .golang-build stage: build docker: diff --git a/scripts/golang-build-api.sh b/scripts/golang-build-api.sh deleted file mode 100644 index 7fa0c84..0000000 --- a/scripts/golang-build-api.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -#%%MULTILINE_YAML_START -#Build golang api -export GOPATH=/go -export PATH=$PATH:$GOPATH/bin - -mkdir output - -go install -go install github.com/swaggo/swag/cmd/swag@v1.8.12 -swag init - -CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o ./output/main . \ No newline at end of file diff --git a/scripts/golang-build.sh b/scripts/golang-build.sh new file mode 100644 index 0000000..bdd35ea --- /dev/null +++ b/scripts/golang-build.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +#%%MULTILINE_YAML_START +#Build golang project +export GOPATH=/go +export PATH=$PATH:$GOPATH/bin + +mkdir output + +go install + +# Check if go.mod contains "swag" +if grep -q "swag" go.mod; then + echo "Found 'swag' in go.mod. Running swag init..." + go install github.com/swaggo/swag/cmd/swag@v1.8.12 + swag init +fi + +CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o ./output/main . diff --git a/templates/golang.tpl.yml b/templates/golang.tpl.yml index a122984..2c17342 100644 --- a/templates/golang.tpl.yml +++ b/templates/golang.tpl.yml @@ -1,9 +1,9 @@ -.golang-build-api: +.golang-build: variables: #GOPROXY: https://nexus.durp.info/repository/go/ image: registry.internal.durp.info/golang:${GO_VERSION} script: - - ./scripts/golang-build-api.sh + - ./scripts/golang-build.sh artifacts: expire_in: 1 hour paths: