diff --git a/.github/workflows/minor-release-pr.yml b/.github/workflows/minor-release-pr.yml new file mode 100644 index 000000000000..59581fa976d3 --- /dev/null +++ b/.github/workflows/minor-release-pr.yml @@ -0,0 +1,21 @@ +--- +name: 'create release PR for minor releases' +on: + push: + branches: + - 'k[0-9]*' + workflow_dispatch: {} +permissions: + contents: 'write' + issues: 'write' + pull-requests: 'write' +jobs: + create-release-pr: + uses: github/loki-release/.github/workflows/release-pr.yml@main + with: + release_repo: grafana/loki + skip_validation: false + versioning_strategy: always-bump-minor + secrets: + GCS_SERVICE_ACCOUNT_KEY: '${{ secrets.BACKEND_ENTERPRISE_DRONE }}' + GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}' diff --git a/.github/workflows/patch-release-pr.yml b/.github/workflows/patch-release-pr.yml new file mode 100644 index 000000000000..001b00d93b66 --- /dev/null +++ b/.github/workflows/patch-release-pr.yml @@ -0,0 +1,21 @@ +--- +name: 'create release PR for patch releases' +on: + push: + branches: + - 'release-[0-9].[0-9].x' + workflow_dispatch: {} +permissions: + contents: 'write' + issues: 'write' + pull-requests: 'write' +jobs: + create-release-pr: + uses: github/loki-release/.github/workflows/release-pr.yml@main + with: + release_repo: grafana/loki + skip_validation: false + versioning_strategy: always-bump-patch + secrets: + GCS_SERVICE_ACCOUNT_KEY: '${{ secrets.BACKEND_ENTERPRISE_DRONE }}' + GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000000..cacdacf773a8 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,19 @@ +--- +name: 'create release' +on: + push: + branches: + - 'release-[0-9].[0-9].x' + - 'k[0-9]*' + workflow_dispatch: {} +permissions: + contents: write + pull-requests: write +jobs: + release: + uses: github/loki-release/.github/workflows/release.yml@main + with: + release_repo: grafana/loki + secrets: + GCS_SERVICE_ACCOUNT_KEY: '${{ secrets.BACKEND_ENTERPRISE_DRONE }}' + GH_TOKEN: '${{ secrets.GH_TOKEN }}' diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 000000000000..0e134950eab8 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,6 @@ +{ + "cmd/loki": "2.9.4", + "cmd/loki-canary": "2.9.4", + "cmd/logcli": "2.9.4", + "clients/cmd/promtail": "2.9.4" +} diff --git a/Makefile b/Makefile index 09701ca053ab..928dea57aeb4 100644 --- a/Makefile +++ b/Makefile @@ -281,7 +281,16 @@ cmd/migrate/migrate: ############# GOX = gox $(GO_FLAGS) -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}" CGO_GOX = gox $(DYN_GO_FLAGS) -cgo -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}" + +SKIP_ARM ?= false dist: clean +ifeq ($(SKIP_ARM),true) + CGO_ENABLED=0 $(GOX) -osarch="linux/amd64 darwin/amd64 windows/amd64 freebsd/amd64" ./cmd/loki + CGO_ENABLED=0 $(GOX) -osarch="linux/amd64 darwin/amd64 windows/amd64 freebsd/amd64" ./cmd/logcli + CGO_ENABLED=0 $(GOX) -osarch="linux/amd64 darwin/amd64 windows/amd64 freebsd/amd64" ./cmd/loki-canary + CGO_ENABLED=0 $(GOX) -osarch="darwin/amd64 windows/amd64 windows/386 freebsd/amd64" ./clients/cmd/promtail + CGO_ENABLED=1 $(CGO_GOX) -tags promtail_journal_enabled -osarch="linux/amd64" ./clients/cmd/promtail +else CGO_ENABLED=0 $(GOX) -osarch="linux/amd64 linux/arm64 linux/arm darwin/amd64 darwin/arm64 windows/amd64 freebsd/amd64" ./cmd/loki CGO_ENABLED=0 $(GOX) -osarch="linux/amd64 linux/arm64 linux/arm darwin/amd64 darwin/arm64 windows/amd64 freebsd/amd64" ./cmd/logcli CGO_ENABLED=0 $(GOX) -osarch="linux/amd64 linux/arm64 linux/arm darwin/amd64 darwin/arm64 windows/amd64 freebsd/amd64" ./cmd/loki-canary @@ -289,6 +298,7 @@ dist: clean PKG_CONFIG_PATH="/usr/lib/aarch64-linux-gnu/pkgconfig" CC="aarch64-linux-gnu-gcc" $(CGO_GOX) -tags promtail_journal_enabled -osarch="linux/arm64" ./clients/cmd/promtail PKG_CONFIG_PATH="/usr/lib/arm-linux-gnueabihf/pkgconfig" CC="arm-linux-gnueabihf-gcc" $(CGO_GOX) -tags promtail_journal_enabled -osarch="linux/arm" ./clients/cmd/promtail CGO_ENABLED=1 $(CGO_GOX) -tags promtail_journal_enabled -osarch="linux/amd64" ./clients/cmd/promtail +endif for i in dist/*; do zip -j -m $$i.zip $$i; done pushd dist && sha256sum * > SHA256SUMS && popd @@ -307,7 +317,7 @@ publish: packages lint: ## run linters go version golangci-lint version - GO111MODULE=on golangci-lint run -v + GO111MODULE=on golangci-lint run -v --timeout 15m faillint -paths "sync/atomic=go.uber.org/atomic" ./... ######## @@ -786,30 +796,37 @@ check-doc: doc ################### # Example Configs # ################### +EXAMPLES_DOC_PATH := $(DOC_SOURCES_PATH)/configure/examples +EXAMPLES_DOC_OUTPUT_PATH := $(EXAMPLES_DOC_PATH)/configuration-examples.md +EXAMPLES_YAML_PATH := $(EXAMPLES_DOC_PATH)/yaml +EXAMPLES_SKIP_VALIDATION_FLAG := "doc-example:skip-validation=true" # Validate the example configurations that we provide in ./docs/sources/configure/examples +# We run the validation only for complete examples, not snippets. +# Complete examples should contain "Example" in their file name. validate-example-configs: loki - for f in ./docs/sources/configure/examples/*.yaml; do echo "Validating provided example config: $$f" && ./cmd/loki/loki -config.file=$$f -verify-config || exit 1; sleep 1; done + for f in $$(grep -rL $(EXAMPLES_SKIP_VALIDATION_FLAG) $(EXAMPLES_YAML_PATH)/*.yaml); do echo "Validating provided example config: $$f" && ./cmd/loki/loki -config.file=$$f -verify-config || exit 1; done + +validate-dev-cluster-config: loki + ./cmd/loki/loki -config.file=./tools/dev/loki-boltdb-storage-s3/config/loki.yaml -verify-config # Dynamically generate ./docs/sources/configure/examples.md using the example configs that we provide. # This target should be run if any of our example configs change. generate-example-config-doc: - $(eval CONFIG_DOC_PATH=$(DOC_SOURCES_PATH)/configure) - $(eval CONFIG_EXAMPLES_PATH=$(CONFIG_DOC_PATH)/examples) - echo "Removing existing doc at $(CONFIG_DOC_PATH)/examples.md and re-generating. . ." + echo "Removing existing doc at $(EXAMPLES_DOC_OUTPUT_PATH) and re-generating. . ." # Title and Heading - echo -e "---\ntitle: Examples\ndescription: Loki Configuration Examples\n---\n # Examples" > $(CONFIG_DOC_PATH)/examples.md + echo -e "---\ntitle: Configuration\ndescription: Loki Configuration Examples and Snippets\nweight: 100\n---\n# Configuration" > $(EXAMPLES_DOC_OUTPUT_PATH) # Append each configuration and its file name to examples.md - for f in $$(find $(CONFIG_EXAMPLES_PATH)/*.yaml -printf "%f\n" | sort -k1n); do \ - echo -e "\n## $$f\n\n\`\`\`yaml\n" >> $(CONFIG_DOC_PATH)/examples.md; \ - cat $(CONFIG_EXAMPLES_PATH)/$$f >> $(CONFIG_DOC_PATH)/examples.md; \ - echo -e "\n\`\`\`\n" >> $(CONFIG_DOC_PATH)/examples.md; \ + for f in $$(find $(EXAMPLES_YAML_PATH)/*.yaml -printf "%f\n" | sort -k1n); do \ + echo -e "\n## $$f\n\n\`\`\`yaml\n" >> $(EXAMPLES_DOC_OUTPUT_PATH); \ + grep -v $(EXAMPLES_SKIP_VALIDATION_FLAG) $(EXAMPLES_YAML_PATH)/$$f >> $(EXAMPLES_DOC_OUTPUT_PATH); \ + echo -e "\n\`\`\`\n" >> $(EXAMPLES_DOC_OUTPUT_PATH); \ done # Fail our CI build if changes are made to example configurations but our doc is not updated check-example-config-doc: generate-example-config-doc - @if ! (git diff --exit-code ./docs/sources/configure/examples.md); then \ + @if ! (git diff --exit-code $(EXAMPLES_DOC_OUTPUT_PATH)); then \ echo -e "\nChanges found in generated example configuration doc"; \ echo "Run 'make generate-example-config-doc' and commit the changes to fix this error."; \ echo "If you are actively developing these files you can ignore this error"; \