diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..dfb1d13 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,46 @@ +version: v1 + +labels: + - label: "type: feature" + sync: true + matcher: + title: "^feat: .*" + commits: "^feat: .*" + body: "(\\n|.)*- \\[x\\] feature(\\n|.)*" + + - label: "type: bug" + sync: true + matcher: + title: "^fix: .*" + commits: "^fix: .*" + body: "(\\n|.)*- \\[x\\] (fix|bug)(\\n|.)*" + + - label: "type: chore" + sync: true + matcher: + title: "^chore: .*" + commits: "^chore: .*" + body: "(\\n|.)*- \\[x\\] chore(\\n|.)*" + files: [ ".github/*" ] + + - label: "type: docs" + sync: true + matcher: + title: "^docs: .*" + commits: "^docs: .*" + files: [ "*.md", "doc.go" ] + +checks: + - context: "Semantic Pull Request" + url: "https://github.com/Fishwaldo/go-logadapter/blob/master/.github/labeler.yml" + description: + success: Ready for review & merge. + failure: Missing semantic label for merge. + labels: + any: + - 'type: feature' + - 'type: bug' + - 'type: chore' + - 'type: docs' + - 'type: maintenance' + - 'type: dependencies' diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..80ada4c --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,39 @@ +name-template: 'v$RESOLVED_VERSION' +tag-template: 'v$RESOLVED_VERSION' +template: | + # What's Changed + + $CHANGES +categories: + - title: 'Breaking' + label: 'type: breaking' + - title: 'New' + label: 'type: feature' + - title: 'Bug Fixes' + label: 'type: bug' + - title: 'Maintenance' + label: 'type: maintenance' + - title: 'Maintenance' + label: 'type: chore' + - title: 'Documentation' + label: 'type: docs' + - title: 'Dependency Updates' + label: 'type: dependencies' + +version-resolver: + major: + labels: + - 'type: breaking' + minor: + labels: + - 'type: feature' + patch: + labels: + - 'type: bug' + - 'type: maintenance' + - 'type: docs' + - 'type: dependencies' + - 'type: security' + +exclude-labels: + - 'skip-changelog' diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 22f8062..748a02f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,15 +21,38 @@ jobs: uses: actions/setup-go@v1 with: go-version: ${{ matrix.go-version }} + - name: Install libusb-1.0-0-dev + run: sudo apt-get install libusb-1.0-0-dev - name: Checkout code uses: actions/checkout@v1 - - name: Install libusb-1.0-0-dev - run: sudo apt-get install libusb-1.0-0-dev - name: Run tests - run: go test -v -race ./... + run: go test -v -race + + + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Install libusb-1.0-0-dev + run: sudo apt-get install libusb-1.0-0-dev + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: go + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 + codecov: runs-on: ubuntu-latest - needs: test + needs: [ test, analyze ] steps: - name: Install Go if: success() @@ -41,13 +64,14 @@ jobs: - name: Install libusb-1.0-0-dev run: sudo apt-get install libusb-1.0-0-dev - name: Run tests - run: go test -v -race -covermode=atomic -coverprofile=coverage.out ./... + run: go mod tidy && go test -v -race -covermode=atomic -coverprofile=coverage.out ./... - name: CodeCov uses: codecov/codecov-action@v2 + lint: name: Lint project using GolangCI Lint runs-on: ubuntu-latest - needs: test + needs: [ test, analyze ] steps: - name: Check out code into the Go module directory uses: actions/checkout@v1 @@ -57,6 +81,7 @@ jobs: version: latest only-new-issues: true args: --issues-exit-code=0 + goreadme: runs-on: ubuntu-latest needs: [codecov, lint] @@ -69,5 +94,20 @@ jobs: badge-codecov: 'true' badge-godoc: 'true' email: 'justin@dynam.ac' - title: 'Go-DCDCUSB' + title: 'Go-LogAdapter' + # Optional: Token allows goreadme to comment the PR with diff preview. github-token: '${{ secrets.GITHUB_TOKEN }}' + + release: + #if: startsWith(github.ref, 'refs/tags/') + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + needs: [goreadme] + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v2 + - uses: release-drafter/release-drafter@master + with: + prerelease: ${{ contains(github.ref, '-rc') || contains(github.ref, '-b') || contains(github.ref, '-a') }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000..dfbbd25 --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,9 @@ +on: + pull_request_target: + types: [ opened, reopened, edited, synchronize, ready_for_review, labeled, unlabeled ] +name: Labeler +jobs: + labeler: + runs-on: ubuntu-latest + steps: + - uses: fuxingloh/multi-labeler@v1