github.com/snyk/vervet/v5@v5.11.1-0.20240202085829-ad4dd7fb6101/scripts/release.bash (about) 1 #!/usr/bin/env bash 2 set -eux 3 cd $(dirname $0)/.. 4 5 # Require a version to be set 6 [ -n "${VERSION}" ] 7 8 # Ensure there is a GOPATH set 9 if [ -z "${GOPATH:-}" ]; then 10 tmp_gopath=$(mktemp -d) 11 trap "chmod -R u+w $tmp_gopath; rm -rf $tmp_gopath" EXIT 12 export GOPATH=$tmp_gopath 13 fi 14 export PATH=$GOPATH/bin:$PATH 15 16 # Push tags in CI environment 17 if [ -z $(git config user.email) ]; then 18 git config credential.helper 'cache --timeout=120' 19 git config user.email "vervet-ci@noreply.snyk.io" 20 git config user.name "Vervet CI" 21 fi 22 23 go generate ./internal/cmd/... 24 25 git tag ${VERSION} 26 git push -q https://${GH_TOKEN}@github.com/snyk/vervet.git --tags 27 28 # Publish npm package 29 if [ ! -e "dist/.npmrc" ]; then 30 echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > dist/.npmrc 31 fi 32 (cd dist; npm publish) 33 34 # Github release 35 # Do this last; if it fails, it's easy to create a release in the UI. 36 # Pushing the tags and publishing to NPM are more important. 37 go install github.com/goreleaser/goreleaser@v1.6.3 38 GITHUB_TOKEN=${GH_TOKEN} goreleaser release --rm-dist