Skip to content

Commit

Permalink
Merge pull request #3 from svetasmirnova/main
Browse files Browse the repository at this point in the history
Automatically update submodules and add version support for Percona Toolkit
  • Loading branch information
svetasmirnova authored Dec 6, 2023
2 parents b98b254 + 4e98383 commit 2eaa7a5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
Expand All @@ -19,7 +19,21 @@ jobs:
uses: actions/setup-go@v4
with:
go-version: ^1.21.4


# Update references
- name: Git Sumbodule Update
run: |
git checkout main
git pull --recurse-submodules
git submodule update --remote --recursive
- name: Commit update
run: |
git config --global user.name 'Git bot'
git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git commit -am "Auto updated submodule references" && git push || echo "No changes to commit"
- name: Build
run: ./build
env:
Expand Down
21 changes: 15 additions & 6 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,37 @@ function d {
echo "[ $(date) ] $1"
}

function ldflags {
function ldflags_pmm_dump {
BRANCH=$(git branch --show-current)
COMMIT=$(git rev-parse --short HEAD)
VERSION=$(git describe --tags --abbrev=0)
VERSION=$(git describe --tags --abbrev=0)
echo "-X 'main.GitBranch=${BRANCH}' -X 'main.GitCommit=${COMMIT}' -X 'main.GitVersion=${VERSION}'"
}

function ldflags_pt {
CP=')'
VERSION=$(git log --no-walk --tags --pretty="%H %d" --decorate=short | head -n1 | awk -F'[, $(CP)]' '{ print $5; }')
BUILD=$(date "+%FT%T%z")
GOVERSION=$(go version | cut --delimiter=" " -f3)
COMMIT=$(git rev-list -1 HEAD)
echo "-X main.Version=${VERSION} -X main.Build=${BUILD} -X main.GoVersion=${GOVERSION} -X main.Commit=${COMMIT} -s -w"
}

for os_ in ${OS[@]}; do
for arch_ in ${ARCH[@]}; do
test $( go tool dist list | grep -wc $os_/$arch_ ) -ne 1 && continue
test "$os_/$arch_" == "windows/arm" && continue;
cd pmm-dump
d "Building pmm-dump on $os_/$arch_"
GOOS=${os_} GOARCH=${arch_} go build -ldflags "$(ldflags)" -o ../dist/pmm-dump.${os_}.${arch_} pmm-dump/cmd/pmm-dump
GOOS=${os_} GOARCH=${arch_} go build -ldflags "$(ldflags_pmm_dump)" -o ../dist/pmm-dump.${os_}.${arch_} pmm-dump/cmd/pmm-dump
cd ..

cd percona-toolkit/src/go

for pkg in pt-k8s-debug-collector pt-mongodb-index-check pt-mongodb-query-digest pt-mongodb-summary pt-pg-summary pt-secure-collect; do
d "Building $pkg on $os_/$arch_"
GOOS=${os_} GOARCH=${arch_} go build -ldflags "$(ldflags)" -o ../../../dist/${pkg}.${os_}.${arch_} ./${pkg}
d "Building $pkg on $os_/$arch_"
GOOS=${os_} GOARCH=${arch_} go build -ldflags "$(ldflags_pt)" -o ../../../dist/${pkg}.${os_}.${arch_} ./${pkg}
done;
cd ../../..
done;
done;
done;
2 changes: 1 addition & 1 deletion percona-toolkit
Submodule percona-toolkit updated 941 files
2 changes: 1 addition & 1 deletion pmm-dump
Submodule pmm-dump updated 1027 files

0 comments on commit 2eaa7a5

Please sign in to comment.