This Go application provides a simple version bumping service. It includes two primary functionalities: bumping the version of a given semantic version string and retrieving the current version of the application. The application leverages the go-semver
package for semantic version parsing and operations, and the gorilla/mux
package for routing HTTP requests.
- Version Bumping: POST requests to
/bump
will increment the specified version according to the specified mode (major, minor, or patch). - Get Current Version: GET requests to
/version
will return the current version of the application.
- Go programming language
- External Go packages:
github.com/adamwasila/go-semver
github.com/gorilla/mux
To run this application, you need to have Go installed on your system. After installing Go, you can set up the project by following these steps:
- Clone the repository to your local machine.
- Navigate to the project directory.
- Run
go get
to install the required dependencies.
To start the server, run the following command in the terminal from the project directory:
go run main.go
To run the application using Docker, follow these steps:
- Build the Docker image:
make docker-build
- Run the Docker container:
make docker-run
make test
: Run tests.make build
: Build the application.make clean
: Clean the build directory.make run ARGS="<args>"
: Run the application with specified arguments.make docker-build
: Build the Docker image.make docker-run
: Run the Docker container.make docker-push
: Push the Docker image to a registry.
The Dockerfile uses a multi-stage build process:
- The first stage uses
golang:1.19
to build the application. - The second stage uses
alpine:3.14
to create a lightweight container.
-
Bump Version
- URL:
/bump
- Method:
POST
- Body:
{ "version": "current version", "currentVersion": "current version to bump", "class": "major/minor/patch" }
- Response:
{ "statusCode": "0 for success, error codes for failure", "newVersion": "bumped version string" }
- URL:
-
Get Current Version
- URL:
/version
- Method:
GET
- Response:
{ "version": "current application version" }
- URL:
Contributions to this project are welcome. Please ensure that you follow the established code style and add unit tests for new functionalities. For major changes, please open an issue first to discuss what you would like to change.
Note: This README provides a basic guide to using and contributing to this Go application. For more detailed documentation, refer to the comments within the code.