Skip to content

Commit cd47c42

Browse files
committed
chore: init
0 parents  commit cd47c42

32 files changed

+1061
-0
lines changed

.chglog/CHANGELOG.tpl.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{ range .Versions }}
2+
{{ $tag := .Tag.Name }}
3+
<a name="{{ .Tag.Name }}"></a>
4+
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} <kbd>{{ datetime "2006/01/02" .Tag.Date }}</kbd>
5+
6+
{{ range .CommitGroups -}}
7+
{{ $type := .Title }}
8+
{{ range .Commits -}}{{$type}} {{ .Subject }}<br>{{ end }}
9+
{{ end -}}
10+
11+
{{ end -}}

.chglog/config.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
style: github
2+
template: CHANGELOG.tpl.md
3+
info:
4+
title: CHANGELOG
5+
repository_url: https://github.com/kilianc/cli-name
6+
options:
7+
commits:
8+
filters:
9+
Type:
10+
- feat
11+
- fix
12+
- chore
13+
commit_groups:
14+
group_by: Type
15+
sort_by: Title
16+
title_order:
17+
- fix
18+
- feat
19+
- chore
20+
title_maps:
21+
feat:
22+
fix: 🐛
23+
chore: 🧹
24+
header:
25+
pattern: "^(\\w*)\\:\\s(.*)$"
26+
pattern_maps:
27+
- Type
28+
- Subject
29+
notes:
30+
keywords:
31+
- BREAKING CHANGE

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*
2+
!cmd
3+
!internal
4+
!pkg
5+
!.golangci.yml
6+
!go.*
7+
!Makefile
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const fs = require('fs')
2+
3+
const updateCodeCoverageComment = module.exports = async ({ context, github }) => {
4+
const comments = await github.rest.issues.listComments({
5+
owner: context.repo.owner,
6+
repo: context.repo.repo,
7+
issue_number: context.issue.number,
8+
per_page: 100
9+
})
10+
11+
const coverageComment = comments.data.find((comment) => {
12+
return comment.body.startsWith('<!-- coverage -->')
13+
}) || {}
14+
15+
const coverageText = fs.readFileSync('cover.txt', 'utf8').split('\n').slice(0, -1)
16+
const coverageTextSummary = coverageText[coverageText.length-1].split('\t').pop()
17+
18+
const commentBody = [
19+
'<!-- coverage -->',
20+
`### Code Coverage Report ${process.env.REVISION}`,
21+
'```',
22+
`Total: ${coverageTextSummary}`,
23+
'```',
24+
'<details>',
25+
'<summary>Full coverage report</summary>',
26+
'',
27+
'```',
28+
...coverageText,
29+
'```',
30+
'</details>',
31+
].join('\n')
32+
33+
const upsertCommentOptions = {
34+
owner: context.repo.owner,
35+
repo: context.repo.repo,
36+
issue_number: context.issue.number,
37+
comment_id: coverageComment.id,
38+
body: commentBody
39+
}
40+
41+
if (coverageComment.id) {
42+
await github.rest.issues.updateComment(upsertCommentOptions)
43+
} else {
44+
await github.rest.issues.createComment(upsertCommentOptions)
45+
}
46+
}

.github/upload-release-assets.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const fs = require('fs')
2+
3+
const uploadReleaseAssets = module.exports = async ({ context, github }, tag) => {
4+
const files = fs.readdirSync('bin').filter(file => file.endsWith('.tar.gz'))
5+
6+
const release = await github.rest.repos.getReleaseByTag({
7+
owner: context.repo.owner,
8+
repo: context.repo.repo,
9+
tag: tag.replace('refs/tags/', '')
10+
})
11+
12+
for (const file of files) {
13+
console.log(`Uploading bin/${file} to release ${tag.replace('refs/tags/', '')} id=${release.data.id}`)
14+
15+
await github.rest.repos.uploadReleaseAsset({
16+
owner: context.repo.owner,
17+
repo: context.repo.repo,
18+
release_id: release.data.id,
19+
name: file,
20+
data: fs.readFileSync(`bin/${file}`),
21+
url: release.data.upload_url
22+
})
23+
}
24+
}

