diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..eefa9066ba8cafa7a320d11b9e7fb4f64412dad7 --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +# get Makefile directory name: http://stackoverflow.com/a/5982798/376773 +THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) +PROJECT_ROOT:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd)/ +THIS_MAKEFILE:=$(PROJECT_ROOT)$(THIS_MAKEFILE_PATH) + +GO:=go +BUILD_PATH:=$(PROJECT_ROOT)build/ + +info: + echo "PROJECT_ROOT: $(PROJECT_ROOT)" + +## Compiling for every OS and Platform +compile: + + version patch --path $(PROJECT_ROOT)version.json --selector "version" + $(eval VERSION := $(shell cat version.json | jq -r .version)) + $(eval BUILD := $(shell version date)) + + echo "Compiling for every OS and Platform $(VERSION) $(BUILD)" + + cd $(PROJECT_ROOT); GOOS=linux GOARCH=arm $(GO) build -ldflags "-X main.version=$(VERSION) -X main.build='$(BUILD)'" -o $(BUILD_PATH)version-linux-arm; cd - + cd $(PROJECT_ROOT); GOOS=linux GOARCH=amd64 $(GO) build -ldflags "-X main.version=$(VERSION) -X main.build='$(BUILD)'" -o $(BUILD_PATH)version-linux-amd64; cd - + cd $(PROJECT_ROOT); GOOS=linux GOARCH=arm64 $(GO) build -ldflags "-X main.version=$(VERSION) -X main.build='$(BUILD)'" -o $(BUILD_PATH)version-linux-arm64; cd - + cd $(PROJECT_ROOT); GOOS=linux GOARCH=386 $(GO) build -ldflags "-X main.version=$(VERSION) -X main.build='$(BUILD)'" -o $(BUILD_PATH)version-linux-386; cd - + cd $(PROJECT_ROOT); GOOS=windows GOARCH=amd64 $(GO) build -ldflags "-X main.version=$(VERSION) -X main.build='$(BUILD)'" -o $(BUILD_PATH)version-windows; cd - + +## compile and deplay to aws +deploy: compile + find $(BUILD_PATH) -iname "version-*" -exec aws s3 cp {} s3://download.schukai.com/tools/version/ \; + +## overview-to-aws +overview-to-aws: + aws s3 cp $(PROJECT_ROOT)/data/index.html s3://download.schukai.com/tools/version/ \ No newline at end of file diff --git a/README.md b/README.md index 02f28e6b0eca12b52f998c9488296961caec60d8..350e932ebc7dd2fd1fafd11f89d12e10a9a93889 100644 --- a/README.md +++ b/README.md @@ -1,92 +1,71 @@ -# version +# Bump Version +This tool helps to increment the version number of a project. +You can download the tool here: [download.schukai.com/tools/version/](http://download.schukai.com/tools/version/). -## Getting started -To make it easy for you to get started with GitLab, here's a list of recommended next steps. +```bash +echo "1.0.0" | version patch +# 1.0.1 +echo "1.0.0" | version minor +# 1.1.0 +echo "1.0.0" | version major +# 2.0.0 +``` -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! +You can also replace directly in files. -## Add your files +**YAML** -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://gitlab.schukai.com/oss/utilities/version.git -git branch -M master -git push -uf origin master +```yaml +my: + version: 1.0.0 ``` -## Integrate with your tools - -- [ ] [Set up project integrations](https://gitlab.schukai.com/oss/utilities/version/-/settings/integrations) - -## Collaborate with your team - -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) - -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. +```bash +version patch --path my.yaml --selector my.version +``` -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. +**JSON** -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. +```json +{ + "my": { + "version": "1.0.0" + } +} +``` -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. +```bash +version patch --path my.json --selector my.version +``` -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. +**Git** -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. +Or set git tags directly -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. +```bash +version patch --git +``` -## Contributing -State if you are open to contributions and what your requirements are for accepting them. +**Build** -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. +With the command build the current build date can be output. -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. + +```bash +version build +``` -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. +**Makefile** -## License -For open source projects, say how it is licensed. +```makefile -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +build: + version patch --path $(PROJECT_ROOT)version.json --selector "version" + $(eval VERSION := $(shell cat version.json | jq -r .version)) + $(eval BUILD := $(shell version date)) + + echo "Compiling for every OS and Platform $(VERSION) $(BUILD)" +``` \ No newline at end of file diff --git a/build/version-linux-386 b/build/version-linux-386 new file mode 100755 index 0000000000000000000000000000000000000000..4780fbab1ab2a7bad3d282df2618a890896745d3 Binary files /dev/null and b/build/version-linux-386 differ diff --git a/build/version-linux-amd64 b/build/version-linux-amd64 new file mode 100755 index 0000000000000000000000000000000000000000..04db2b78e489278d9d9234229930f381c5939484 Binary files /dev/null and b/build/version-linux-amd64 differ diff --git a/build/version-linux-arm b/build/version-linux-arm new file mode 100755 index 0000000000000000000000000000000000000000..5b2c580a72728a37085cc4457defe113a6fe8725 Binary files /dev/null and b/build/version-linux-arm differ diff --git a/build/version-linux-arm64 b/build/version-linux-arm64 new file mode 100755 index 0000000000000000000000000000000000000000..c8d8483083f8d8bd0479105debfac91a04938107 Binary files /dev/null and b/build/version-linux-arm64 differ diff --git a/build/version-windows b/build/version-windows new file mode 100755 index 0000000000000000000000000000000000000000..da8e2bdb5b1e9500dacf7f0462fbdc3fe204ac2b Binary files /dev/null and b/build/version-windows differ diff --git a/commandline.go b/commandline.go index c352c0ce3b2eacf02a2d576b5dfeab8c59fd0c62..10e17d95be9ce9e37f51e870e92744fac16ec0e5 100644 --- a/commandline.go +++ b/commandline.go @@ -3,6 +3,7 @@ package main import ( "fmt" "os" + "time" "github.com/jessevdk/go-flags" ) @@ -25,6 +26,8 @@ type commandLineOptions struct { } `command:"patch" description:"increase the patch version"` Init struct { } `command:"init" description:"init new version"` + Date struct { + } `command:"date" description:"print the current date and time in the format YYYYMMDDHHMMSS"` } func increasePatch() (string, error) { @@ -77,6 +80,16 @@ func executeCommand() { var newVersion string switch activeCommand.Name { + case "date": + currentTime := time.Now() + build = currentTime.Format("20060102150405") + + if arguments.Null { + build += string(rune(0)) + } + + fmt.Printf("%s", build) + case "init": newVersion = "0.1.0" case "major": diff --git a/data/index.html b/data/index.html new file mode 100644 index 0000000000000000000000000000000000000000..c4bdc9e8f2f2c4c3b3514ab7a6e87383f438dabb --- /dev/null +++ b/data/index.html @@ -0,0 +1,82 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + + <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" + integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> + + <style> + + body { + background-color: #ffffff; + } + + </style> + <title>Version | Download Portal schukai GmbH</title> +</head> +<body> + + +<div class="d-flex flex-column align-items-center justify-content-center" + style="height:100vh;"> + + <div class="text-center"> + <a href="https://www.schukai.com" class="text-decoration-none text-white text-decoration"><img + src="https://cdn.alvine.io/image/logo/schukai-rot.svg" width="300px"></a> + <br> + + <div class="card mt-5"> + <div class="card-header"> + Version + </div> + <ul class="list-group"> + <li class="list-group-item"><a class="text-decoration-none link-danger" href="./version-linux-386">version-linux-386</a></li> + <li class="list-group-item"><a class="text-decoration-none link-danger" href="./version-linux-amd64">version-linux-amd64</a></li> + <li class="list-group-item"><a class="text-decoration-none link-danger" href="./version-linux-arm">version-linux-arm</a></li> + <li class="list-group-item"><a class="text-decoration-none link-danger" href="./version-linux-arm64">version-linux-arm64</a></li> + <li class="list-group-item"><a class="text-decoration-none link-danger" href="./version-windows">version-windows</a></li> + </ul> + </div> + + <p class="mt-5"> + <a href="https://about.schukai.com/de/impressum/" class="text-decoration-none text-decoration" + style="color:#c10000">Imprint</a></p> + + </div> + + +</div> + + +<!-- +<div class="d-flex flex-column align-items-center justify-content-center" + style="height:100vh;"> + +<div class="d-block"> + +<div><img src="signet.svg" height="10%"></div> +<div> + +</div> +</div> +</div> + + + +<div class="text-center mb-2 fixed-bottom"> + <div class="row"> + <div class="col"> + + </div> + </div> +</div> --> + + +<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" + integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" + crossorigin="anonymous"></script> + +</body> +</html> diff --git a/version b/version index 056189e8d337655b03427edf37e2d198559e0d01..854a0985bde6bacfb49f9d8db3eec79ac0ba8cc8 100755 Binary files a/version and b/version differ diff --git a/version-linux-386 b/version-linux-386 new file mode 100755 index 0000000000000000000000000000000000000000..a8225f7bce7a31e8b6de75b7c622606b86a72923 Binary files /dev/null and b/version-linux-386 differ diff --git a/version-windows b/version-windows new file mode 100755 index 0000000000000000000000000000000000000000..53138a6c2bfce4330c1d06c41f098d46cad83966 Binary files /dev/null and b/version-windows differ diff --git a/version.go b/version.go index 468622bcf0c363ac70e9333e19448fc295740eaf..e761b9e67f95feb018995d9609f7d8b5568e8a52 100644 --- a/version.go +++ b/version.go @@ -241,9 +241,35 @@ func writeVersionToYaml(version string) error { return err } +func writeVersionToGit(version string) error { + + path, err := os.Getwd() + if err != nil { + return err + } + + repo, err := git.PlainOpen(path) + if err != nil { + return err + } + + h, err := repo.Head() + if err != nil { + return err + } + + _, err = repo.CreateTag(version, h.Hash(), &git.CreateTagOptions{ + Message: version, + }) + + return nil +} + func writeVersion(version string) error { - if currentType == "json" { + if arguments.Git { + return writeVersionToGit(version) + } else if currentType == "json" { return writeVersionToJson(version) } else if currentType == "yaml" { return writeVersionToYaml(version) diff --git a/version.json b/version.json new file mode 100644 index 0000000000000000000000000000000000000000..112b446b4a96282923692657cdc272cad702a27b --- /dev/null +++ b/version.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.27" +} \ No newline at end of file