Skip to content

Commit

Permalink
Merge pull request #1 from gowizzard/development
Browse files Browse the repository at this point in the history
chore: Add github files.
  • Loading branch information
gowizzard authored Oct 29, 2023
2 parents 15e0f09 + 16eaefb commit 7f7b82a
Show file tree
Hide file tree
Showing 7 changed files with 203 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Here you can find all the code owners for the following project.
* @gowizzard
16 changes: 16 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# .github/release.yml

changelog:
categories:
- title: 🚩 Breaking Changes
labels:
- breaking-change
- title: 🚀 Features
labels:
- feature
- title: 🐛 Fixes
labels:
- fix
- title: 📦 Other Changes
labels:
- "*"
43 changes: 43 additions & 0 deletions .github/workflows/compver.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CompVer

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

env:
USER_NAME: "GitHub Action"
USER_EMAIL: "actions@github.com"
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
COMMIT_MESSAGE: "ci: The data of the master branch was merged automatically."

jobs:
version:
runs-on: ubuntu-latest
steps:

- name: Clone repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get the major version
id: compver
env:
GITHUB_TOKEN: ${{ github.token }}
uses: gowizzard/compver@v5
with:
args: "-core -block major -version1 ${{ github.ref_name }} -trim -prefix v"

- name: Set git config
run: |
git config --local user.name "$USER_NAME"
git config --local user.email "$USER_EMAIL"
- name: Merge data from default branch
run: |
git fetch
git checkout v${{ steps.compver.outputs.core_result }}
git pull
git merge --no-ff "origin/$DEFAULT_BRANCH" -m "$COMMIT_MESSAGE"
git push
53 changes: 53 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Docker Build

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

env:
REGISTRY: ghcr.io
USERNAME: ${{ github.actor }}
PASSWORD: ${{ secrets.GITHUB_TOKEN }}
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:

- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.USERNAME }}
password: ${{ env.PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/arm64
push: true
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
23 changes: 23 additions & 0 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Docker Test

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
IMAGE_NAME: ${{ github.repository }}
IMAGE_TAG: "test"

jobs:
build:
runs-on: ubuntu-latest

steps:

- name: Checkout repository
uses: actions/checkout@v3

- name: Build the Docker image
run: docker build -t ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} .
27 changes: 27 additions & 0 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Go Test

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:

- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...
39 changes: 39 additions & 0 deletions .github/workflows/pull-request-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Pull Request Labels

on:
pull_request:
types: [opened]

jobs:
pull-request-labeler:

runs-on: ubuntu-latest

permissions:
pull-requests: write

steps:

- name: Add label to pull request
uses: actions/github-script@v6
with:
script: |
const title = context.payload.pull_request.title.toLowerCase();
if (!title) return;
function getLabelFromTitle(title) {
if (title.includes('feat!:')) return 'breaking change';
if (title.includes('fix:')) return 'fix';
if (title.includes('feat:')) return 'feature';
return null;
}
const label = getLabelFromTitle(title);
if (label) {
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [label]
});
}

0 comments on commit 7f7b82a

Please sign in to comment.