Создан каркас проекта и система сборки.
Some checks failed
drawio-exporter/pipeline/head There was a failure building this commit
Some checks failed
drawio-exporter/pipeline/head There was a failure building this commit
This commit is contained in:
parent
2da3265dc3
commit
ec6351ec91
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"cSpell.words": [
|
||||||
|
"drawio"
|
||||||
|
]
|
||||||
|
}
|
107
.vscode/tasks.json
vendored
Normal file
107
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
{
|
||||||
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
|
// for the documentation about the tasks.json format
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "build",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "make vendor build",
|
||||||
|
"group": "build",
|
||||||
|
"icon": {
|
||||||
|
"id": "briefcase",
|
||||||
|
"color": "terminal.ansiGreen"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "dist",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "make build dist",
|
||||||
|
"group": "build",
|
||||||
|
"icon": {
|
||||||
|
"id": "briefcase",
|
||||||
|
"color": "terminal.ansiBlue"
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"env": {
|
||||||
|
"GO_OPT": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "doc HTML",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "make doc",
|
||||||
|
"group": "build",
|
||||||
|
"icon": {
|
||||||
|
"id": "book",
|
||||||
|
"color": "terminal.ansiBlue"
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"env": {
|
||||||
|
"DOC_FORMAT": "html"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "doc PDF",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "make doc",
|
||||||
|
"group": "build",
|
||||||
|
"icon": {
|
||||||
|
"id": "book",
|
||||||
|
"color": "terminal.ansiRed"
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"env": {
|
||||||
|
"DOC_FORMAT": "pdf"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "test",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "make test",
|
||||||
|
"group": "test",
|
||||||
|
"icon": {
|
||||||
|
"id": "beaker",
|
||||||
|
"color": "terminal.ansiGreen"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "coverage",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "make coverage",
|
||||||
|
"group": "test",
|
||||||
|
"icon": {
|
||||||
|
"id": "beaker",
|
||||||
|
"color": "terminal.ansiGreen"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "coverage HTML",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "make coverage",
|
||||||
|
"group": "test",
|
||||||
|
"icon": {
|
||||||
|
"id": "beaker",
|
||||||
|
"color": "terminal.ansiBlue"
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"env": {
|
||||||
|
"EXPORT_RESULT": "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "clean",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "make clean",
|
||||||
|
"group": "build",
|
||||||
|
"icon": {
|
||||||
|
"id": "trash",
|
||||||
|
"color": "terminal.ansiBlack"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
11
CHANGELOG.md
Normal file
11
CHANGELOG.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
Все заметные изменения в этом проекте будут документироваться в этом файле.
|
||||||
|
Формат основан на [Keep a Changelog](https://keepachangelog.com/ru/1.1.0/),
|
||||||
|
и этот проект придерживается [Semantic Versioning](https://semver.org/lang/ru/).
|
||||||
|
|
||||||
|
## [0.1] - Не опубликовано
|
||||||
|
|
||||||
|
- **Добавлено**
|
||||||
|
- Все параметры передаются программе `drawio` из пакета `drawio-desktop` без
|
||||||
|
изменений.
|
@ -1,2 +1,4 @@
|
|||||||
# drawio-exporter
|
# Go Draw.io Exporter
|
||||||
|
|
||||||
|
Экспортирует все диаграммы из файла формата `Draw.io`.
|
||||||
|
Для работы необходимо наличие приложения `drawio-desktop`.
|
||||||
|
214
build/ci/Jenkinsfile
vendored
Normal file
214
build/ci/Jenkinsfile
vendored
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
// MouseSoft Ships Jenkins declarative pipeline
|
||||||
|
|
||||||
|
pipeline {
|
||||||
|
agent { label 'go' }
|
||||||
|
options {
|
||||||
|
ansiColor('css')
|
||||||
|
timestamps()
|
||||||
|
buildDiscarder(logRotator(numToKeepStr: '10'))
|
||||||
|
skipDefaultCheckout()
|
||||||
|
timeout(time: 8, unit: 'MINUTES', activity: true)
|
||||||
|
}
|
||||||
|
environment {
|
||||||
|
PROJECT_OWNER = 'ms'
|
||||||
|
PROJECT_ID = 'drawio-exporter'
|
||||||
|
PROJECT_NAME = 'MouseSoft Draw.io Exporter'
|
||||||
|
ROCKET_TITLE = "${currentBuild.fullDisplayName} (<${env.BUILD_URL}|Open>)"
|
||||||
|
RELEASE_ID = 0
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage('Build') {
|
||||||
|
parallel {
|
||||||
|
stage('Build Linux') {
|
||||||
|
steps {
|
||||||
|
echo "***** BUILD ${PROJECT_NAME} on Linux *****"
|
||||||
|
msSendRocketChat("${ROCKET_TITLE}", msBuildInfo(currentBuild), 'black')
|
||||||
|
cleanWs(disableDeferredWipeout: true, deleteDirs: true)
|
||||||
|
checkout scm
|
||||||
|
sh '''#!/bin/bash
|
||||||
|
make clean vendor lint build dist doc
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// stage('Build Windows') {
|
||||||
|
// agent{ label 'windows' }
|
||||||
|
// environment {
|
||||||
|
// GO_OPT = ' '
|
||||||
|
// CGO_ENABLED = 0
|
||||||
|
// }
|
||||||
|
// steps {
|
||||||
|
// echo "***** BUILD ${PROJECT_NAME} on Windows *****"
|
||||||
|
// cleanWs(disableDeferredWipeout: true, deleteDirs: true)
|
||||||
|
// catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
|
||||||
|
// checkout scm
|
||||||
|
// bat 'make clean vendor build dist pkg-msi'
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// post {
|
||||||
|
// always {
|
||||||
|
// script {
|
||||||
|
// if (getContext(hudson.FilePath)) {
|
||||||
|
// archiveArtifacts (
|
||||||
|
// artifacts: 'out/*.zip,out/*.msi',
|
||||||
|
// allowEmptyArchive: true,
|
||||||
|
// fingerprint: true,
|
||||||
|
// onlyIfSuccessful: true,
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Test') {
|
||||||
|
environment {
|
||||||
|
EXPORT_RESULT = true
|
||||||
|
COVERAGE_FORMAT = 'xml'
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
echo "===== TEST ${PROJECT_NAME} ====="
|
||||||
|
sh '''#!/bin/bash
|
||||||
|
make test coverage
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Doc') {
|
||||||
|
when { anyOf {
|
||||||
|
branch 'main'
|
||||||
|
branch 'develop'
|
||||||
|
branch 'release/*'
|
||||||
|
branch 'support/*'
|
||||||
|
tag 'v*'
|
||||||
|
} }
|
||||||
|
environment {
|
||||||
|
DOC_FORMAT = 'pdf'
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
echo "===== MAKE ${PROJECT_NAME} Documentation ====="
|
||||||
|
sh '''#!/bin/bash
|
||||||
|
make doc
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Draft Release') {
|
||||||
|
when { tag 'v*' }
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
def version = "${TAG_NAME}".substring(1)
|
||||||
|
RELEASE_ID = msCreateRelease(
|
||||||
|
"${PROJECT_OWNER}",
|
||||||
|
"${PROJECT_ID}",
|
||||||
|
"${TAG_NAME}",
|
||||||
|
"${PROJECT_NAME}",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Release') {
|
||||||
|
parallel {
|
||||||
|
stage('Release Linux') {
|
||||||
|
when { tag 'v*' }
|
||||||
|
environment {
|
||||||
|
OUTDIR = 'dist'
|
||||||
|
DIST_TAG = 'empty'
|
||||||
|
GO_OPT = ' '
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
echo "***** RELEASE ${PROJECT_NAME} for Linux *****"
|
||||||
|
sh '''#!/bin/bash
|
||||||
|
make build dist
|
||||||
|
'''
|
||||||
|
script {
|
||||||
|
msUploadFilesToRelease(
|
||||||
|
"${PROJECT_OWNER}",
|
||||||
|
"${PROJECT_ID}",
|
||||||
|
RELEASE_ID,
|
||||||
|
['dist/*.tar.gz', 'out/doc/*.pdf'],
|
||||||
|
)
|
||||||
|
if( currentBuild.currentResult == 'SUCCESS' ) {
|
||||||
|
currentBuild.keepLog = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msSendRocketChat("${ROCKET_TITLE}", "Released assets for Linux", 'blue')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Release Windows') {
|
||||||
|
agent{ label 'windows' }
|
||||||
|
when { tag 'v*' }
|
||||||
|
environment {
|
||||||
|
OUTDIR = 'dist'
|
||||||
|
DIST_TAG = 'empty'
|
||||||
|
GO_OPT = ' '
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
echo "***** RELEASE ${PROJECT_NAME} for Windows *****"
|
||||||
|
bat 'make build dist pkg-msi'
|
||||||
|
script {
|
||||||
|
msUploadFilesToRelease(
|
||||||
|
"${PROJECT_OWNER}",
|
||||||
|
"${PROJECT_ID}",
|
||||||
|
RELEASE_ID,
|
||||||
|
['dist/*.msi'],
|
||||||
|
)
|
||||||
|
if( currentBuild.currentResult == 'SUCCESS' ) {
|
||||||
|
currentBuild.keepLog = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msSendRocketChat("${ROCKET_TITLE}", "Released assets for Windows", 'blue')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
script {
|
||||||
|
if (getContext(hudson.FilePath)) {
|
||||||
|
junit (
|
||||||
|
testResults: 'out/junit-report.xml',
|
||||||
|
allowEmptyResults: false,
|
||||||
|
skipPublishingChecks: true,
|
||||||
|
)
|
||||||
|
cobertura (
|
||||||
|
coberturaReportFile: 'out/coverage.xml',
|
||||||
|
failNoReports: true,
|
||||||
|
)
|
||||||
|
archiveArtifacts (
|
||||||
|
artifacts: 'out/*.tar.*,out/*.zip,out/*.msi',
|
||||||
|
allowEmptyArchive: false,
|
||||||
|
fingerprint: true,
|
||||||
|
onlyIfSuccessful: true,
|
||||||
|
)
|
||||||
|
archiveArtifacts (
|
||||||
|
artifacts: 'out/doc/*.pdf',
|
||||||
|
allowEmptyArchive: true,
|
||||||
|
fingerprint: true,
|
||||||
|
onlyIfSuccessful: true,
|
||||||
|
)
|
||||||
|
if (currentBuild.result == 'SUCCESS') {
|
||||||
|
publishHTML(target: [
|
||||||
|
allowMissing: true,
|
||||||
|
alwaysLinkToLastBuild: true,
|
||||||
|
keepAll: false,
|
||||||
|
reportDir: 'out/doc/html',
|
||||||
|
reportFiles: 'godoc/index.html',
|
||||||
|
reportTitles: 'Техническая документация',
|
||||||
|
reportName: 'Documentation',
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( currentBuild.result != 'SUCCESS' ) {
|
||||||
|
currentBuild.keepLog = false
|
||||||
|
}
|
||||||
|
def timeSec = currentBuild.duration / 1000
|
||||||
|
msSendRocketChat(
|
||||||
|
"${ROCKET_TITLE}",
|
||||||
|
"Build ${currentBuild.result} after ${timeSec} sec",
|
||||||
|
msBuildResultColor(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
cmd/drawio-export/main.go
Normal file
7
cmd/drawio-export/main.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Println("Draw.io Exporter")
|
||||||
|
}
|
136
makefile
Normal file
136
makefile
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
# drawio-exporter makefile
|
||||||
|
# ========================
|
||||||
|
|
||||||
|
PROJECT_NAME := drawio-exporter
|
||||||
|
|
||||||
|
TMPDIR ?= $(CURDIR)/tmp
|
||||||
|
OUTDIR ?= $(CURDIR)/out
|
||||||
|
BINDIR ?= $(OUTDIR)/bin
|
||||||
|
|
||||||
|
VERSION ?= $(strip $(shell ./scripts/version.sh))
|
||||||
|
VERSION_NUMBER := $(strip $(shell ./scripts/version.sh number))
|
||||||
|
DIST_KIND := $(shell uname -m)
|
||||||
|
|
||||||
|
GO_OPT_BASE := -mod vendor -ldflags "-X main.version=${VERSION}"
|
||||||
|
GO_OPT ?=
|
||||||
|
EXPORT_RESULT ?= false # for CI please set EXPORT_RESULT to true
|
||||||
|
COVERAGE_FORMAT ?= html
|
||||||
|
|
||||||
|
GOCMD := go
|
||||||
|
GOTEST := $(GOCMD) test
|
||||||
|
GOVET := $(GOCMD) vet
|
||||||
|
ECHO_CMD := echo
|
||||||
|
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
DIST_SUFFIX := windows-$(DIST_KIND)
|
||||||
|
MSI_FILE := $(PROJECT_NAME)_$(VERSION)_$(DIST_KIND).msi
|
||||||
|
DIST_EXT := .zip
|
||||||
|
DIST_OPTS := -a -cf
|
||||||
|
ECHO_CMD := echo -e
|
||||||
|
else
|
||||||
|
PLATFORM := $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
||||||
|
DIST_SUFFIX := $(PLATFORM)-$(DIST_KIND)
|
||||||
|
DIST_EXT := .tar.gz
|
||||||
|
DIST_OPTS := -czf
|
||||||
|
endif
|
||||||
|
|
||||||
|
PKG_NAME := $(PROJECT_NAME)_$(VERSION)_$(DIST_SUFFIX)
|
||||||
|
DIST_FILE := $(PKG_NAME)$(DIST_EXT)
|
||||||
|
|
||||||
|
GREEN := $(shell tput -Txterm setaf 2)
|
||||||
|
YELLOW := $(shell tput -Txterm setaf 3)
|
||||||
|
WHITE := $(shell tput -Txterm setaf 7)
|
||||||
|
CYAN := $(shell tput -Txterm setaf 6)
|
||||||
|
RESET := $(shell tput -Txterm sgr0)
|
||||||
|
|
||||||
|
.PHONY: all version version-number test build dist vendor
|
||||||
|
|
||||||
|
version: ## Version of the project to be built
|
||||||
|
@echo $(VERSION)
|
||||||
|
|
||||||
|
version-number: ## Version number of the project to be built
|
||||||
|
@echo $(VERSION_NUMBER)
|
||||||
|
|
||||||
|
## Build:
|
||||||
|
|
||||||
|
all: clean vendor build ## Build binary
|
||||||
|
|
||||||
|
APPS = $(patsubst cmd/%/, %, $(dir $(wildcard cmd/*/main.go)))
|
||||||
|
|
||||||
|
build: $(addprefix $(BINDIR)/, $(APPS)) ## Build your project and put the output binary in out/bin/
|
||||||
|
@mkdir -p $(BINDIR)
|
||||||
|
@$(ECHO_CMD) "Build\t\t${GREEN}[OK]${RESET}"
|
||||||
|
|
||||||
|
$(BINDIR)/%: cmd/%/main.go $(patsubst cmd/%/main.go,cmd/%/*.go,$<)
|
||||||
|
GO111MODULE=on $(GOCMD) build $(GO_OPT_BASE) $(GO_OPT) \
|
||||||
|
-o $(BINDIR)/$(BIN_PREFIX)$(patsubst cmd/%/main.go,%,$<)$(BIN_SUFFIX) \
|
||||||
|
$(patsubst %/main.go,./%,$<)
|
||||||
|
|
||||||
|
dist: ## Create all distro packages
|
||||||
|
@rm -f "$(OUTDIR)/$(DIST_FILE)"
|
||||||
|
tar $(DIST_OPTS) "$(OUTDIR)/$(DIST_FILE)" -C "$(OUTDIR)" bin
|
||||||
|
@$(ECHO_CMD) "Dist\t\t${GREEN}[OK]${RESET}"
|
||||||
|
|
||||||
|
vendor: ## Copy of all packages needed to support builds and tests in the vendor directory.
|
||||||
|
$(GOCMD) mod vendor
|
||||||
|
@echo "Vendor\t\t${GREEN}[OK]${RESET}"
|
||||||
|
|
||||||
|
clean: ## Remove build related files
|
||||||
|
@rm -fr $(TMPDIR)
|
||||||
|
@rm -fr $(OUTDIR)
|
||||||
|
@rm -fr dist/
|
||||||
|
@$(ECHO_CMD) "Clean\t\t${GREEN}[OK]${RESET}"
|
||||||
|
|
||||||
|
## Test:
|
||||||
|
test: ## Run the tests of the project
|
||||||
|
ifeq ($(EXPORT_RESULT), true)
|
||||||
|
@mkdir -p $(OUTDIR)
|
||||||
|
$(eval OUTPUT_OPTIONS = | go-junit-report -set-exit-code > $(OUTDIR)/junit-report.xml)
|
||||||
|
endif
|
||||||
|
$(GOTEST) -v $(GO_OPT) ./... $(OUTPUT_OPTIONS)
|
||||||
|
@echo "Test\t\t${GREEN}[OK]${RESET}"
|
||||||
|
|
||||||
|
coverage: ## Run the tests of the project and export the coverage report.
|
||||||
|
@mkdir -p out
|
||||||
|
$(GOTEST) -cover -covermode=count -coverprofile=$(OUTDIR)/profile.cov ./...
|
||||||
|
$(GOCMD) tool cover -func $(OUTDIR)/profile.cov
|
||||||
|
ifeq ($(EXPORT_RESULT), true)
|
||||||
|
ifeq ($(COVERAGE_FORMAT), html)
|
||||||
|
gocov convert $(OUTDIR)/profile.cov | gocov-html > $(OUTDIR)/coverage.html
|
||||||
|
else
|
||||||
|
gocov convert $(OUTDIR)/profile.cov | gocov-xml > $(OUTDIR)/coverage.xml
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
@echo "Coverage\t${GREEN}[OK]${RESET}"
|
||||||
|
|
||||||
|
## Lint:
|
||||||
|
lint: lint-go ## Run all available linters.
|
||||||
|
@echo "Lint\t\t${GREEN}[OK]${RESET}"
|
||||||
|
|
||||||
|
lint-go:
|
||||||
|
go fmt ./...
|
||||||
|
go vet ./...
|
||||||
|
|
||||||
|
## Documentation:
|
||||||
|
doc: doc-golds ## Generate all documents.
|
||||||
|
@echo "Doc\t\t${GREEN}[OK]${RESET}"
|
||||||
|
|
||||||
|
doc-common:
|
||||||
|
@mkdir -p $(DOC_DIR)
|
||||||
|
|
||||||
|
doc-golds: doc-common ## Generate HTML documentation with Golds.
|
||||||
|
@mkdir -p $(DOC_DIR)/html
|
||||||
|
golds -gen -dir=$(DOC_DIR)/html -nouses -source-code-reading=rich \
|
||||||
|
-silent -only-list-exporteds -wdpkgs-listing=solo ./pkg/hexgrid
|
||||||
|
|
||||||
|
## Help:
|
||||||
|
help: ## Show this help.
|
||||||
|
@echo ''
|
||||||
|
@echo 'Usage:'
|
||||||
|
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
|
||||||
|
@echo ''
|
||||||
|
@echo 'Targets:'
|
||||||
|
@awk 'BEGIN {FS = ":.*?## "} { \
|
||||||
|
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
|
||||||
|
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
|
||||||
|
}' $(MAKEFILE_LIST)
|
20
scripts/changes.awk
Normal file
20
scripts/changes.awk
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Get changes of given version number.
|
||||||
|
{
|
||||||
|
while (index($0, "## [" + version + "]") <= 0) {
|
||||||
|
if (getline <= 0) {
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getline <= 0 ) {
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
if (getline <= 0 ) {
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
while (index($0, "## [") <= 0) {
|
||||||
|
print $0
|
||||||
|
if (getline <= 0) {
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
scripts/version.sh
Executable file
22
scripts/version.sh
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
if [ -z ${TAG_NAME+x} ]; then
|
||||||
|
if [ -z ${BRANCH_NAME+x} ]; then
|
||||||
|
BRANCH_NAME=$(echo $(git branch --show-current) || \
|
||||||
|
echo $(git name-rev --name-only HEAD))
|
||||||
|
fi
|
||||||
|
GIT_VERSION=$(echo ${BRANCH_NAME} | grep -q 'release/' \
|
||||||
|
&& echo ${BRANCH_NAME} | sed -e 's|release/|v|' -e 's/$/-RC/' || \
|
||||||
|
echo $(git describe --always --tags --dirty 2>/dev/null) || echo v0)
|
||||||
|
else
|
||||||
|
GIT_VERSION=${TAG_NAME}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z ${VERSION+x} ]; then
|
||||||
|
VERSION=$(echo ${GIT_VERSION} | sed -e 's|^origin/||')
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $1 ]; then
|
||||||
|
echo "${VERSION}"
|
||||||
|
else
|
||||||
|
echo ${VERSION} | sed -e 's/^v//'
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user