Skip to content

Commit 4e064b6

Browse files
committed
Initial commit
0 parents  commit 4e064b6

22 files changed

+641
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
ARG VARIANT="1.19"
2+
3+
FROM mcr.microsoft.com/vscode/devcontainers/go:${VARIANT}
4+
5+
ARG GOLANGCI_LINT_VERSION="1.49.0"
6+
7+
RUN echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' \
8+
| tee /etc/apt/sources.list.d/goreleaser.list
9+
RUN apt-get update \
10+
&& export DEBIAN_FRONTEND=noninteractive \
11+
&& apt-get -y install --no-install-recommends goreleaser
12+
13+
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
14+
| sh -s -- -b $(go env GOPATH)/bin v$GOLANGCI_LINT_VERSION
15+
16+
USER vscode
17+
WORKDIR /home/vscode
18+
19+
RUN mkdir -p .config/git \
20+
&& echo ".vscode/*" >> .config/git/ignore \
21+
&& echo "*.code-workspace" >> .config/git/ignore \
22+
&& echo ".history/" >> .config/git/ignore

.devcontainer/devcontainer.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "Go Module",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"args": {
6+
"VARIANT": "1.19",
7+
"GOLANGCI_LINT_VERSION": "1.49.0"
8+
}
9+
},
10+
"extensions": [
11+
"golang.Go",
12+
"ms-vsliveshare.vsliveshare",
13+
"EditorConfig.EditorConfig"
14+
],
15+
"postCreateCommand": "go mod download",
16+
"remoteUser": "vscode"
17+
}

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
indent_style = space
9+
indent_size = 2
10+
11+
[*.go]
12+
indent_style = tab
13+
14+
[Makefile]
15+
indent_style = tab

.github/actions/setup/action.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: Setup Go.
3+
description: Setup Go.
4+
5+
inputs:
6+
go_version:
7+
description: The Go version.
8+
required: false
9+
default: '1.19'
10+
11+
runs:
12+
using: composite
13+
steps:
14+
- name: Setup Go
15+
uses: actions/setup-go@v3
16+
with:
17+
go-version: ${{ inputs.go_version }}
18+
cache: true
19+
- name: Setup GoReleaser
20+
uses: goreleaser/goreleaser-action@v3
21+
with:
22+
install-only: true

.github/workflows/format.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
name: format
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- master
8+
workflow_dispatch: {}
9+
repository_dispatch:
10+
types:
11+
- format
12+
13+
jobs:
14+
fix:
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 30
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
with:
21+
ref: ${{ github.head_ref }}
22+
token: ${{ secrets.GH_TOKEN }}
23+
- name: Import GPG key
24+
uses: crazy-max/ghaction-import-gpg@v5
25+
with:
26+
git_user_signingkey: true
27+
git_commit_gpgsign: true
28+
git_committer_name: ${{ secrets.GIT_USER_NAME }}
29+
git_committer_email: ${{ secrets.GIT_USER_EMAIL }}
30+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
31+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
32+
- name: Setup
33+
uses: ./.github/actions/setup
34+
- name: Format
35+
uses: golangci/golangci-lint-action@v3
36+
with:
37+
version: v1.49
38+
args: --fix --timeout 30m
39+
- name: Commit
40+
uses: stefanzweifel/git-auto-commit-action@v4
41+
with:
42+
commit_message: Run format
43+
commit_user_name: ${{ secrets.GIT_USER_NAME }}
44+
commit_user_email: ${{ secrets.GIT_USER_EMAIL }}
45+
commit_author: ${{ secrets.GIT_USER_NAME }} <${{ secrets.GIT_USER_EMAIL }}>

