From 664019d42c16c648c214534e530c954576b9e9b6 Mon Sep 17 00:00:00 2001 From: Igor Shishkin Date: Sat, 6 Jul 2024 09:55:19 +0300 Subject: [PATCH] Add Github actions pipelines for verify & release procedures Signed-off-by: Igor Shishkin --- .github/ISSUE_TEMPLATE/bug-report.md | 31 +++++++ .github/ISSUE_TEMPLATE/feature_request.md | 23 ++++++ .github/dependabot.yml | 11 +++ .github/workflows/release.yml | 99 +++++++++++++++++++++++ .github/workflows/verify.yml | 60 ++++++++++++++ 5 files changed, 224 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug-report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/verify.yml diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md new file mode 100644 index 0000000..042932d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -0,0 +1,31 @@ +--- +name: Bug Report +about: Create a report to help us improve +title: "[BUG] " +labels: bug +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. ... +2. ... +3. ... +4. ... + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Configuration file snippet** + +``` +// config.yaml or json + +``` + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..f1fb96f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,23 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: "[FEATURE REQUEST] " +labels: enhancement +assignees: '' + +--- + +**What is your use case?** +What real problem are you trying to solve? + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..cd88554 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "gomod" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7de4b2c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,99 @@ +--- +name: release + +on: + push: + tags: + - 'v*' + +jobs: + hadolint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: hadolint/hadolint-action@v3.1.0 + with: + dockerfile: Dockerfile + + markdownlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: articulate/actions-markdownlint@v1 + + unittests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.22.x' + - name: Install dependencies + run: go mod download + - name: Test with the Go CLI + run: go test ./... + - name: Build + run: go build -v ./... + + build: + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + needs: + - hadolint + - markdownlint + - unittests + steps: + - name: Define build timestamp + id: timestamp + run: echo "::set-output name=now::$(date -u +'%Y%m%d%H%M%S')" + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.22.x' + - name: Install dependencies + run: go mod download + - name: Build & Publish release release + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: '~> v2' + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push access container image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile.access + platforms: amd64 + push: true + tags: | + ghcr.io/${{ github.repository }}/access:latest + ghcr.io/${{ github.repository }}/access:${{ github.ref_name }} + ghcr.io/${{ github.repository }}/access:${{ github.ref_name }}-${{ steps.timestamp.outputs.now }} + outputs: type=image,name=ghcr.io/${{ github.repository }}/access,annotation-index.org.opencontainers.image.description=${{ github.repository }} + - name: Build and push manage container image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile.manage + platforms: amd64 + push: true + tags: | + ghcr.io/${{ github.repository }}/manage:latest + ghcr.io/${{ github.repository }}/manage:${{ github.ref_name }} + ghcr.io/${{ github.repository }}/manage:${{ github.ref_name }}-${{ steps.timestamp.outputs.now }} + outputs: type=image,name=ghcr.io/${{ github.repository }}/manage,annotation-index.org.opencontainers.image.description=${{ github.repository }} diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 0000000..d386e28 --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,60 @@ +--- +name: verify + +on: + push: + branches: + - master + pull_request: + types: + - opened + - reopened + - edited + - synchronize + +jobs: + hadolint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: hadolint/hadolint-action@v3.1.0 + with: + dockerfile: Dockerfile + + markdownlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: articulate/actions-markdownlint@v1 + + unittests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.22.x' + - name: Install dependencies + run: go mod download + - name: Test with the Go CLI + run: go test ./... + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: '1.22.x' + - name: Install dependencies + run: go mod download + - name: Build project against .goreleaser.yaml + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: '~> v2' + args: build --snapshot + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}