Skip to content

Commit bdc7812

Browse files
authored
Prepare for release (#37)
* Prepare for release Added LICENSE, set version and configured GoReleaser/Docker * Updated LICENSE
1 parent fb3056d commit bdc7812

File tree

9 files changed

+191
-1
lines changed

9 files changed

+191
-1
lines changed

.cirrus.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,38 @@ task:
1111
cleanup_script:
1212
- tart list
1313
- rm -rf ~/.tart/vms/orchard-*
14+
15+
task:
16+
name: Release Binaries
17+
only_if: $CIRRUS_TAG != ''
18+
depends_on:
19+
- Lint
20+
- Test (macOS)
21+
env:
22+
GITHUB_TOKEN: ENCRYPTED[!98ace8259c6024da912c14d5a3c5c6aac186890a8d4819fad78f3e0c41a4e0cd3a2537dd6e91493952fb056fa434be7c!]
23+
container:
24+
image: goreleaser/goreleaser:latest
25+
cpu: 4
26+
memory: 12G
27+
release_script: goreleaser
28+
29+
30+
docker_builder:
31+
name: Release Docker Image
32+
only_if: $CIRRUS_TAG != ''
33+
depends_on:
34+
- Lint
35+
- Test (macOS)
36+
env:
37+
GITHUB_TOKEN: ENCRYPTED[!82ed873afdf627284305afef4958c85a8f73127b09978a9786ac521559630ea6c9a5ab6e7f8315abf9ead09b6eff6eae!]
38+
login_script:
39+
- echo $GITHUB_TOKEN | docker login ghcr.io -u fkorotkov --password-stdin
40+
setup_script:
41+
- docker buildx create --name multibuilder
42+
- docker buildx use multibuilder
43+
- docker buildx inspect --bootstrap
44+
deploy_script: |
45+
docker buildx build --push --platform linux/amd64,linux/arm64 \
46+
--tag ghcr.io/cirruslabs/orchard:$CIRRUS_TAG \
47+
--tag ghcr.io/cirruslabs/orchard:latest \
48+
.

.goreleaser.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
project_name: orchard
2+
3+
before:
4+
hooks:
5+
- go mod download
6+
7+
builds:
8+
- main: cmd/orchard/main.go
9+
ldflags: >
10+
-X github.com/cirruslabs/orchard/internal/version.Version={{.Version}}
11+
-X github.com/cirruslabs/orchard/internal/version.Commit={{.ShortCommit}}
12+
env:
13+
- CGO_ENABLED=0
14+
goos:
15+
- linux
16+
- darwin
17+
goarch:
18+
- amd64
19+
- arm64
20+
21+
archives:
22+
- id: binary
23+
format: binary
24+
name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
25+
- id: regular
26+
name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
27+
28+
release:
29+
prerelease: auto
30+
31+
brews:
32+
- name: orchard
33+
ids:
34+
- regular
35+
tap:
36+
owner: cirruslabs
37+
name: homebrew-cli
38+
caveats: See the Github repository for more information
39+
homepage: https://github.com/cirruslabs/orchard
40+
description: Orchestrator for running Tart Virtual Machines on a cluster of Apple Silicon devices
41+
skip_upload: auto

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM goreleaser/goreleaser:latest as builder
2+
3+
WORKDIR /tmp/orchard
4+
ADD . /tmp/orchard/
5+
6+
RUN goreleaser build --single-target --snapshot --timeout 60m
7+
8+
FROM gcr.io/distroless/base
9+
10+
LABEL org.opencontainers.image.source=https://github.com/cirruslabs/orchard
11+
ENV ORCHARD_HOME=/data
12+
EXPOSE 6120
13+
14+
COPY --from=builder /tmp/orchard/dist/orchard_linux_*/orchard /bin/orchard
15+
16+
CMD ["/bin/orchard"]

LICENSE

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Fair Source License, version 0.9
2+
3+
Copyright (C) 2023 Cirrus Labs, Inc.
4+
5+
Licensor: Cirrus Labs, Inc.
6+
7+
Software: Orchard
8+
9+
Use Limitation: 4 users. User is defined as a device running macOS operating system.
10+
The Use Limitation does not apply to devices used by a single individual.
11+
12+
License Grant. Licensor hereby grants to each recipient of the
13+
Software ("you") a non-exclusive, non-transferable, royalty-free and
14+
fully-paid-up license, under all of the Licensor's copyright and
15+
patent rights, to use, copy, distribute, prepare derivative works of,
16+
publicly perform and display the Software, subject to the Use
17+
Limitation and the conditions set forth below.
18+
19+
Use Limitation. The license granted above allows use by up to the
20+
number of users per entity set forth above (the "Use Limitation"). For
21+
determining the number of users, "you" includes all affiliates,
22+
meaning legal entities controlling, controlled by, or under common
23+
control with you. If you exceed the Use Limitation, your use is
24+
subject to payment of Licensor's then-current list price for licenses.
25+
26+
Conditions. Redistribution in source code or other forms must include
27+
a copy of this license document to be provided in a reasonable
28+
manner. Any redistribution of the Software is only allowed subject to
29+
this license.
30+
31+
Trademarks. This license does not grant you any right in the
32+
trademarks, service marks, brand names or logos of Licensor.
33+
34+
DISCLAIMER. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OR
35+
CONDITION, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES
36+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
37+
NONINFRINGEMENT. LICENSORS HEREBY DISCLAIM ALL LIABILITY, WHETHER IN
38+
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39+
CONNECTION WITH THE SOFTWARE.
40+
41+
Termination. If you violate the terms of this license, your rights
42+
will terminate automatically and will not be reinstated without the
43+
prior written consent of Licensor. Any such termination will not
44+
affect the right of others who may have received copies of the
45+
Software from you.

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ require (
1414
github.com/google/uuid v1.3.0
1515
github.com/gosuri/uitable v0.0.4
1616
github.com/hashicorp/go-multierror v1.1.1
17+
github.com/hashicorp/go-version v1.6.0
1718
github.com/manifoldco/promptui v0.9.0
1819
github.com/mitchellh/go-grpc-net-conn v0.0.0-20200427190222-eb030e4876f0
1920
github.com/spf13/cobra v1.6.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/U
9797
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
9898
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
9999
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
100+
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
101+
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
100102
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
101103
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
102104
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=

internal/command/controller/run.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,32 @@ import (
55
"errors"
66
"fmt"
77
"github.com/cirruslabs/orchard/internal/controller"
8+
"github.com/cirruslabs/orchard/internal/netconstants"
89
"github.com/spf13/cobra"
910
"go.uber.org/zap"
11+
"os"
12+
"strconv"
1013
)
1114

1215
var ErrRunFailed = errors.New("failed to run controller")
1316

17+
var address string
18+
1419
func newRunCommand() *cobra.Command {
15-
return &cobra.Command{
20+
cmd := &cobra.Command{
1621
Use: "run",
1722
Short: "Run the controller",
1823
RunE: runController,
1924
}
25+
26+
port := os.Getenv("PORT")
27+
if port == "" {
28+
port = strconv.FormatInt(netconstants.DefaultControllerPort, 10)
29+
}
30+
31+
cmd.PersistentFlags().StringVarP(&address, "listen", "l", fmt.Sprintf(":%s", port), "address to listen on")
32+
33+
return cmd
2034
}
2135

2236
func runController(cmd *cobra.Command, args []string) (err error) {
@@ -53,6 +67,7 @@ func runController(cmd *cobra.Command, args []string) (err error) {
5367
}
5468

5569
controller, err := controller.New(
70+
controller.WithListenAddr(address),
5671
controller.WithDataDir(dataDir),
5772
controller.WithLogger(logger),
5873
controller.WithTLSConfig(&tls.Config{

internal/command/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/cirruslabs/orchard/internal/command/portforward"
1212
"github.com/cirruslabs/orchard/internal/command/stop"
1313
"github.com/cirruslabs/orchard/internal/command/worker"
14+
"github.com/cirruslabs/orchard/internal/version"
1415
"github.com/spf13/cobra"
1516
)
1617

@@ -19,6 +20,7 @@ func NewRootCmd() *cobra.Command {
1920
Use: "orchard",
2021
SilenceUsage: true,
2122
SilenceErrors: true,
23+
Version: version.FullVersion,
2224
}
2325

2426
addGroupedCommands(command, "Working With Resources:",

internal/version/version.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package version
2+
3+
import (
4+
"fmt"
5+
goversion "github.com/hashicorp/go-version"
6+
"runtime/debug"
7+
)
8+
9+
var (
10+
Version = "unknown"
11+
Commit = "unknown"
12+
FullVersion = ""
13+
)
14+
15+
//nolint:gochecknoinits
16+
func init() {
17+
if Version == "unknown" {
18+
info, ok := debug.ReadBuildInfo()
19+
if ok {
20+
// We parse the version here for two reasons:
21+
// * to weed out the "(devel)" version and fallback to "unknown" instead
22+
// (see https://github.com/golang/go/issues/29228 for details on when this might happen)
23+
// * to remove the "v" prefix from the BuildInfo's version (e.g. "v0.7.0") and thus be consistent
24+
// with the binary builds, where the version string would be "0.7.0" instead
25+
semver, err := goversion.NewSemver(info.Main.Version)
26+
if err == nil {
27+
Version = semver.String()
28+
}
29+
}
30+
}
31+
32+
FullVersion = fmt.Sprintf("%s-%s", Version, Commit)
33+
}

0 commit comments

Comments
 (0)