.github/workflows/go.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# This workflow will build a golang project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
3+
4+
name: Go
5+
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
11+
12+
env:
13+
REVISION: ${{ github.event.pull_request.head.sha || github.sha }}
14+
15+
jobs:
16+
build:
17+
name: Build and Test
18+
permissions:
19+
issues: write
20+
pull-requests: write
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v3
24+
25+
- name: Set up Go
26+
uses: actions/setup-go@v4
27+
with:
28+
go-version: '1.22'
29+
30+
- name: Docker Build
31+
run: make docker-build
32+
33+
- name: Build
34+
run: make build
35+
36+
- name: Test
37+
run: make test
38+
39+
- name: Create cover.txt
40+
run: make cover.txt
41+
42+
- name: Post Code Coverage Comment
43+
uses: actions/github-script@v5
44+
if: ${{ github.event_name == 'pull_request' }}
45+
with:
46+
script: await require('${{ github.workspace }}/.github/update-code-coverage-comment.js')({ context, github })
47+
48+
- name: Cover Check
49+
run: make check-cover
50+
51+
- name: Version Check
52+
run: make check-version
53+
54+
- name: Commit Check
55+
run: make check-commit message='${{ github.event.pull_request.title }}'

.github/workflows/release.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: 'Tag to build (e.g., v1.2.3)'
11+
required: true
12+
13+
jobs:
14+
upload-release-assets:
15+
name: Upload Release Assets
16+
permissions:
17+
contents: write
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
with:
23+
ref: ${{ github.event.inputs.tag || github.ref }}
24+
25+
- name: Set up Go
26+
uses: actions/setup-go@v4
27+
with:
28+
go-version: '1.22'
29+
30+
- name: Version Check
31+
run: make version-check tag=${{ github.event.inputs.tag || github.ref }}
32+
33+
- name: Tarball
34+
run: make release
35+
36+
- name: Upload Release Assets
37+
uses: actions/github-script@v5
38+
with:
39+
script: |
40+
const script = require('${{ github.workspace }}/.github/upload-release-assets.js')
41+
const tag = '${{ github.event.inputs.tag || github.ref }}'
42+
await script({ context, github }, tag)

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# https://github.com/github/gitignore/blob/main/Go.gitignore
2+
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
3+
#
4+
# Allowlisting gitignore template for GO projects prevents us
5+
# from adding various unwanted local files, such as generated
6+
# files, developer configurations or IDE-specific files etc.
7+
#
8+
# Recommended: Go.AllowList.gitignore
9+
10+
# Ignore everything
11+
*
12+
13+
# But not these files...
14+
!/.gitignore
15+
16+
!*.go
17+
!go.sum
18+
!go.mod
19+
20+
!README.md
21+
!Makefile
22+
23+
# ...even if they are in subdirectories
24+
!*/

.golangci.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
linters:
2+
enable-all: false
3+
disable-all: true
4+
fast: false
5+
enable:
6+
- errchkjson
7+
- errorlint
8+
- godot
9+
- gofumpt
10+
- intrange
11+
- ireturn
12+
- lll
13+
- nestif
14+
- nilerr
15+
- nlreturn
16+
- revive
17+
- testifylint
18+
- wrapcheck
19+
- wsl
20+
21+
issues:
22+
exclude-files:
23+
- "mock.*\\.go"
24+
exclude-rules:
25+
- path: '.+_test\.go'
26+
linters:
27+
- forcetypeassert
28+
29+
output:
30+
print-issued-lines: false
31+
32+
linters-settings:
33+
gofumpt:
34+
module-path: "cli-name"

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Launch Package",
9+
"type": "go",
10+
"request": "launch",
11+
"mode": "auto",
12+
"program": "${fileDirname}"
13+
}
14+
]
15+
}

0 commit comments

Comments
 (0)