diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..43b8387 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# Here you can find all the code owners for the following project. +* @gowizzard \ No newline at end of file diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..ed0a9d1 --- /dev/null +++ b/.github/release.yml @@ -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: + - "*" \ No newline at end of file diff --git a/.github/workflows/compver.yml b/.github/workflows/compver.yml new file mode 100644 index 0000000..12d51d6 --- /dev/null +++ b/.github/workflows/compver.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..02ccfde --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -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 }} \ No newline at end of file diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml new file mode 100644 index 0000000..ef03cc6 --- /dev/null +++ b/.github/workflows/docker-test.yml @@ -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 }} . \ No newline at end of file diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml new file mode 100644 index 0000000..423e384 --- /dev/null +++ b/.github/workflows/go-test.yml @@ -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 ./... \ No newline at end of file diff --git a/.github/workflows/pull-request-labels.yml b/.github/workflows/pull-request-labels.yml new file mode 100644 index 0000000..9b22a6a --- /dev/null +++ b/.github/workflows/pull-request-labels.yml @@ -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] + }); + } \ No newline at end of file