From 5443e3265eb36ff62224effebee4a7f64a757b06 Mon Sep 17 00:00:00 2001 From: Georgi Chulkov Date: Tue, 19 Mar 2024 11:46:42 +0100 Subject: [PATCH] Add GitHub workflows --- .github/dependabot.yml | 26 +++++++++++ .github/release-drafter.yml | 49 +++++++++++++++++++ .github/workflows/draft-release.yml | 23 +++++++++ .github/workflows/lint.yml | 19 ++++++++ .github/workflows/publish-docker.yml | 70 ++++++++++++++++++++++++++++ .github/workflows/reuse.yml | 13 ++++++ .github/workflows/test.yml | 19 ++++++++ 7 files changed, 219 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/draft-release.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/publish-docker.yml create mode 100644 .github/workflows/reuse.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..6485164e --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,26 @@ +version: 2 +updates: +- package-ecosystem: gomod + directory: "/" + schedule: + interval: daily + commit-message: + prefix: "" + reviewers: + - Gchbg +- package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily + commit-message: + prefix: "" + reviewers: + - Gchbg +- package-ecosystem: docker + directory: "/" + schedule: + interval: daily + commit-message: + prefix: "" + reviewers: + - Gchbg diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 00000000..0a8ae7e3 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,49 @@ +name-template: 'v$RESOLVED_VERSION' +tag-template: 'v$RESOLVED_VERSION' +categories: +- title: '🚀 Features' + labels: + - 'feature' + - 'enhancement' +- title: '🐛 Bug Fixes' + labels: + - 'fix' + - 'bugfix' + - 'bug' +- title: '🧰 Maintenance' + labels: + - 'chore' + - 'dependencies' + - 'documentation' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +version-resolver: + major: + labels: + - 'major' + minor: + labels: + - 'minor' + patch: + labels: + - 'patch' + default: patch +exclude-labels: +- 'skip-changelog' +autolabeler: +- label: 'documentation' + files: + - '**/*.md' + branch: + - '/docs{0,1}\/.+/' +- label: 'bug' + branch: + - '/fix\/.+/' + title: + - '/fix/i' +- label: 'enhancement' + branch: + - '/feature\/.+/' +template: | + ## Changes + $CHANGES diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml new file mode 100644 index 00000000..c4419feb --- /dev/null +++ b/.github/workflows/draft-release.yml @@ -0,0 +1,23 @@ +name: Draft release + +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + +jobs: + release-drafter: + name: Draft release + runs-on: ubuntu-latest + steps: + - name: Draft release + uses: release-drafter/release-drafter@v6 + with: + disable-releaser: github.ref != 'refs/heads/main' + config-name: release-drafter.yml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..4645fce3 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,19 @@ +name: Lint + +on: pull_request + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + - name: Run linter + uses: golangci/golangci-lint-action@v4 diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml new file mode 100644 index 00000000..78981009 --- /dev/null +++ b/.github/workflows/publish-docker.yml @@ -0,0 +1,70 @@ +name: Build and publish docker image + +env: + platforms: linux/amd64,linux/arm64 + +on: + push: + branches: + - main + tags: + - v* + pull_request: + +permissions: + contents: read + packages: write + +jobs: + publish-docker: + name: Build and publish Docker image + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Collect metadata + uses: docker/metadata-action@v5 + id: meta + with: + images: | + ghcr.io/${{ github.repository_owner }}/metal + tags: | + type=semver,pattern={{version}} + type=schedule + type=ref,event=branch + type=ref,event=tag + type=ref,event=pr + type=sha + flavor: | + latest=${{ github.ref == 'refs/heads/main' }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + image: tonistiigi/binfmt:latest + platforms: ${{ env.platforms }} + - name: Set up Docker Buildx context + run: | + docker context create builders + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + timeout-minutes: 5 + with: + version: latest + endpoint: builders + - name: Log in to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push Docker image + uses: docker/build-push-action@v5 + timeout-minutes: 60 + with: + context: . + platforms: ${{ env.platforms }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + push: true diff --git a/.github/workflows/reuse.yml b/.github/workflows/reuse.yml new file mode 100644 index 00000000..7dda5ca5 --- /dev/null +++ b/.github/workflows/reuse.yml @@ -0,0 +1,13 @@ +name: Check REUSE compliance + +on: pull_request + +jobs: + reuse: + name: Check REUSE compliance + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + - name: Run REUSE + uses: fsfe/reuse-action@v3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..61f27e2d --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,19 @@ +name: Test + +on: pull_request + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + - name: Run tests + run: make test