From b9f040db691daf12d0f4db0c870112ba015f95c1 Mon Sep 17 00:00:00 2001 From: Tarun Koyalwar Date: Mon, 21 Nov 2022 15:55:55 +0530 Subject: [PATCH] adds gh actions (closes #5) --- .github/dependabot.yml | 43 +++++++++++++++++++++++++++ .github/workflows/build-test.yml | 29 ++++++++++++++++++ .github/workflows/codeql-analysis.yml | 38 +++++++++++++++++++++++ .github/workflows/lint-test.yml | 25 ++++++++++++++++ .github/workflows/release-tag.yml | 36 ++++++++++++++++++++++ 5 files changed, 171 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/build-test.yml create mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/lint-test.yml create mode 100644 .github/workflows/release-tag.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..f57b3f7 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,43 @@ +# 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://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + target-branch: "main" + commit-message: + prefix: "chore" + include: "scope" + labels: + - "Type: Maintenance" + + # Maintain dependencies for go modules + - package-ecosystem: "gomod" + directory: "/" + schedule: + interval: "daily" + target-branch: "main" + commit-message: + prefix: "chore" + include: "scope" + labels: + - "Type: Maintenance" + + # Maintain dependencies for docker + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "weekly" + target-branch: "main" + commit-message: + prefix: "chore" + include: "scope" + labels: + - "Type: Maintenance" diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 0000000..727ce00 --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,29 @@ +name: 🔨 Build Test + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + build: + name: Test Builds + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + steps: + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.18 + + - name: Check out code + uses: actions/checkout@v3 + + - name: Test + run: go test ./... + + - name: Build + run: go build . + working-directory: examples/ diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..4494ac5 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,38 @@ +name: 🚨 CodeQL Analysis + +on: + workflow_dispatch: + pull_request: + branches: + - main + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'go' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml new file mode 100644 index 0000000..28508fb --- /dev/null +++ b/.github/workflows/lint-test.yml @@ -0,0 +1,25 @@ + + +name: 🙏🏻 Lint Test +on: + push: + pull_request: + workflow_dispatch: + +jobs: + lint: + name: Lint Test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.18 + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v3.3.0 + with: + version: latest + args: --timeout 5m + working-directory: . diff --git a/.github/workflows/release-tag.yml b/.github/workflows/release-tag.yml new file mode 100644 index 0000000..e007008 --- /dev/null +++ b/.github/workflows/release-tag.yml @@ -0,0 +1,36 @@ +name: 🔖 Release Tag + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * 0' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + with: + persist-credentials: false + + - name: Get Commit Count + id: get_commit + run: git rev-list `git rev-list --tags --no-walk --max-count=1`..HEAD --count | xargs -I {} echo COMMIT_COUNT={} >> $GITHUB_OUTPUT + + - name: Create release and tag + if: ${{ steps.get_commit.outputs.COMMIT_COUNT > 0 }} + id: tag_version + uses: mathieudutour/github-tag-action@v6.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Create a GitHub release + if: ${{ steps.get_commit.outputs.COMMIT_COUNT > 0 }} + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.tag_version.outputs.new_tag }} + release_name: Release ${{ steps.tag_version.outputs.new_tag }} + body: ${{ steps.tag_version.outputs.changelog }}