Skip to content

Commit

Permalink
Merge pull request #3 from manifest-cyber/feat-project-structure
Browse files Browse the repository at this point in the history
feat: sbom-convert cli
  • Loading branch information
puerco authored Aug 8, 2023
2 parents cd3278c + 52cb6f5 commit 92ff386
Show file tree
Hide file tree
Showing 36 changed files with 2,633 additions and 345 deletions.
77 changes: 77 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.195.0/containers/go
{
"name": "sbom-convert",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"mounts": [
"source=${localEnv:HOME}/.aws,target=/home/vscode/.aws,type=bind",
"source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,type=bind",
"source=${localEnv:HOME}/.local,target=/home/vscode/.local,type=bind",
"source=${localEnv:HOME}/.config,target=/home/vscode/.config,type=bind",
"source=${localEnv:HOME}/.gitconfig,target=/home/vscode/.gitconfig,type=bind",
"source=${localEnv:HOME}/.zsh_history,target=/home/vscode/.zsh_history,type=bind"
],
"containerEnv": {
"HISTFILE": "/home/vscode/.zsh_history",
"HISTSIZE": "1000000",
"SAVEHIST": "1000000",
"ORG_NAME": "bom-squad"
},
"postCreateCommand": ".devcontainer/post-create.sh",
"customizations": {
"vscode": {
"extensions": [
"redhat.vscode-yaml",
"ms-azuretools.vscode-docker",
"ms-vscode.makefile-tools",
"esbenp.prettier-vscode",
"GitHub.copilot",
"GitHub.copilot-chat",
"GitHub.copilot-labs",
"golang.Go"
],
"settings": {
"editor.formatOnSave": true,
"files.eol": "\n",
"terminal.integrated.defaultProfile.linux": "zsh",
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"go.gopath": "/go",
"go.goroot": "/usr/local/go",
"go.lintTool": "golangci-lint",
"go.lintFlags": ["--fast", "--timeout", "5m"],
"gopls": {
"formatting.gofumpt": true
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
}
},
"remoteUser": "vscode",
"runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],
"workspaceFolder": "/workspace",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind",
"features": {
"ghcr.io/devcontainers/features/go:1": {
"version": "1.20"
},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/common-utils:2": {
"configureZshAsDefaultShell": true
},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/python:1": {},
"ghcr.io/devcontainers/features/node:1": {
"version": "20"
},
"ghcr.io/devcontainers-contrib/features/zsh-plugins:0": {
"plugins": ["docker docker-compose vscode colorize golang github git"]
}
}
}
93 changes: 93 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/env bash

PYTHON_UTILS=("yamllint" "pre-commit")
GITHUB_UTILS=("")
GOLANG_UTILS=("github.com/google/yamlfmt/cmd/yamlfmt@latest" "github.com/goreleaser/goreleaser@latest")
APT_UTILS=("shellcheck" "vim")
NODE_UTILS=("@commitlint/cli" "@commitlint/config-conventional")
set -e

# Install Python tools
if [[ $(python --version) != "" ]]; then
echo ====================================================
echo Installing Python tools...
export PYTHONUSERBASE=/tmp/pip-tmp
export PIP_CACHE_DIR=/tmp/pip-tmp/cache
PIPX_DIR=""
if ! type pipx >/dev/null 2>&1; then
pip3 install --disable-pip-version-check --no-cache-dir --user pipx 2>&1
/tmp/pip-tmp/bin/pipx install --pip-args=--no-cache-dir pipx
PIPX_DIR="/tmp/pip-tmp/bin/"
fi
for util in "${PYTHON_UTILS[@]}"; do
if ! type "${util}" >/dev/null 2>&1; then
"${PIPX_DIR}pipx" install --system-site-packages --pip-args '--no-cache-dir --force-reinstall' "${util}"
else
echo "${util} already installed. Skipping."
fi
done
rm -rf /tmp/pip-tmp
fi

# Install tools
echo ====================================================
echo "Installing tools from Github..."
for util in "${GITHUB_UTILS[@]}"; do
if ! type "${util}" >/dev/null 2>&1; then
curl -s "https://raw.githubusercontent.com/${util}" | bash
echo ""
else
echo "${util} already installed. Skipping."
fi
done

# Install Golang tools
echo ====================================================
echo Installing Golang tools...
for util in "${GOLANG_UTILS[@]}"; do
if ! type "${util}" >/dev/null 2>&1; then
go install "${util}"
else
echo "${util} already installed. Skipping."
fi
done

# Install Node tools
echo ====================================================
echo Installing Node tools...
for util in "${NODE_UTILS[@]}"; do
if ! type "${util}" >/dev/null 2>&1; then
npm install -g "${util}"
else
echo "${util} already installed. Skipping."
fi
done

# Install APT tools
echo ====================================================
echo Installing apt tools...
sudo apt-get update
for util in "${APT_UTILS[@]}"; do
if ! type "${util}" >/dev/null 2>&1; then
sudo apt install -y "${util}"
else
echo "${util} already installed. Skipping."
fi
done

# Update .zshrc
echo ====================================================
echo Updating .zshrc ...
{
printf "setopt appendhistory \nsetopt sharehistory \nsetopt incappendhistory \n"
printf "export GPG_TTY=%s\n" "$(tty)"
} >>/home/vscode/.zshrc

# Other
echo ====================================================
echo Finallizing ...
pre-commit install
pre-commit run --all-files

# Done
echo ====================================================
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
55 changes: 55 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This is a comment.
# Each line is a file pattern followed by one or more owners.
#
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# @global-owner1 and @global-owner2 will be requested for
# review when someone opens a pull request.
# * @global-owner1 @global-owner2
#
# Order is important; the last matching pattern takes the most
# precedence. When someone opens a pull request that only
# modifies JS files, only @js-owner and not the global
# owner(s) will be requested for a review.
# *.js @js-owner #This is an inline comment.
#
# You can also use email addresses if you prefer. They'll be
# used to look up users just like we do for commit author
# emails.
# *.go [email protected]
#
# Teams can be specified as code owners as well. Teams should
# be identified in the format @org/team-name. Teams must have
# explicit write access to the repository. In this example,
# the octocats team in the octo-org organization owns all .txt files.
# *.txt @octo-org/octocats
#
# In this example, @doctocat owns any files in the build/logs
# directory at the root of the repository and any of its
# subdirectories.
# /build/logs/ @doctocat
#
# The `docs/*` pattern will match files like
# `docs/getting-started.md` but not further nested files like
# `docs/build-app/troubleshooting.md`.
# docs/* [email protected]
#
# In this example, @octocat owns any file in an apps directory
# anywhere in your repository.
# apps/ @octocat
#
# In this example, @doctocat owns any file in the `/docs`
# directory in the root of your repository and any of its
# subdirectories.
# /docs/ @doctocat
#
# In this example, any change inside the `/scripts` directory
# will require approval from @doctocat or @octocat.
# /scripts/ @doctocat @octocat
#
# In this example, @octocat owns any file in the `/apps`
# directory in the root of your repository except for the `/apps/github`
# subdirectory, as its owners are left empty.
# /apps/ @octocat
# /apps/github
@manifestori @puerco @houdini91
83 changes: 83 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: release

on:
workflow_dispatch:
inputs:
release-as:
description: "semver type of the release"
type: choice
options:
- patch
- minor
- major
default: none
required: true
prerelease:
description: "release as prerelease"
type: boolean
required: true
default: true
prerelease-suffix:
description: suffix for your prerelease versions
type: string
required: false
default: beta

permissions: write-all
jobs:
release:
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
name: release
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Setup Go
uses: actions/setup-go@v3
with:
cache: true
go-version: ">=1.20.6"
- uses: actions/cache@v3
with:
path: |
./dist/*.deb
./dist/*.rpm
./dist/*.apk
key: ${{ github.ref }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Fetch tags
run: git fetch --force --tags
- name: Bump version and push tag
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: ${{ inputs.release-as }}
PRERELEASE: ${{ inputs.prerelease }}
PRERELEASE_SUFFIX: ${{ inputs.prerelease-suffix }}
VERBOSE: true
DRY_RUN: false
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
ORG_NAME: ${{ github.repository_owner }}
- name: Upload assets
uses: actions/upload-artifact@v3
with:
name: ${{ github.repository_owner }}
path: dist/*
Loading

0 comments on commit 92ff386

Please sign in to comment.