Skip to content

Commit 063a098

Browse files
authored
feat: deb, rpm, and homebrew support (#28)
* Adds support for deb, rpm, and Homebrew installation
1 parent f10c664 commit 063a098

File tree

15 files changed

+2153
-465
lines changed

15 files changed

+2153
-465
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ updates:
55
schedule:
66
interval: daily
77
time: "05:00"
8-
timezone: UTC
8+
timezone: US/Pacific
99
- package-ecosystem: gomod
1010
directory: /
1111
schedule:
1212
interval: daily
1313
time: "05:00"
14-
timezone: UTC
14+
timezone: US/Pacific

.github/workflows/go-quality.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ jobs:
44
tests:
55
runs-on: ubuntu-latest
66
steps:
7-
- name: Checkout
7+
-
8+
name: Checkout
89
uses: actions/checkout@v2
910
- name: Setup Go
1011
uses: actions/setup-go@v2

.github/workflows/release.yml

Lines changed: 29 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,150 +1,45 @@
1-
name: hinge Release
1+
name: Release
22

33
on:
44
push:
55
tags:
66
- 'v*'
77

8+
permissions:
9+
contents: write
10+
811
jobs:
912
release:
10-
name: Create Release
1113
runs-on: ubuntu-latest
12-
outputs:
13-
upload_url: ${{ steps.upload_url.outputs.upload_url }}
14-
1514
steps:
16-
- name: Checkout code
15+
-
16+
name: Checkout
1717
uses: actions/checkout@v2
18-
19-
- name: Create Release
20-
id: create_release
21-
uses: actions/create-release@v1
22-
env:
23-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2418
with:
25-
tag_name: ${{ github.ref }}
26-
release_name: Release ${{ github.ref }}
27-
body: |
28-
This release has the following changes:
29-
- README Updates.
30-
draft: false
31-
prerelease: false
32-
33-
- name: Fix Upload URL
34-
id: upload_url
35-
run: echo ::set-output name=upload_url::$(echo "${{ steps.create_release.outputs.upload_url }}" | cut -d"{" -f1)
36-
37-
- name: Echo upload url
38-
run: echo "${{ steps.upload_url.outputs.upload_url }}"
39-
40-
build:
41-
needs: release
42-
strategy:
43-
matrix:
44-
os: ["darwin", "freebsd", "linux", "netbsd", "openbsd", "windows"]
45-
arch: ["amd64", "arm64", "arm"]
46-
47-
env:
48-
UPLOAD_URL: ${{ needs.release.outputs.upload_url }}
49-
50-
name: Build and Upload Assets
51-
runs-on: ubuntu-latest
52-
steps:
53-
- name: Checkout code
54-
uses: actions/checkout@v2
55-
56-
- name: Setup Go
19+
fetch-depth: 0
20+
-
21+
name: Set up Go
5722
uses: actions/setup-go@v2
5823
with:
59-
go-version: '1.18'
60-
61-
- name: Get the version
62-
id: get_version
63-
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/}
64-
65-
- name: Generate SBOM
66-
uses: CycloneDX/gh-gomod-generate-sbom@v0.3.0
24+
go-version: 1.18
25+
-
26+
name: Run GoReleaser
27+
uses: goreleaser/goreleaser-action@v2
6728
with:
68-
include-stdlib: true
69-
json: true
70-
output: sbom.json
71-
resolve-licenses: true
72-
version: "^v0"
73-
74-
- name: Build amd64 Assets
75-
if: matrix.arch == 'amd64'
76-
run: |
77-
echo "${{ matrix.os }} ${{ matrix.arch }}"
78-
env GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o $FILE github.com/devops-kung-fu/hinge
79-
env:
80-
FILE: build/hinge-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}
81-
82-
- name: Build arm64 Assets
83-
if: matrix.arch == 'arm64' && matrix.os == 'linux'
84-
run: |
85-
echo "${{ matrix.os }} ${{ matrix.arch }}"
86-
env GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o $FILE github.com/devops-kung-fu/hinge
87-
env:
88-
FILE: build/hinge-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}
89-
90-
- name: Build arm Assets
91-
if: matrix.arch == 'arm' && (matrix.os == 'freebsd' || matrix.os == 'netbsd' || matrix.os == 'openbsd')
92-
run: |
93-
echo "${{ matrix.os }} ${{ matrix.arch }}"
94-
env GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o $FILE github.com/devops-kung-fu/hinge
95-
env:
96-
FILE: build/hinge-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}
97-
98-
- name: Upload SBoM
99-
run: |
100-
curl \
101-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
102-
-H "Content-Type: $(file -b --mime-type $FILE)" \
103-
--data-binary @$FILE \
104-
"$UPLOAD_URL?name=$(basename $FILE)"
105-
env:
106-
FILE: sbom.json
107-
108-
- name: Upload amd64 Non-Windows
109-
if: matrix.os != 'windows' && matrix.arch == 'amd64'
110-
run: |
111-
curl \
112-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
113-
-H "Content-Type: $(file -b --mime-type $FILE)" \
114-
--data-binary @$FILE \
115-
"$UPLOAD_URL?name=$(basename $FILE)"
116-
env:
117-
FILE: build/hinge-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}
118-
119-
- name: Upload amd64 Windows
120-
if: matrix.os == 'windows' && matrix.arch == 'amd64'
121-
run: |
122-
curl \
123-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
124-
-H "Content-Type: $(file -b --mime-type $FILE)" \
125-
--data-binary @$FILE \
126-
"$UPLOAD_URL?name=$(basename $FILE)"
127-
env:
128-
FILE: build/hinge-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}.exe
129-
130-
- name: Upload arm64
131-
if: matrix.os == 'linux' && matrix.arch == 'arm64'
132-
run: |
133-
curl \
134-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
135-
-H "Content-Type: $(file -b --mime-type $FILE)" \
136-
--data-binary @$FILE \
137-
"$UPLOAD_URL?name=$(basename $FILE)"
138-
env:
139-
FILE: build/hinge-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}
29+
distribution: goreleaser
30+
version: ${{ env.GITHUB_REF_NAME }}
31+
args: release --rm-dist
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
34+
-
35+
name: Generate SBOM
36+
uses: anchore/sbom-action@v0
37+
with:
38+
artifact-name: hinge.spdx.json
39+
path: .
40+
-
41+
name: Release SBOM
42+
uses: anchore/sbom-action/publish-sbom@v0
43+
with:
44+
sbom-artifact-match: ".*\\.spdx.json$"
14045

141-
- name: Upload arm
142-
if: (matrix.os == 'freebsd' || matrix.os == 'netbsd' || matrix.os == 'openbsd') && matrix.arch == 'arm'
143-
run: |
144-
curl \
145-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
146-
-H "Content-Type: $(file -b --mime-type $FILE)" \
147-
--data-binary @$FILE \
148-
"$UPLOAD_URL?name=$(basename $FILE)"
149-
env:
150-
FILE: build/hinge-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@
1515
# vendor/
1616

1717
.DS_Store
18+
1819
hinge

.goreleaser.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
project_name: hinge
2+
3+
builds:
4+
-
5+
binary: hinge
6+
goos:
7+
- darwin
8+
- linux
9+
goarch:
10+
- amd64
11+
- arm64
12+
13+
release:
14+
prerelease: auto
15+
16+
universal_binaries:
17+
- replace: true
18+
19+
brews:
20+
-
21+
name: hinge
22+
homepage: "https://github.com/devops-kung-fu/hinge"
23+
tap:
24+
owner: devops-kung-fu
25+
name: homebrew-tap
26+
commit_author:
27+
name: djschleen
28+
email: djschleen@gmail.com
29+
30+
checksum:
31+
name_template: 'checksums.txt'
32+
33+
nfpms:
34+
- maintainer: DJ Schleen <djschleen@gmail.com>
35+
description: Creates and updates your Dependabot config.
36+
homepage: https://github.com/devops-kung-fu/hinge
37+
license: MPL
38+
formats:
39+
- deb
40+
- rpm
41+

.hookz.yaml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
version: 2.4.0
1+
version: 2.4.1
22
sources:
3-
- source: github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@latest
3+
- source: github.com/anchore/syft/cmd/syft@latest
44
- source: github.com/devops-kung-fu/hinge@latest
55
- source: github.com/kisielk/errcheck@latest
66
- source: golang.org/x/lint/golint@latest
@@ -30,7 +30,7 @@
3030
exec: gocyclo
3131
args: ["-over", "8", "."]
3232
- name: Hinge
33-
exec: hinge
33+
exec: ./hinge
3434
args: ["."]
3535
- name: "go: Build (Ensure pulled modules do not break the build)"
3636
exec: go
@@ -41,9 +41,14 @@
4141
- name: "go: Test coverage"
4242
exec: go
4343
args: ["tool", "cover", "-func=coverage.out"]
44-
- name: "cyclone-dx: Generate a Software Bill of Materials (SBoM)"
45-
exec: cyclonedx-gomod
46-
args: ["-json", "-output", "hinge-sbom.json"]
44+
- name: "syft: Generate a Software Bill of Materials (SBoM)"
45+
exec: syft
46+
args: [".","-o ","json=sbom/hinge.syft.json","-o", "spdx-json=sbom/hinge.spdx.json", "-o", "cyclonedx-json=sbom/hinge.cyclonedx.json"]
4747
- name: "git: Add all changed files during the pre-commit stage"
4848
exec: git
49-
args: ["add", "."]
49+
args: ["add", "."]
50+
- type: pre-push
51+
actions:
52+
- name: "hookz: example pre-push hook"
53+
exec: /bin/echo
54+
args: ["Pushing changes..."]

Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ title:
1313
@echo "--------------"
1414

1515
build: ## Builds the application
16-
go get -u ./...
17-
go mod tidy
18-
go build ./...
16+
@echo Building...
17+
@go get -u ./...
18+
@go mod tidy
19+
@go build ./...
1920

2021
test: ## Runs tests and coverage
21-
go test -v -coverprofile=coverage.out ./... && go tool cover -func=coverage.out
22+
@go test -v -coverprofile=coverage.out ./... && go tool cover -func=coverage.out
2223

2324
check: build ## Tests the pre-commit hooks if they exist
24-
hookz reset --verbose --debug --verbose-output
25+
@hookz reset --verbose --debug --verbose-output
2526
. .git/hooks/pre-commit
2627

2728
all: title build test ## Makes all targets

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,23 @@ Creates and updates your Dependabot configuration file, `dependabot.yml`.
2020

2121
## Installation
2222

23-
To install ```hinge```, [download the latest release](https://github.com/devops-kung-fu/hinge/releases) , make it executable, rename it to `hinge` and move it to the `/usr/local/bin` directory for Linux, or on your `PATH` for other operating systems.
23+
### Mac
2424

25-
### Linux Example
25+
You can use [Homebrew](https://brew.sh) to install ```Hookz``` using the following:
2626

27-
```bash
28-
sudo chmod +x hinge-1.0.0-linux-amd64
29-
sudo mv hinge-1.0.0-linux-amd64 /usr/local/bin/hinge
27+
``` bash
28+
brew tap devops-kung-fu/homebrew-tap
29+
brew install devops-kung-fu/homebrew-tap/hinge
3030
```
31+
32+
### Linux
33+
34+
To install ```hinge```, download the latest release [deb or rpm](https://github.com/devops-kung-fu/hinge/releases and install.
35+
36+
``` bash
37+
# Debian Example
38+
dpkg -i hinge_1.0.1_linux_amd64.deb
39+
3140
### With a Go Development Environment
3241

3342
If you have a Go development environment set up, you can also simply do this:
@@ -71,7 +80,7 @@ Once ```hinge``` is installed, you can run this command in the root of your git
7180
hinge .
7281
```
7382

74-
**NOTE**: The provided path needs to be a git repository.
83+
**NOTE**: The provided path must be a git repository.
7584

7685
### Flag Notes
7786

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
)
2020

2121
var (
22-
version = "1.0.0"
22+
version = "1.0.1"
2323
//Afs stores a global OS Filesystem that is used throughout hinge
2424
Afs = &afero.Afero{Fs: afero.NewOsFs()}
2525
//Verbose determines if the execution of hing should output verbose information

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.18
55
require (
66
github.com/devops-kung-fu/common v0.2.3
77
github.com/gookit/color v1.5.1
8-
github.com/spf13/afero v1.8.2
8+
github.com/spf13/afero v1.9.2
99
github.com/spf13/cobra v1.5.0
1010
github.com/stretchr/testify v1.8.0
1111
gopkg.in/yaml.v2 v2.4.0
@@ -17,7 +17,7 @@ require (
1717
github.com/pmezard/go-difflib v1.0.0 // indirect
1818
github.com/spf13/pflag v1.0.5 // indirect
1919
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
20-
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e // indirect
20+
golang.org/x/sys v0.0.0-20220731174439-a90be440212d // indirect
2121
golang.org/x/text v0.3.7 // indirect
2222
gopkg.in/yaml.v3 v3.0.1 // indirect
2323
)

0 commit comments

Comments
 (0)