chore: release v0.6.26 #885
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "🤖 Check: Commit" | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
permissions: | |
contents: write | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
changes: | |
runs-on: ubuntu-latest | |
timeout-minutes: 4 | |
outputs: | |
has_change: "${{ steps.check-non-source.outputs.any_modified == 'true' || steps.check-source.outputs.any_modified == 'true' }}" | |
has_source_change: "${{ steps.check-source.outputs.any_modified == 'true' }}" | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Check for any non-source code changes | |
id: check-non-source | |
uses: tj-actions/changed-files@v45 | |
with: | |
files: | | |
.github/actions/** | |
.github/workflows/** | |
go.mod | |
go.sum | |
- name: Check for any source code changes | |
id: check-source | |
uses: tj-actions/changed-files@v45 | |
with: | |
files: | | |
**/*.go | |
format: | |
needs: ["changes"] | |
if: | | |
needs.changes.outputs.has_source_change == 'true' && | |
github.actor != 'dependabot[bot]' | |
runs-on: ubuntu-latest | |
timeout-minutes: 4 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# Checkout the "head_ref" (i.e. PR branch HEAD) in case a commit is | |
# later needed. See https://github.com/stefanzweifel/git-auto-commit-action | |
# for more details. | |
ref: ${{ github.head_ref }} | |
# Use a PAT so that GitHub Actions will trigger on the resulting commit. | |
token: ${{ secrets.ACTIONS_BOT }} | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: "go.mod" | |
- name: Check formatting of source code | |
id: format | |
continue-on-error: true | |
run: | | |
go install golang.org/x/tools/cmd/goimports@latest | |
test -z $(gofmt -l .) | |
test -z $(goimports -local github.com/coffeebeats/gdenv -l .) | |
- name: Fix formatting of source code | |
if: steps.format.outcome == 'failure' | |
run: | | |
gofmt -w . | |
goimports -local github.com/coffeebeats/gdenv -w . | |
# See https://github.com/orgs/community/discussions/26560#discussioncomment-3531273 | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config user.name "github-actions[bot]" | |
git add --all '*.go' | |
git commit -m "chore: fix formatting (on behalf of '${{ github.triggering_actor }}')" | |
git push | |
- name: Terminate CI run early | |
if: steps.format.outcome == 'failure' | |
run: exit 1 | |
build: | |
needs: ["changes"] | |
if: needs.changes.outputs.has_change == 'true' | |
runs-on: ubuntu-latest | |
timeout-minutes: 4 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: "go.mod" | |
- name: Build source code | |
run: go build -v ./... | |
lint: | |
needs: ["changes", "build", "format"] | |
if: needs.changes.outputs.has_source_change == 'true' | |
runs-on: ubuntu-latest | |
timeout-minutes: 4 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
cache: false # See https://github.com/golangci/golangci-lint-action/issues/135. | |
go-version-file: "go.mod" | |
- name: Lint source code | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
version: latest | |
test: | |
needs: ["changes", "build"] | |
if: needs.changes.outputs.has_change == 'true' | |
runs-on: ubuntu-latest | |
timeout-minutes: 4 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: "go.mod" | |
- name: Test source code | |
run: go test -race -covermode=atomic -coverprofile=coverage.out ./... | |
- name: Upload coverage report to Codecov | |
uses: codecov/codecov-action@v4 | |
if: needs.changes.outputs.has_source_change == 'true' | |
with: | |
fail_ci_if_error: true | |
flags: gdenv | |
token: ${{ secrets.CODECOV_TOKEN }} | |
# Used to ensure all branch protection requirements are met. This is a workaround until | |
# https://github.com/github-community/community/discussions/4324 is addressed. | |
branch_protection: | |
needs: ["format", "lint", "build", "test"] | |
if: ${{ always() }} | |
runs-on: ubuntu-latest | |
timeout-minutes: 1 | |
steps: | |
- name: Verify 'format' status | |
if: | | |
always() && | |
needs.format.result == 'failure' || | |
needs.format.result == 'cancelled' | |
run: exit 1 | |
- name: Verify 'lint' status | |
if: | | |
always() && | |
needs.lint.result == 'failure' || | |
needs.lint.result == 'cancelled' | |
run: exit 1 | |
- name: Verify 'build' status | |
if: | | |
always() && | |
needs.build.result == 'failure' || | |
needs.build.result == 'cancelled' | |
run: exit 1 | |
- name: Verify 'test' status | |
if: | | |
always() && | |
needs.test.result == 'failure' || | |
needs.test.result == 'cancelled' | |
run: exit 1 |