Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6e1658b
Showing
10 changed files
with
364 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
name: Release | ||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
|
||
jobs: | ||
build: | ||
name: Build & Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "1.17" | ||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-code-dependencies-${{ hashFiles('go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-code-dependencies | ||
- run: | | ||
go vet ./... | ||
go test ./... | ||
version: | ||
name: Semantic versioning | ||
needs: build | ||
runs-on: ubuntu-latest | ||
outputs: | ||
new_release_published: "${{ steps.semantic.outputs.new_release_published }}" | ||
new_release_version: "${{ steps.semantic.outputs.new_release_version }}" | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "1.17" | ||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-code-dependencies-${{ hashFiles('go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-code-dependencies | ||
- name: Semantic Release | ||
uses: cycjimmy/semantic-release-action@v2 | ||
id: semantic | ||
with: | ||
extra_plugins: | | ||
@semantic-release/commit-analyzer | ||
@semantic-release/release-notes-generator | ||
@semantic-release/changelog | ||
@semantic-release/git | ||
@semantic-release/exec | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
binary_release: | ||
name: Binary release | ||
needs: version | ||
if: ${{ needs.version.outputs.new_release_published == 'true' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set git tag | ||
run: git tag ${{ needs.version.outputs.new_release_version }} | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17 | ||
- name: Install vembed | ||
run: go install github.com/NoUseFreak/go-vembed/vembed@latest | ||
- name: Prepare vembed info | ||
run: echo "VEMBED=$(vembed)" >> $GITHUB_ENV | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
distribution: goreleaser | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_PAT }} | ||
|
||
docker_release: | ||
name: Docker release | ||
needs: version | ||
if: ${{ needs.version.outputs.new_release_published == 'true' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Current | ||
uses: actions/checkout@v2 | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: | | ||
ghcr.io/${{ github.repository }} | ||
tags: | | ||
type=ref,event=branch | ||
type=semver,pattern={{version}},value=${{ needs.version.outputs.new_release_version }} | ||
type=semver,pattern={{major}}.{{minor}},value=${{ needs.version.outputs.new_release_version }} | ||
type=semver,pattern={{major}},value=${{ needs.version.outputs.new_release_version }} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Login to GHCR | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist/ | ||
.tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
env: | ||
- PROJECT_DESCRIPTION= | ||
- PROJECT_HOMEPAGE=https://stenic.io | ||
- LICENSE=MIT | ||
|
||
before: | ||
hooks: | ||
- go mod tidy | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- darwin | ||
- windows | ||
goarch: | ||
- "386" | ||
- amd64 | ||
- arm | ||
- arm64 | ||
goarm: | ||
- "6" | ||
- "7" | ||
mod_timestamp: '{{ .CommitTimestamp }}' | ||
flags: | ||
- -trimpath | ||
ldflags: | ||
- '{{ .Env.VEMBED }}' | ||
|
||
checksum: | ||
name_template: 'checksums.txt' | ||
|
||
archives: | ||
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
files: | ||
- README.md | ||
- LICENSE | ||
|
||
brews: | ||
- tap: | ||
owner: stenic | ||
name: homebrew-tap | ||
folder: Formula | ||
homepage: "{{ .Env.PROJECT_HOMEPAGE }}" | ||
description: "{{ .Env.PROJECT_DESCRIPTION }}" | ||
license: "{{ .Env.LICENSE }}" | ||
test: | | ||
system "#{bin}/{{ .ProjectName }} -v" | ||
dependencies: [] | ||
install: |- | ||
bin.install "{{ .ProjectName }}" | ||
rigs: | ||
- rig: | ||
owner: stenic | ||
name: fish-food | ||
homepage: "{{ .Env.PROJECT_HOMEPAGE }}" | ||
description: "{{ .Env.PROJECT_DESCRIPTION }}" | ||
license: "{{ .Env.LICENSE }}" | ||
|
||
scoop: | ||
bucket: | ||
owner: stenic | ||
name: scoop-bucket | ||
homepage: "{{ .Env.PROJECT_HOMEPAGE }}" | ||
description: "{{ .Env.PROJECT_DESCRIPTION }}" | ||
license: "{{ .Env.LICENSE }}" | ||
|
||
nfpms: | ||
- file_name_template: '{{ .ConventionalFileName }}' | ||
id: packages | ||
homepage: "{{ .Env.PROJECT_HOMEPAGE }}" | ||
description: "{{ .Env.PROJECT_DESCRIPTION }}" | ||
maintainer: Dries De Peuter <dries@stenic.io> | ||
license: "{{ .Env.LICENSE }}" | ||
vendor: Stenic | ||
formats: | ||
- apk | ||
- deb | ||
- rpm | ||
dependencies: [] | ||
recommends: [] | ||
|
||
# snapcrafts: | ||
# - name_template: '{{ .ProjectName }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' | ||
# summary: "{{ .Env.PROJECT_DESCRIPTION }}" | ||
# description: "{{ .Env.PROJECT_DESCRIPTION }}" | ||
# grade: devel | ||
# confinement: strict | ||
# publish: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM golang:1.17 as builder | ||
|
||
WORKDIR /workspace | ||
COPY go.* . | ||
RUN go mod download | ||
COPY main.go main.go | ||
RUN CGO_ENABLED=0 GOOS=linux go build -a -o /project main.go | ||
|
||
|
||
# Use distroless as minimal base image to package the project | ||
# Refer to https://github.com/GoogleContainerTools/distroless for more details | ||
FROM gcr.io/distroless/static:nonroot | ||
|
||
WORKDIR / | ||
COPY --from=builder /project . | ||
ENTRYPOINT ["/project"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Stenic | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# [[project]] | ||
|
||
[[project]] does things. | ||
|
||
## Installation | ||
|
||
```shell | ||
# homebrew | ||
brew install stenic/tap/[[project]] | ||
|
||
# gofish | ||
gofish rig add https://github.com/stenic/fish-food | ||
gofish install github.com/stenic/fish-food/[[project]] | ||
|
||
# scoop | ||
scoop bucket add [[project]] https://github.com/stenic/scoop-bucket.git | ||
scoop install [[project]] | ||
|
||
# go | ||
go install github.com/stenic/[[project]]@latest | ||
|
||
# docker | ||
docker pull ghcr.io/stenic/[[project]]:latest | ||
|
||
# dockerfile | ||
COPY --from=ghcr.io/stenic/[[project]]:latest /[[project]] /usr/local/bin/ | ||
``` | ||
|
||
> For even more options, check the [releases page](https://github.com/stenic/[[project]]/releases). | ||
|
||
## Run | ||
|
||
```shell | ||
# Installed | ||
[[project]] -h | ||
|
||
# Docker | ||
docker run -ti ghcr.io/stenic/[[project]]:latest -h | ||
|
||
# Kubernetes | ||
kubectl run [[project]] --image=ghcr.io/stenic/[[project]]:latest --restart=Never -ti --rm -- -h | ||
``` | ||
|
||
## Documentation | ||
|
||
```shell | ||
[[project]] -h | ||
``` | ||
|
||
## Badges | ||
|
||
[![Release](https://img.shields.io/github/release/stenic/[[project]].svg?style=for-the-badge)](https://github.com/stenic/[[project]]/releases/latest) | ||
[![Software License](https://img.shields.io/github/license/stenic/[[project]]?style=for-the-badge)](./LICENSE) | ||
[![Build status](https://img.shields.io/github/workflow/status/stenic/[[project]]/Release?style=for-the-badge)](https://github.com/stenic/[[project]]/actions?workflow=build) | ||
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=for-the-badge)](https://conventionalcommits.org) | ||
|
||
## License | ||
|
||
[License](./LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# tpl go binary | ||
|
||
Template project for building and publishing binaries based on [Go](https://golang.org/). | ||
|
||
## Setup | ||
|
||
Make sure to search for `[[project]]` once you think you are done. | ||
|
||
|
||
### Configuration | ||
|
||
- .goreleaser.yml | ||
- Dockerfile | ||
- README.md | ||
- Delete this file ;-) | ||
|
||
### Pipeline | ||
|
||
Create a [personal access token](https://github.com/settings/tokens) for the project | ||
and configure it under `Settings > Secrets` on you repository called `GH_PAT`. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/nousefreak/gorel-poc | ||
|
||
go 1.17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package main | ||
|
||
// func main() { | ||
// println("Ba dum, tss!") | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = { | ||
"plugins": [ | ||
["@semantic-release/commit-analyzer"], | ||
["@semantic-release/release-notes-generator"], | ||
["@semantic-release/changelog", { | ||
"changelogTitle": "# Changelog\n\nAll notable changes to this project will be documented in this file. See\n[Conventional Commits](https://conventionalcommits.org) for commit guidelines." | ||
}], | ||
["@semantic-release/git", { | ||
"assets": ["CHANGELOG.md"], | ||
"message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}" | ||
}] | ||
], | ||
"branches": ["main"] | ||
} |