-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from ydb-platform/RELEASES
Scripts and files to build releases
- Loading branch information
Showing
8 changed files
with
130 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# This workflow will build a golang project | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | ||
|
||
name: Go | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@master | ||
|
||
- name: Build | ||
run: | | ||
make build-in-docker | ||
- name: Generate Changelog | ||
run: | | ||
VERSION=$(cicd/version.sh) | ||
cicd/changelog.sh $VERSION > bin/CHANGELOG.md | ||
- name: Create GitHub Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
body_path: bin/CHANGELOG.md | ||
files: bin/ydbops* | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Changelog | ||
|
||
## 0.0.9 | ||
+ Information about version in help output | ||
+ Scripts for build release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
FROM golang:1.22 as builder | ||
COPY go /go/pkg/mod | ||
RUN mkdir /app | ||
WORKDIR /app | ||
COPY . /app | ||
RUN cd /app && make build | ||
RUN cd /app && make all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,40 @@ | ||
APP_VERSION=$(shell cicd/version.sh) | ||
BINARY_NAME=ydbops | ||
BUILD_DIR=bin | ||
TODAY=$(shell date --iso=minutes) | ||
|
||
build: | ||
go get -u | ||
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags='-X main.buildInfo=${TODAY}' -o bin/${BINARY_NAME} main.go | ||
all: build build-macos | ||
|
||
lint: | ||
@echo "Linting code..." | ||
@go vet ./... | ||
|
||
pre-build: | ||
@mkdir -p $(BUILD_DIR) | ||
|
||
build-macos: lint pre-build | ||
GOOS=darwin GOARCH=amd64 go build -ldflags='-X github.com/ydb-platform/ydbops/cmd.buildVersion=${APP_VERSION}' -o ${BUILD_DIR}/${BINARY_NAME}_darwin_amd64 main.go | ||
GOOS=darwin GOARCH=arm64 go build -ldflags='-X github.com/ydb-platform/ydbops/cmd.buildVersion=${APP_VERSION}' -o ${BUILD_DIR}/${BINARY_NAME}_darwin_arm64 main.go | ||
|
||
build: lint pre-build | ||
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags='-X github.com/ydb-platform/ydbops/cmd.buildVersion=${APP_VERSION}' -o ${BUILD_DIR}/${BINARY_NAME} main.go | ||
strip bin/${BINARY_NAME} | ||
|
||
clear: | ||
rm -rf bin/${BINARY_NAME} | ||
|
||
dep: | ||
go mod download | ||
|
||
docker: | ||
docker build --force-rm -t $(BINARY_NAME) . | ||
|
||
build-in-docker: docker | ||
docker rm -f $(BINARY_NAME) || true | ||
docker create --name $(BINARY_NAME) $(BINARY_NAME) | ||
docker cp '$(BINARY_NAME):/app/bin/' $(BUILD_DIR) | ||
docker rm -f $(BINARY_NAME) | ||
|
||
clean: | ||
@echo "Cleaning..." | ||
@rm -Rf $(BUILD_DIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/sh | ||
|
||
MARKER_PREFIX="##" | ||
VERSION=$(echo "$1" | sed 's/^v//g') | ||
|
||
IFS='' | ||
found=0 | ||
|
||
cat CHANGELOG.md | while read "line"; do | ||
|
||
# If not found and matching heading | ||
if [ $found -eq 0 ] && echo "$line" | grep -q "^$MARKER_PREFIX $VERSION$"; then | ||
found=1 | ||
continue | ||
fi | ||
|
||
# If needed version if found, and reaching next delimter - stop | ||
if [ $found -eq 1 ] && echo "$line" | grep -q -E "^$MARKER_PREFIX [[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+"; then | ||
found=0 | ||
break | ||
fi | ||
|
||
# Keep printing out lines as no other version delimiter found | ||
if [ $found -eq 1 ]; then | ||
echo "$line" | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
LATEST_TAG_REV=$(git rev-list --tags --max-count=1) | ||
LATEST_COMMIT_REV=$(git rev-list HEAD --max-count=1) | ||
|
||
if [ -n "$LATEST_TAG_REV" ]; then | ||
LATEST_TAG=$(git describe --tags "$(git rev-list --tags --max-count=1)") | ||
else | ||
LATEST_TAG="v0.0.0" | ||
fi | ||
|
||
if [ "$LATEST_TAG_REV" != "$LATEST_COMMIT_REV" ]; then | ||
echo "$LATEST_TAG+$(git rev-list HEAD --max-count=1 --abbrev-commit)" | ||
else | ||
echo "$LATEST_TAG" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters