Skip to content

Commit

Permalink
ci: Update go example
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Aug 28, 2024
0 parents commit 5531564
Show file tree
Hide file tree
Showing 32 changed files with 1,018 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# all start with .(dot), including directories and files
.*
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
compose.yml
LICENSE*
Makefile
README.md
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 120
tab_width = 4
trim_trailing_whitespace = true

[{Makefile,*.go}]
indent_style = tab
44 changes: 44 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Bug report
about: Create a report to help us improve
title: 'bug: '
labels: bug
assignees: ''

---

## Bug description

<!-- A clear and concise description of what the bug is. -->

- Would you like to work on a fix? [y/n]

## To Reproduce

Steps to reproduce the behavior:

1. ...
2. ...
3. ...
4. ...

<!-- Make sure you are able to reproduce the bug in the main branch, too. -->

## Expected behavior

<!-- A clear and concise description of what you expected to happen. -->

## Screenshots

<!-- If applicable, add screenshots to help explain your problem. -->

## Environment

<!-- Please fill the following information. -->

- OS: [e.g. Ubuntu 20.04]
- example-go version: [e.g. 0.1.0]

## Additional context

<!-- Add any other context about the problem here. -->
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: true
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Feature request
about: Suggest an idea for this project
title: 'Feature Request: '
labels: enhancement
assignees: ''

---

## Motivations

<!--
If your feature request is related to a problem, please describe it.
-->

- Would you like to implement this feature? [y/n]

## Solution

<!-- Describe the solution you'd like. -->

## Alternatives

<!-- Describe any alternative solutions or features you've considered. -->

## Additional context

<!-- Add any other context or screenshots about the feature request here. -->
9 changes: 9 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- Please explain the changes you made -->

<!--
Please make sure:
- you have read the contributing guidelines:
https://github.com/x-pt/example-go/blob/main/docs/CONTRIBUTING.md
- you have updated the changelog (if needed):
https://github.com/x-pt/example-go/blob/main/CHANGELOG.md
-->
63 changes: 63 additions & 0 deletions .github/configs/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
version: 1

labels:
# Type: Build-related changes
- label: "@type/build"
title: '^build(?:\(.+\))?\!?:'

# Type: CI-related changes
- label: "@type/ci"
title: '^ci(?:\(.+\))?\!?:'
files:
- '\.github/.+'

# Type: Documentation changes
- label: "@type/docs"
title: '^docs(?:\(.+\))?\!?:'
files:
- "docs/.+"
- "**/*.md"

# Type: New feature
- label: "@type/feature"
title: '^feat(?:\(.+\))?\!?:'

# Type: Bug fix
- label: "@type/fix"
title: '^fix(?:\(.+\))?\!?:'

# Type: Improvements such as style changes, refactoring, or performance improvements
- label: "@type/improve"
title: '^(style|refactor|perf)(?:\(.+\))?\!?:'

# Type: Dependency changes
- label: "@type/dependency"
title: '^(chore|build)(?:\(deps\))?\!?:'

# Type: Test-related changes
- label: "@type/test"
title: '^test(?:\(.+\))?\!?:'
files:
- "tests/.+"
- "spec/.+"

# Type: Security-related changes
- label: "@type/security"
title: '^security(?:\(.+\))?\!?:'
files:
- "**/security/.+"

# Issue Type Only: Feature Request
- label: "Feature Request"
type: issue
title: "^Feature Request:"

# Issue Type Only: Documentation
- label: "Documentation"
type: issue
title: "^.*(\b[Dd]ocumentation|doc(s)?\b).*"

# Issue Type Only: Bug Report
- label: "Bug Report"
type: issue
title: "^.*(\b[Bb]ug|b(u)?g(s)?\b).*"
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
# Check for updates every Monday
schedule:
interval: "weekly"
open-pull-requests-limit: 10
6 changes: 6 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
]
}
14 changes: 14 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: CD # Continuous Deployment or Delivery

on:
push:
# e.g. 1.0.0, v2.0.0, v0.1.0, v0.2.0-alpha, v0.3.0+build-71edf32
tags:
- '[v]?[0-9]+\.[0-9]+\.[0-9]+.*'

jobs:
dd:
name: Deploy or Delivery
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI # Continuous Integration

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Build
run: make init && make build

- name: Test
run: make test
51 changes: 51 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and Push Docker Image

on:
push:
tags:
- '^v[0-9]+\.[0-9]+\.[0-9]+.*$'

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and Export to Docker
uses: docker/build-push-action@v6
with:
context: .
load: true
tags: |
ghcr.io/x-pt/example-go:latest
ghcr.io/x-pt/example-go:${GITHUB_REF_NAME:1}
-
name: Test it before Push
run: |
docker run --rm ghcr.io/x-pt/example-go:latest
docker run --rm ghcr.io/x-pt/example-go:${GITHUB_REF_NAME:1}
-
name: Build and Push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/x-pt/example-go:latest
ghcr.io/x-pt/example-go:${GITHUB_REF_NAME:1}
15 changes: 15 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Labeler

on:
- pull_request
- issues

jobs:
labeler:
runs-on: ubuntu-latest
steps:
- uses: srvaroa/labeler@master
with:
config_path: .github/configs/labeler.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60 changes: 60 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Example Go Release

on:
push:
tags:
- "v*.*.*"

jobs:
changelog:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get Tag Version
id: tag_version
run: echo "CURRENT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Generate Full Changelog
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: --verbose
env:
OUTPUT: CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}

- name: Commit Changelog
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
set +e
git switch main
git add CHANGELOG.md
git commit -m "chore(release-bot): prepare for release notes on ${CURRENT_TAG}"
git push
release:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Generate Latest Release Notes
id: latest_release_notes
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: --latest --strip all
env:
OUTPUT: CHANGELOG.txt

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
body_path: CHANGELOG.txt
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
### Custom
.idea
.vscode

### Go template
# Binaries for programs and plugins
bin
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
Loading

0 comments on commit 5531564

Please sign in to comment.