.github/workflows/main.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
name: main
3+
4+
on:
5+
push:
6+
branches:
7+
- '**'
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 30
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
- name: Setup
17+
uses: ./.github/actions/setup
18+
- name: Test
19+
run: make test
20+
lint:
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 30
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v3
26+
- name: Setup
27+
uses: ./.github/actions/setup
28+
- name: Lint
29+
uses: golangci/golangci-lint-action@v3
30+
with:
31+
version: v1.49
32+
args: --timeout 30m
33+
build:
34+
runs-on: ubuntu-latest
35+
timeout-minutes: 60
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v3
39+
- name: Setup
40+
uses: ./.github/actions/setup
41+
- name: Build
42+
uses: goreleaser/goreleaser-action@v3
43+
with:
44+
args: release --skip-publish --skip-sign --snapshot --timeout=60m

.github/workflows/publish.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: publish
3+
4+
on:
5+
push:
6+
tags:
7+
- v*
8+
9+
jobs:
10+
github:
11+
runs-on: ubuntu-20.04
12+
timeout-minutes: 60
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
- name: Import GPG key
17+
uses: crazy-max/ghaction-import-gpg@v5
18+
with:
19+
git_user_signingkey: true
20+
git_commit_gpgsign: true
21+
git_committer_name: ${{ secrets.GIT_USER_NAME }}
22+
git_committer_email: ${{ secrets.GIT_USER_EMAIL }}
23+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
24+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
25+
- name: Setup
26+
uses: ./.github/actions/setup
27+
- name: Release
28+
uses: goreleaser/goreleaser-action@v3
29+
with:
30+
args: release --timeout=60m
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}

.github/workflows/version.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
name: version
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: Version to cut
9+
repository_dispatch:
10+
types:
11+
- version
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 30
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
with:
21+
persist-credentials: false
22+
- name: Setup Git config
23+
env:
24+
GH_USER: ${{ secrets.GH_USER }}
25+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
26+
GIT_USER_NAME: ${{ secrets.GIT_USER_NAME }}
27+
GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
28+
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
29+
run: |
30+
git remote set-url --push origin "https://${GH_USER}:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
31+
git config user.name "$GIT_USER_NAME"
32+
git config user.email "$GIT_USER_EMAIL"
33+
- name: Import GPG key
34+
uses: crazy-max/ghaction-import-gpg@v5
35+
with:
36+
git_user_signingkey: true
37+
git_commit_gpgsign: true
38+
git_committer_name: ${{ secrets.GIT_USER_NAME }}
39+
git_committer_email: ${{ secrets.GIT_USER_EMAIL }}
40+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
41+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
42+
- name: Cut ${{ github.event.inputs.version }}${{ github.event.client_payload.version }} version
43+
run: |
44+
git tag --sign "v${VERSION}" -m "${VERSION}"
45+
git push --tags
46+
env:
47+
VERSION: ${{ github.event.inputs.version }}${{ github.event.client_payload.version }}

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Parts of this file were adapted from
2+
# GitHub’s collection of .gitignore file templates
3+
# which are Copyright (c) 2022 GitHub, Inc.
4+
# and released under the MIT License.
5+
# For more details, visit the project page:
6+
# https://github.com/github/gitignore
7+
8+
# Build directories
9+
dist
10+
package
11+
target
12+
13+
# Temporary development files
14+
tmp
15+
16+
# If you prefer the allow list template instead of the deny list, see community template:
17+
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
18+
#
19+
# Binaries for programs and plugins
20+
*.exe
21+
*.exe~
22+
*.dll
23+
*.so
24+
*.dylib
25+
26+
# Test binary, built with `go test -c`
27+
*.test
28+
29+
# Output of the go coverage tool, specifically when used with LiteIDE
30+
*.out
31+
32+
# Dependency directories (remove the comment below to include it)
33+
# vendor/
34+
35+
# Go workspace file
36+
go.work

.golangci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
timeout: 30m
3+
4+
skip-dirs:
5+
- dist
6+
- tmp
7+
8+
linters:
9+
enable:
10+
- gofmt

0 commit comments

Comments
 (0)