Skip to content

Commit

Permalink
Initial commit including building script and submodules for percona-t…
Browse files Browse the repository at this point in the history
…oolkit and pmm-dump
  • Loading branch information
impimp committed Jul 19, 2023
0 parents commit cab2a80
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This is a basic workflow to help you get started with Actions

name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
with:
submodules: true
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ^1.20.3

- name: Build
run: ./build
env:
CGO_ENABLED: 0
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/*
tag: ${{ github.ref }}
overwrite: true
file_glob: true

6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "percona-toolkit"]
path = percona-toolkit
url = https://github.com/percona/percona-toolkit
[submodule "pmm-dump"]
path = pmm-dump
url = https://github.com/percona/pmm-dump
36 changes: 36 additions & 0 deletions build
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/bash

OS=( linux windows darwin )
ARCH=( amd64 arm arm64 )

test -d dist || mkdir dist

function d {
echo "[ $(date) ] $1"
}

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

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
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}
done;
cd ../../..
done;
done;
1 change: 1 addition & 0 deletions percona-toolkit
Submodule percona-toolkit added at 28fbbc
1 change: 1 addition & 0 deletions pmm-dump
Submodule pmm-dump added at 4cc335

0 comments on commit cab2a80

Please sign in to comment.