Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 42 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker Build
name: Build

on:
pull_request:
Expand All @@ -12,9 +12,48 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Go environment
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: "go.mod"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0
with:
version: latest
args: build --single-target --snapshot --clean --output ./version
env:
GORELEASER_CURRENT_TAG: ${{ steps.draft_release.outputs.tag_name }}
- name: Version test
id: version
run: echo "output=$(./version bump 0.1.0)" >> "$GITHUB_OUTPUT"
- name: Failed
if: ${{ steps.version.outputs.output != '0.1.1' }}
run: |-
exit 1
- name: Success
if: ${{ steps.version.outputs.output == '0.1.1' }}
run: |-
exit 0

docker-build:
name: docker build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

- name: Build Docker image
run: VERSION=$(git rev-parse --short HEAD) make docker-build
run: VERSION=$(git rev-parse --short HEAD) make docker-build docker-build-x-platform
- name: Version test
id: version
run: |-
echo "output=$(docker run ghcr.io/version-cli/version:latest bump 0.1.0)" >> "$GITHUB_OUTPUT"
- name: Failed
if: ${{ steps.version.outputs.output != '0.1.1' }}
run: |-
exit 1
- name: Success
if: ${{ steps.version.outputs.output == '0.1.1' }}
run: |-
exit 0
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.idea/

dist/

# Ignore version binaries in root project-folder
/version*
22 changes: 14 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,29 @@ build: validate-go-version clean $(BINARY)
$(BINARY):
CGO_ENABLED=0 $(GO) build -a -installsuffix cgo -ldflags="-X github.com/version-cli/version/cmd.VERSION=${VERSION}" -o $@

DOCKER_BUILD_PLATFORM ?= linux/amd64,linux/arm64,linux/ppc64le,linux/arm/v7
DOCKER_BUILDX_ARGS_LIST ?= \

DOCKER_BUILDX_ARGS_LIST ?= \
CREATED=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ') \
REVISION=$(shell git rev-parse --short HEAD) \
VERSION=${VERSION}
DOCKER_BUILDX_ARGS := $(addprefix --build-arg ,$(DOCKER_BUILDX_ARGS_LIST))
DOCKER_BUILDX_TAGS := -t $(REPOSITORY):latest -t $(REPOSITORY):${VERSION}
DOCKER_BUILDX := docker buildx build ${DOCKER_BUILDX_ARGS} --platform ${DOCKER_BUILD_PLATFORM} ${DOCKER_BUILDX_TAGS}
DOCKER_BUILDX_PUSH := $(DOCKER_BUILDX) --push
DOCKER_BUILDX_ARGS := $(addprefix --build-arg ,$(DOCKER_BUILDX_ARGS_LIST))
DOCKER_BUILDX_TAGS := -t $(REPOSITORY):latest -t $(REPOSITORY):${VERSION}
DOCKER_BUILDX_CACHE := --cache-from=type=gha --cache-to=type=gha
DOCKER_BUILDX := docker buildx build ${DOCKER_BUILDX_ARGS} ${DOCKER_BUILDX_CACHE} ${DOCKER_BUILDX_TAGS} .
DOCKER_BUILDX_X_PLATFORM := ${DOCKER_BUILDX} --platform linux/amd64,linux/arm64,linux/ppc64le,linux/arm/v7
DOCKER_BUILDX_PUSH := $(DOCKER_BUILDX_X_PLATFORM) --push

.PHONY: docker-build
docker-build:
$(DOCKER_BUILDX) .
$(DOCKER_BUILDX) --load

.PHONY: docker-build-x-platform
docker-build-x-platform:
$(DOCKER_BUILDX_X_PLATFORM)

.PHONY: docker-push
docker-push:
$(DOCKER_BUILDX_PUSH) .
$(DOCKER_BUILDX_PUSH)

.PHONY: validate-go-version
validate-go-version:
Expand Down
2 changes: 0 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ func init() {
rootCmd.PersistentFlags().BoolVarP(&minor, "minor", "m", false, "Set version level to minor")
rootCmd.PersistentFlags().BoolVarP(&patch, "patch", "p", true, "Set version level to patch")
rootCmd.MarkFlagsMutuallyExclusive("major", "minor", "patch")
rootCmd.MarkFlagsOneRequired("major", "minor", "patch")
rootCmd.PersistentFlags().BoolVarP(&useSemver, "semver", "S", true, "Use semver as the versioning type")
rootCmd.MarkFlagsOneRequired("semver")
}

func setVersionLevel(_ *cobra.Command, _ []string) {
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ github.com/docker/docker-credential-helpers v0.8.0 h1:YQFtbBQb4VrpoPxhFuzEBPQ9E1
github.com/docker/docker-credential-helpers v0.8.0/go.mod h1:UGFXcuoQ5TxPiB54nHOZ32AWRqQdECoh/Mg0AlEYb40=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-containerregistry v0.17.0 h1:5p+zYs/R4VGHkhyvgWurWrpJ2hW4Vv9fQI+GzdcwXLk=
github.com/google/go-containerregistry v0.17.0/go.mod h1:u0qB2l7mvtWVR5kNcbFIhFY1hLbf8eeGapA+vbFDCtQ=
github.com/google/go-containerregistry v0.19.0 h1:uIsMRBV7m/HDkDxE/nXMnv1q+lOOSPlQ/ywc5JbB8Ic=
github.com/google/go-containerregistry v0.19.0/go.mod h1:u0qB2l7mvtWVR5kNcbFIhFY1hLbf8eeGapA+vbFDCtQ=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
Expand Down
12 changes: 0 additions & 12 deletions version.iml

This file was deleted.