diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..c63b382 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +version: 2 +updates: + - package-ecosystem: gomod + directory: / + schedule: + interval: weekly + commit-message: + prefix: ":arrow_up:" + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + commit-message: + prefix: ":arrow_up:" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2ca487e..9fa9007 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,19 +1,24 @@ name: CI -on: [push, pull_request] + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read jobs: - build: + ci: + name: CI runs-on: ubuntu-latest - strategy: - matrix: - go: ["1.17"] - name: Go ${{ matrix.go }} sample steps: - - uses: actions/checkout@v3 - - name: Setup go - uses: actions/setup-go@v2 + - uses: actions/checkout@v7 + - uses: actions/setup-go@v7 with: - go-version: ${{ matrix.go }} - - run: | - go build - go test ./... + go-version: stable + - name: Format + run: test -z "$(gofmt -l .)" + - run: go vet ./... + - run: go build ./... + - run: go test -race ./... diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml new file mode 100644 index 0000000..0bba156 --- /dev/null +++ b/.github/workflows/dependabot-automerge.yml @@ -0,0 +1,39 @@ +name: Dependabot Auto Merge + +on: + pull_request: + types: + - opened + - reopened + - synchronize + +permissions: + contents: write + pull-requests: write + +jobs: + dependabot-auto-merge: + name: Dependabot Auto Merge + runs-on: ubuntu-latest + + if: >- + github.event.pull_request.user.login == 'dependabot[bot]' + + steps: + # Every update type, majors included: the ruleset's required CI check decides + # whether it actually merges (auto-merge waits for it). + # + # The built-in token can never merge a PR that edits .github/workflows/* + # ("refusing to allow a GitHub App to create or update workflow ... without workflows + # permission"), which is what Dependabot's action-version bumps are. Those are left for a + # human or the sweep tool instead of failing this job. + - name: Enable auto-merge + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_URL: ${{ github.event.pull_request.html_url }} + run: | + if gh pr diff "$PR_URL" --name-only | grep -q '^\.github/workflows/'; then + echo "::notice::This PR edits workflow files, which the built-in token cannot merge. Merge it by hand." + exit 0 + fi + gh pr merge --auto --squash "$PR_URL" diff --git a/.github/workflows/goreleaser.yaml b/.github/workflows/goreleaser.yaml index f319e7c..6ea45c9 100644 --- a/.github/workflows/goreleaser.yaml +++ b/.github/workflows/goreleaser.yaml @@ -12,19 +12,16 @@ jobs: goreleaser: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 + - uses: actions/checkout@v7 with: fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v2 + - uses: actions/setup-go@v7 with: - go-version: 1.17 - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 + go-version: stable + - uses: goreleaser/goreleaser-action@v7 with: distribution: goreleaser - version: latest - args: release --rm-dist + version: "~> v2" + args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}