Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Updated Release Workflows #17

Merged
merged 1 commit into from
Oct 25, 2022
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
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ updates:
schedule:
interval: daily
time: "05:00"
timezone: UTC
timezone: US/Pacific
- package-ecosystem: gomod
directory: /
schedule:
interval: daily
time: "05:00"
timezone: UTC
timezone: US/Pacific
168 changes: 34 additions & 134 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,150 +1,50 @@
name: gardener Release
name: Release

on:
push:
tags:
- 'v*'

permissions:
contents: write

jobs:
release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.upload_url.outputs.upload_url }}

steps:
- name: Checkout code
-
name: Checkout
uses: actions/checkout@v2

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
This release has the following changes:
- README Updates.
draft: false
prerelease: false

- name: Fix Upload URL
id: upload_url
run: echo ::set-output name=upload_url::$(echo "${{ steps.create_release.outputs.upload_url }}" | cut -d"{" -f1)

- name: Echo upload url
run: echo "${{ steps.upload_url.outputs.upload_url }}"

build:
needs: release
strategy:
matrix:
os: ["darwin", "freebsd", "linux", "netbsd", "openbsd", "windows"]
arch: ["amd64", "arm64", "arm"]

env:
UPLOAD_URL: ${{ needs.release.outputs.upload_url }}

name: Build and Upload Assets
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Go
fetch-depth: 0
# -
# name: Install Snapcraft
# uses: samuelmeuli/action-snapcraft@v1
# with:
# snapcraft_token: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.16'

- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/}

- name: Generate SBOM
uses: CycloneDX/gh-gomod-generate-sbom@v0.3.0
go-version: 1.19
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
include-stdlib: true
json: true
output: sbom.json
resolve-licenses: true
version: "^v0"

- name: Build amd64 Assets
if: matrix.arch == 'amd64'
run: |
echo "${{ matrix.os }} ${{ matrix.arch }}"
env GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o $FILE github.com/devops-kung-fu/gardener
env:
FILE: build/gardener-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}

- name: Build arm64 Assets
if: matrix.arch == 'arm64' && matrix.os == 'linux'
run: |
echo "${{ matrix.os }} ${{ matrix.arch }}"
env GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o $FILE github.com/devops-kung-fu/gardener
env:
FILE: build/gardener-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}

- name: Build arm Assets
if: matrix.arch == 'arm' && (matrix.os == 'freebsd' || matrix.os == 'netbsd' || matrix.os == 'openbsd')
run: |
echo "${{ matrix.os }} ${{ matrix.arch }}"
env GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o $FILE github.com/devops-kung-fu/gardener
env:
FILE: build/gardener-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}

- name: Upload SBoM
run: |
curl \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: $(file -b --mime-type $FILE)" \
--data-binary @$FILE \
"$UPLOAD_URL?name=$(basename $FILE)"
env:
FILE: sbom.json

- name: Upload amd64 Non-Windows
if: matrix.os != 'windows' && matrix.arch == 'amd64'
run: |
curl \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: $(file -b --mime-type $FILE)" \
--data-binary @$FILE \
"$UPLOAD_URL?name=$(basename $FILE)"
env:
FILE: build/gardener-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}

- name: Upload amd64 Windows
if: matrix.os == 'windows' && matrix.arch == 'amd64'
run: |
curl \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: $(file -b --mime-type $FILE)" \
--data-binary @$FILE \
"$UPLOAD_URL?name=$(basename $FILE)"
env:
FILE: build/gardener-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}.exe

- name: Upload arm64
if: matrix.os == 'linux' && matrix.arch == 'arm64'
run: |
curl \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: $(file -b --mime-type $FILE)" \
--data-binary @$FILE \
"$UPLOAD_URL?name=$(basename $FILE)"
env:
FILE: build/gardener-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}
distribution: goreleaser
version: ${{ env.GITHUB_REF_NAME }}
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
-
name: Generate SBOM
uses: anchore/sbom-action@v0
with:
artifact-name: bomber.cyclonedx.json
path: .
-
name: Release SBOM
uses: anchore/sbom-action/publish-sbom@v0
with:
sbom-artifact-match: ".*\\.cyclonedx.json$"

- name: Upload arm
if: (matrix.os == 'freebsd' || matrix.os == 'netbsd' || matrix.os == 'openbsd') && matrix.arch == 'arm'
run: |
curl \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: $(file -b --mime-type $FILE)" \
--data-binary @$FILE \
"$UPLOAD_URL?name=$(basename $FILE)"
env:
FILE: build/gardener-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}
43 changes: 43 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
project_name: gardener

builds:
-
binary: bomber
goos:
- darwin
- linux
- windows
goarch:
- amd64
- arm64

release:
prerelease: auto

universal_binaries:
- replace: true

brews:
-
name: bomber
homepage: "https://github.com/devops-kung-fu/gardener"
tap:
owner: devops-kung-fu
name: homebrew-tap
commit_author:
name: djschleen
email: djschleen@gmail.com

checksum:
name_template: 'checksums.txt'

