Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

Commit

Permalink
CI/CD scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Weiss committed Apr 15, 2018
1 parent 4e7a842 commit 0f05d4f
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 24 deletions.
25 changes: 25 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: 2
jobs:
build:
working_directory: /go/src/github.com/opencontrol/oscalkit
docker:
- image: circleci/golang:1.10
steps:
- checkout
- restore_cache:
keys:
- v1-pkg-cache
- setup_remote_docker:
docker_layer_caching: true
- run: sudo apt-get install -y rpm
- run: docker login -u $HUB_USERNAME -p $HUB_PASSWORD
- deploy:
name: goreleaser
command: |
if [[ -n ${CIRCLE_TAG} ]]; then
curl -sL https://git.io/goreleaser | bash
fi
deployment:
trigger_tag:
tag: /.*/
21 changes: 20 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,26 @@ nfpm:
homepage: https://github.com/opencontrol/oscalkit
license: CC0 1.0
dependencies:
- xmllint
- libxml2-utils
formats:
- deb
- rpm

dockers:
- image: opencontrolorg/oscalkit
dockerfile: Dockerfile.release
tag_templates:
- "{{ .Version }}"
- latest

brew:
name: oscalkit
github:
owner: opencontrol
name: homebrew-oscalkit
commit_author:
name: OpenControl
email: dev@open-control.org
homepage: https://github.com/opencontrol/oscalkit
dependencies:
- libxml2
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

FROM golang:1.10-alpine AS builder
WORKDIR /go/src/github.com/opencontrol/oscalkit/cli
WORKDIR /go/src/github.com/opencontrol/oscalkit
COPY . .
RUN CGO_ENABLED=0 go install -v -ldflags="-s -w"
WORKDIR /go/src/github.com/opencontrol/oscalkit/cli
RUN CGO_ENABLED=0 go build -o oscalkit -v -ldflags="-s -w"

FROM alpine:3.7
RUN apk --no-cache add ca-certificates libxml2-utils
WORKDIR /oscalkit
COPY --from=builder /go/bin/oscalkit /oscalkit-linux-x86_64
COPY --from=builder /go/src/github.com/opencontrol/oscalkit/cli/oscalkit /oscalkit-linux-x86_64
RUN ln -s /oscalkit-linux-x86_64 /usr/local/bin/oscalkit
ENTRYPOINT ["oscalkit"]
3 changes: 3 additions & 0 deletions Dockerfile.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM alpine:3.7
RUN apk --no-cache add ca-certificates libxml2-utils
ENTRYPOINT ["/oscalkit"]
38 changes: 18 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
# oscalkit

[![GoDoc](https://godoc.org/github.com/opencontrol/oscalkit?status.svg)](https://godoc.org/github.com/opencontrol/oscalkit)
[![CircleCI](https://circleci.com/gh/opencontrol/oscalkit.svg?style=svg)](https://circleci.com/gh/opencontrol/oscalkit) [![GoDoc](https://godoc.org/github.com/opencontrol/oscalkit?status.svg)](https://godoc.org/github.com/opencontrol/oscalkit)

> In development
Barebones Go SDK and CLI tool for parsing OSCAL, translating between OSCAL-formatted XML and JSON and for converting from OpenControl projects in to OSCAL.

## Installing

You can download the appropriate oscalkit command-line utility for your system from the [GitHub Releases](https://github.com/opencontrol/oscalkit/releases) page and run it from your local machine directly. For easier execution, you can include it in your `$PATH` environment variable as follows:
You can download the appropriate oscalkit command-line utility for your system from the [GitHub Releases](https://github.com/opencontrol/oscalkit/releases) page and run it from your local machine directly. For easier execution, you can include it in your `$PATH` environment variable. If you prefer, you can download and install via the included RPM/Deb packages on Linux or Homebrew recipe on macOS. A [Docker image](https://hub.docker.com/r/opencontrolorg/oscalkit/) is also made available on Docker Hub.

### Windows
### Homebrew

> XML validation requires the `xmllint` tool which is not included with Windows. Installation instructions for Windows can be found [here](https://stackoverflow.com/a/21227833).
Run the following commands in a PowerShell console

```powershell
$newPath = "<path_to_oscalkit.exe>;" + [Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable("PATH", $newPath, [EnvironmentVariableTarget]::Machine)
```

### macOS/Linux

Add the following line to to the .profile file in your home directory (~/.profile)

$ PATH=$PATH:/<path_to_oscalkit>
$ export PATH
$ brew tap opencontrol/homebrew-oscalkit
$ brew install oscalkit

### Docker

> Running the oscalkit Docker container requires either bind-mounting the directory containing your source files or passing file contents in to the command via stdin.
$ docker pull opencontrolorg/oscalkit:latest
$ docker pull opencontrolorg/oscalkit:<version>
$ docker run -it --rm -v $PWD:/data -w /data opencontrolorg/oscalkit convert oscal-core.xml

or via stdin:
Expand Down Expand Up @@ -172,3 +158,15 @@ Compile for macOS:
Compile for Windows:

$ GOOS=windows GOARCH=amd64 make

### Releasing

The [GoReleaser](https://goreleaser.com/) tool is used to publish `oscalkit` to GitHub Releases. The following release artifacts are currently supported:

- OSX binary
- Linux binary
- Windows binary
- Docker Image
- RPM package
- Deb package
- Homebrew recipe

0 comments on commit 0f05d4f

Please sign in to comment.