Skip to content

Commit

Permalink
feat: add goreleaser configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaferraro committed Feb 27, 2020
1 parent 568e80f commit fff6ac3
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ build/_output
target/

.envrc

/dist
41 changes: 41 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
- go mod download
builds:
- env:
- CGO_ENABLED=0
hooks:
pre: ./hack/before_release.sh {{ .Tag }}
main: ./cmd/manager/main.go
binary: yaks
ldflags: -X github.com/jboss-fuse/yaks/version.Version={{ .Tag }}
goos:
- linux
- darwin
- windows
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
dockers:
- dockerfile: ./build/Dockerfile.release
extra_files:
- build
image_templates:
- 'docker.io/yaks/yaks:{{ .Tag }}'
- 'docker.io/yaks/yaks:v{{ .Major }}.{{ .Minor }}'
- 'docker.io/yaks/yaks:latest'
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

IMAGE_NAME := docker.io/yaks/yaks
VERSION := 0.0.2
VERSION := devel

GOLDFLAGS += -X main.GitCommit=$(GIT_COMMIT)
GOFLAGS = -ldflags "$(GOLDFLAGS)" -gcflags=-trimpath=$(GO_PATH) -asmflags=-trimpath=$(GO_PATH)
Expand Down
34 changes: 34 additions & 0 deletions build/Dockerfile.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This is the same of the other Dockerfile but with the binary built by goreleaser
FROM fabric8/s2i-java:3.0-java8

ENV OPERATOR=/usr/local/bin/yaks \
OPERATOR_ARGS=operator \
USER_UID=1001 \
USER_NAME=yaks \
HOME=/root \
APP_DIR=/deployments/data/yaks-testing \
APP_LIBS=/deployments/artifacts/m2

# install operator binary
COPY yaks ${OPERATOR}

COPY build/bin /usr/local/bin

# TODO create a more efficient way to manage dependencies than to hardcode them
COPY build/_maven_repository ${APP_LIBS}

# add YAKS runtime
COPY build/_maven_project/yaks-testing ${APP_DIR}

USER 0
RUN /usr/local/bin/user_setup

RUN chgrp -R 0 ${APP_LIBS} && \
chmod -R g=u ${APP_LIBS}

RUN chgrp -R 0 ${APP_DIR} && \
chmod -R g=u ${APP_DIR}

# Let's not use ENTRYPOINT so we can override libs in the base image

USER ${USER_UID}
2 changes: 1 addition & 1 deletion deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
serviceAccountName: yaks
containers:
- name: yaks
image: yaks/yaks:0.0.2
image: yaks/yaks:devel
command:
- yaks
- operator
Expand Down
2 changes: 1 addition & 1 deletion deploy/resources.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module github.com/jboss-fuse/yaks

require (
github.com/NYTimes/gziphandler v1.0.1 // indirect
github.com/fatih/color v1.7.0
github.com/go-logr/logr v0.1.0
github.com/mattn/go-colorable v0.1.2 // indirect
Expand Down
31 changes: 31 additions & 0 deletions hack/before_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

location=$(dirname $0)

if [ "$#" -ne 1 ]; then
echo "usage: $0 version"
exit 1
fi

cd $location/..

for f in ./deploy/*.yaml; do
sed -i "s/image:.*yaks\/yaks.*$/image: yaks\/yaks:$1/g" $f
done

make clean build-resources package-artifacts-no-test
1 change: 1 addition & 0 deletions pkg/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func NewYaksCommand(ctx context.Context) (*cobra.Command, error) {
cmd.AddCommand(newCmdTest(&options))
cmd.AddCommand(newCmdInstall(&options))
cmd.AddCommand(newCmdOperator(&options))
cmd.AddCommand(newCmdVersion(&options))

return &cmd, nil
}
49 changes: 49 additions & 0 deletions pkg/cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package cmd

import (
"fmt"

"github.com/jboss-fuse/yaks/version"
"github.com/spf13/cobra"
)

func newCmdVersion(rootCmdOptions *RootCmdOptions) *cobra.Command {
options := versionCmdOptions{
RootCmdOptions: rootCmdOptions,
}

cmd := cobra.Command{
PersistentPreRunE: options.preRun,
Use: "version",
Short: "Return version information",
RunE: options.run,
}

return &cmd
}

type versionCmdOptions struct {
*RootCmdOptions
}

func (o *versionCmdOptions) run(cmd *cobra.Command, _ []string) error {
_, err := fmt.Fprintln(cmd.OutOrStdout(), version.Version)
return err
}
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package version

var (
Version = "0.0.2"
Version = "devel"
)

0 comments on commit fff6ac3

Please sign in to comment.