nfpms:
-
maintainer: DevOps Kung Fu Mafia <admin@dkfm.io>
description: A utility that renders PlantUML diagram source in Markdown image tags.
homepage: https://github.com/devops-kung-fu/gardener
license: MPL
formats:
- deb
- rpm

9 changes: 4 additions & 5 deletions .hookz.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version: 2.4.0
sources:
- source: github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@latest
- source: github.com/devops-kung-fu/lucha@latest
- source: github.com/anchore/syft/cmd/syft@latest
- source: github.com/devops-kung-fu/hinge@latest
- source: github.com/kisielk/errcheck@latest
- source: golang.org/x/lint/golint@latest
Expand Down Expand Up @@ -42,9 +41,9 @@
- name: "go: Test coverage"
exec: go
args: ["tool", "cover", "-func=coverage.out"]
- name: "cyclone-dx: Generate a Software Bill of Materials (SBoM)"
exec: cyclonedx-gomod
args: ["app", "-json", "-output", "gardener-sbom.json"]
- name: "syft: Generate a Software Bill of Materials (SBoM)"
exec: syft
args: [".", "-o", "cyclonedx-json=sbom/gardener.cyclonedx.json"]
- name: "git: Add all changed files during the pre-commit stage"
exec: git
args: ["add", "."]
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ help: ## This help

.DEFAULT_GOAL := help


title:
@echo "gardener Makefile"
@echo "-----------------"

build: ## Builds the application
go get -u ./...
go mod tidy
go build

test: ## Runs tests and coverage
go test -v -coverprofile=coverage.out ./... && go tool cover -func=coverage.out

install: build ## Builds an executable local version of gardener and puts in in /usr/local/bin
sudo chmod +x gardener
sudo mv hookz /usr/local/bin

all: title build test ## Makes all targets
check: build ## Tests the pre-commit hooks if they exist
hookz reset --verbose --debug --verbose-output
. .git/hooks/pre-commit

all: title build test ## Makes all targets
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,31 @@ At [DKFM](https://github.com/devops-kung-fu), when we develop PlantUML documents

## Installation

To install ```gardener```, [download the latest release](https://github.com/devops-kung-fu/gardener/releases) , make is executable, rename it to ```gardener``` and toss it in your ```/usr/local/bin``` directory for Linux, or on your path for other operating systems.
### Mac

Linux Example:
You can use [Homebrew](https://brew.sh) to install ```gardener``` using the following:

``` bash
brew tap devops-kung-fu/homebrew-tap
brew install devops-kung-fu/homebrew-tap/gardener
```

If you do not have Homebrew, you can still [download the latest release](https://github.com/devops-kung-fu/hookz/releases) (ex: ```gardener_1.0.1_darwin_all.tar.gz```), extract the files from the archive, and use the ```gardener``` binary.

If you wish, you can move the ```gardener``` binary to your ```/usr/local/bin``` directory or anywhere on your path.

### Linux

To install ```gardener```, [download the latest release](https://github.com/devops-kung-fu/hookz/releases) for your platform and install locally. For example, install ```gardener``` on Ubuntu:

```bash
sudo chmod +x gardener-1.0.0-linux-amd64
sudo mv gardener-1.0.0-linux-amd64 /usr/local/bin/gardener
dpkg -i gardener_1.0.1_linux_arm64.deb
```

### Windows

To install ```gardener``` on Windows [download the latest release](https://github.com/devops-kung-fu/hookz/releases), extract, put somewhere on your PATH, and use.

## File Support

```gardener``` will process the following PlantUML and Markdown extensions:
Expand Down Expand Up @@ -146,7 +162,7 @@ Here are some examples from processed from [diagrams/src/example1.pu](diagrams/s

```gardener``` uses the CycloneDX to generate a Software Bill of Materials in CycloneDX format (v1.4) every time a developer commits code to this repository. More information for CycloneDX is available [here](https://cyclonedx.org)

The SBoM for the last commit of ```gardener``` is available [here](gardener-sbom.json).
The SBoM for the last commit of ```gardener``` is available [here](sbom/gardener.cyclonedx.json).


## Credits
Expand Down
2 changes: 1 addition & 1 deletion cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/gookit/color"
"github.com/spf13/cobra"

"github.com/devops-kung-fu/gardener/src"
src "github.com/devops-kung-fu/gardener/lib"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

var (
Afs = &afero.Afero{Fs: afero.NewOsFs()}
version = "1.0.0"
version = "1.0.1"
debug bool
Verbose bool
rootCmd = &cobra.Command{
Expand Down
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ module github.com/devops-kung-fu/gardener
go 1.18

require (
github.com/devops-kung-fu/common v0.2.1
github.com/gookit/color v1.5.1
github.com/spf13/cobra v1.4.0
github.com/stretchr/testify v1.7.2
github.com/devops-kung-fu/common v0.2.5
github.com/gookit/color v1.5.2
github.com/spf13/cobra v1.6.0
github.com/stretchr/testify v1.8.0
)

require golang.org/x/text v0.3.7 // indirect
require golang.org/x/text v0.4.0 // indirect

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/afero v1.8.2
github.com/spf13/afero v1.9.2
github.com/spf13/pflag v1.0.5 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/sys v0.1.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading