Unverified Commit df9adecd authored by Dima Brusilovsky's avatar Dima Brusilovsky Committed by GitHub
Browse files

feat: remove commits by travis during builds

parent 81ac0ec6
Showing with 91 additions and 25 deletions
+91 -25
......@@ -4,5 +4,10 @@ datree
.DS_STORE
.vscode
.idea
# macos code signing
DatreeCli.cer
DatreeCli.p12
# brew
homebrew*
......@@ -7,18 +7,6 @@ before:
hooks:
# you may remove this if you don't need go generate
- go generate ./...
brews:
- name: datree
ids:
- datree-zip
tap:
owner: datreeio
name: ___TAP_NAME
install: bin.install "datree"
homepage: "https://datree.io/"
commit_author:
name: datree-ci
email: rnd@datree.io
builds:
- env:
- CGO_ENABLED=0
......
FROM golang:1.15-alpine
RUN apk --no-cache add curl
WORKDIR /go/src/app
COPY . .
RUN curl --silent "https://api.github.com/repos/datreeio/datree/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' > cli-version
RUN go get -d -v ./...
RUN go build -tags main -ldflags="-X github.com/datreeio/datree/cmd.CliVersion=___CLI_VERSION" -v
RUN go build -tags main -ldflags="-X github.com/datreeio/datree/cmd.CliVersion=$(cat cli-version)" -v
RUN go install -v ./...
ENTRYPOINT ["./datree"]
#!/bin/bash
if [ $# -lt 2 ]
then
echo "Not enough arguments supplied"
exit
fi
VERSION=$1
DESTINATION_FOLDER=$2
SHA256_MAC=$(cat ./dist/checksums.txt | grep Darwin_x86_64 | cut -d" " -f1)
SHA256_LINUX_INTEL=$(cat ./dist/checksums.txt | grep Linux_x86_64 | cut -d" " -f1)
SHA256_LINUX_ARM=$(cat ./dist/checksums.txt | grep Linux_arm64 | cut -d" " -f1)
cat > $DESTINATION_FOLDER/datree.rb <<-EOF
# typed: false
# frozen_string_literal: true
class Datree < Formula
desc ""
homepage "https://datree.io/"
version "$VERSION"
bottle :unneeded
if OS.mac?
url "https://github.com/datreeio/datree/releases/download/$VERSION/datree-cli_${VERSION}_Darwin_x86_64.zip"
sha256 "$SHA256_MAC"
end
if OS.linux? && Hardware::CPU.intel?
url "https://github.com/datreeio/datree/releases/download/$VERSION/datree-cli_${VERSION}_Linux_x86_64.zip"
sha256 "$SHA256_LINUX_INTEL"
end
if OS.linux? && Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
url "https://github.com/datreeio/datree/releases/download/$VERSION/datree-cli_${VERSION}_Linux_arm64.zip"
sha256 "$SHA256_LINUX_ARM"
end
def install
bin.install "datree"
end
end
EOF
#!/bin/bash
if [ $# -lt 2 ]
then
echo "Not enough arguments supplied"
exit
fi
DEPLOYMENT=$1
VERSION=$2
BREW_REPO_NAME=""
if [ $DEPLOYMENT == "production" ]; then
BREW_REPO_NAME="homebrew-datree"
elif [ $DEPLOYMENT == "internal" ]; then
BREW_REPO_NAME="homebrew-datree-internal"
elif [ $DEPLOYMENT == "staging" ]; then
BREW_REPO_NAME="homebrew-datree-staging"
else
echo "No such deployment $DEPLOYMENT: Skipping deployment to brew"
exit
fi
BREW_REPO_URL="https://${GITHUB_TOKEN}@github.com/datreeio/${BREW_REPO_NAME}.git"
git clone $BREW_REPO_URL
bash ./internal/release/brew_formula_generator.sh $VERSION $BREW_REPO_NAME
cd $BREW_REPO_NAME
git add -A
git commit -m "Brew formula update for datree-cli version $VERSION"
git push
cd ..
set -ex
if [ $TRAVIS_BRANCH == "main" ]; then
export DATREE_BUILD_VERSION=$SEMVER_NUMBER
export DATREE_BREW_REPO_NAME=homebrew-datree
else
export DATREE_BUILD_VERSION=$SEMVER_NUMBER-$TRAVIS_BRANCH
export DATREE_BREW_REPO_NAME=homebrew-datree-staging
fi
sed -ie "s/___TAP_NAME/$DATREE_BREW_REPO_NAME/" .goreleaser.yml
sed -ie "s/___CLI_VERSION/$DATREE_BUILD_VERSION/" Dockerfile
git add .goreleaser.yml Dockerfile
git commit -m "ci: dynamic variable updates"
export GIT_TAG=$DATREE_BUILD_VERSION
git tag $GIT_TAG -a -m "Generated tag from TravisCI for build $TRAVIS_BUILD_NUMBER"
git push --tags
git stash save --keep-index --include-untracked
# Secure private key
openssl aes-256-cbc -K $encrypted_2dfcdd1dc486_key -iv $encrypted_2dfcdd1dc486_iv -in DatreeCli.p12.enc -out DatreeCli.p12 -d
......@@ -30,3 +22,9 @@ security set-key-partition-list -S "apple-tool:,apple:" -s -k test buildagent.ke
security find-identity -v
curl -sL https://git.io/goreleaser | VERSION=v$GORELEASER_VERSION bash
if [ $TRAVIS_BRANCH == "main" ]; then
bash ./internal/release/brew_push_formula.sh production $DATREE_BUILD_VERSION
else
bash ./internal/release/brew_push_formula.sh staging $DATREE_BUILD_VERSION
fi
set -ex
export DATREE_INTERNAL=$SEMVER_NUMBER-internal
sed -ie "s/homebrew-datree/homebrew-datree-internal/" .goreleaser.yml
git add -A
git commit -m "release $DATREE_INTERNAL"
git tag $DATREE_INTERNAL -a -m "Generated internal tag from TravisCI for build $TRAVIS_BUILD_NUMBER"
git push --tags
export DATREE_BUILD_VERSION=$DATREE_INTERNAL
curl -sL https://git.io/goreleaser | VERSION=v$GORELEASER_VERSION sh -s -- --rm-dist
bash ./internal/release/brew_push_formula.sh internal $DATREE_INTERNAL
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment