ci: configure release-please dry-run and changelog (#5039)

- Implement a job to preview the release notes
- Include build, ci, and dependency updates
- Add emoji to section headings to match the existing release notes
- Add documentation about how to run release-please from the CLI
This commit is contained in:
Marco Ferrari 2023-12-21 15:03:14 +01:00 committed by GitHub
parent 0bb35c3e60
commit 641c65a8c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 1224 additions and 30 deletions

View file

@ -1,5 +1,31 @@
{
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"changelog-sections": [
{
"section": "⬆️ Dependency updates",
"type": "deps"
},
{
"section": "🚀 Features",
"type": "feat"
},
{
"section": "🐛 Bug fixes",
"type": "fix"
},
{
"section": "🧰 Maintenance",
"type": "build"
},
{
"section": "🧰 Maintenance",
"type": "chore"
},
{
"section": "🧰 Maintenance",
"type": "ci"
}
],
"packages": {
".": {
"changelog-path": "CHANGELOG.md",

View file

@ -114,3 +114,19 @@ jobs:
- name: Run Test Suite
run: make test
preview-release-notes:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup authentication token
run: |
echo "${{ secrets.GITHUB_TOKEN }}" > .github-personal-access-token
- name: Generate a preview of the release notes
run: |
make release-please-dry-run

0
CHANGELOG.md Normal file
View file

View file

@ -73,9 +73,20 @@ endif
GITHUB_TOKEN_PATH := "$(CURDIR)/.github-personal-access-token"
COMMIT_LINTER_CONTAINER_URL := "conventional-changelog/commitlint:latest"
DEV_CONTAINER_URL := "super-linter/dev-container:latest"
.PHONY: inspec
ifeq ($(GITHUB_HEAD_REF),)
RELEASE_PLEASE_TARGET_BRANCH := "$(shell git branch --show-current)"
else
RELEASE_PLEASE_TARGET_BRANCH := "${GITHUB_HEAD_REF}"
endif
.phony: check-github-token
check-github-token:
@if [ ! -f "${GITHUB_TOKEN_PATH}" ]; then echo "Cannot find the file to load the GitHub access token: $(GITHUB_TOKEN_PATH). Create a readable file there, and populate it with a GitHub personal access token."; exit 1; fi
.phony: inspec
inspec: inspec-check ## Run InSpec tests
DOCKER_CONTAINER_STATE="$$(docker inspect --format "{{.State.Running}}" $(SUPER_LINTER_TEST_CONTAINER_NAME) 2>/dev/null || echo "")"; \
if [ "$$DOCKER_CONTAINER_STATE" = "true" ]; then docker kill $(SUPER_LINTER_TEST_CONTAINER_NAME); fi && \
@ -96,8 +107,7 @@ inspec: inspec-check ## Run InSpec tests
&& docker kill $(SUPER_LINTER_TEST_CONTAINER_NAME)
.phony: docker
docker: ## Build the container image
@if [ ! -f "${GITHUB_TOKEN_PATH}" ]; then echo "Cannot find the file to load the GitHub access token: $(GITHUB_TOKEN_PATH). Create a readable file there, and populate it with a GitHub personal access token."; exit 1; fi
docker: check-github-token ## Build the container image
DOCKER_BUILDKIT=1 docker buildx build --load \
--build-arg BUILD_DATE=$(BUILD_DATE) \
--build-arg BUILD_REVISION=$(BUILD_REVISION) \
@ -157,18 +167,35 @@ test-linters: ## Run the linters test suite
-v "$(CURDIR):/tmp/lint" \
$(SUPER_LINTER_TEST_CONTAINER_URL)
.phony: build-commit-linter-container-image
build-commit-linter-container-image: ## Build commit linter container image
.phony: build-dev-container-image
build-dev-container-image: ## Build commit linter container image
DOCKER_BUILDKIT=1 docker buildx build --load \
-t ${COMMIT_LINTER_CONTAINER_URL} "${CURDIR}/dev-dependencies"
-t ${DEV_CONTAINER_URL} "${CURDIR}/dev-dependencies"
.phony: lint-commits
lint-commits: build-commit-linter-container-image ## Lint commits
lint-commits: build-dev-container-image ## Lint commits
docker run \
-v "$(CURDIR):/source-repository" \
${COMMIT_LINTER_CONTAINER_URL} \
${DEV_CONTAINER_URL} \
commitlint \
--config .github/linters/commitlint.config.js \
--cwd /source-repository \
--from ${FROM_INTERVAL_COMMITLINT} \
--to ${TO_INTERVAL_COMMITLINT} \
--verbose
.phony: release-please-dry-run
release-please-dry-run: build-dev-container-image check-github-token ## Run release-please in dry-run mode to preview the release pull request
@echo "Running release-please against branch: ${RELEASE_PLEASE_TARGET_BRANCH}"; \
docker run \
-v "$(CURDIR):/source-repository" \
${DEV_CONTAINER_URL} \
release-please \
release-pr \
--config-file .github/release-please/release-please-config.json \
--dry-run \
--manifest-file .github/release-please/.release-please-manifest.json \
--repo-url super-linter/super-linter \
--target-branch ${RELEASE_PLEASE_TARGET_BRANCH} \
--token "$(shell cat "${GITHUB_TOKEN_PATH}")" \
--trace \

View file

@ -81,8 +81,6 @@ More in-depth [tutorial](https://www.youtube.com/watch?v=EDAmFKO4Zt0&t=118s) ava
To run super-linter as a GitHub Action, you do the following:
<!-- x-release-please-start-major -->
1. Create a new [GitHub Actions workflow](https://docs.github.com/en/actions/using-workflows/about-workflows#about-workflows) in your repository with the following content:
```yaml
@ -109,7 +107,7 @@ To run super-linter as a GitHub Action, you do the following:
uses: actions/checkout@v4
- name: Super-linter
uses: super-linter/super-linter@v5
uses: super-linter/super-linter@v5.7.2 # x-release-please-version
env:
DEFAULT_BRANCH: main
# To report GitHub Actions status checks
@ -121,8 +119,6 @@ To run super-linter as a GitHub Action, you do the following:
1. Push the new commit to the remote repository.
1. Create a new pull request to observe the results.
<!-- x-release-please-end -->
## Add Super-Linter badge in your repository README
You can show Super-Linter status with a badge in your repository README:

View file

@ -4,9 +4,7 @@ author: 'GitHub'
description: 'It is a simple combination of various linters, written in bash, to help validate your source code.'
runs:
using: 'docker'
# x-release-please-start-major
image: 'docker://ghcr.io/super-linter/super-linter:v5'
# x-release-please-end
image: 'docker://ghcr.io/super-linter/super-linter:v5.7.2' # x-release-please-version
branding:
icon: 'check-square'
color: 'white'

View file

@ -11,10 +11,13 @@ WORKDIR /app
COPY package.json ./
RUN jq '.dependencies | to_entries[] | select(.key | startswith("@commitlint/")) | .key + "@" + .value' package.json > commitlint-packages.txt \
&& xargs npm install -g < commitlint-packages.txt \
&& rm package.json commitlint-packages.txt \
&& commitlint --version \
&& git config --global --add safe.directory /source-repository
ENV NPM_PACKAGES_FILE_PATH="npm-packages.txt"
ENTRYPOINT [ "commitlint" ]
RUN jq '.dependencies | to_entries[] | select(.key | startswith("@commitlint/")) | .key + "@" + .value' package.json >> "${NPM_PACKAGES_FILE_PATH}" \
&& jq '.dependencies | to_entries[] | select(.key | startswith("release-please")) | .key + "@" + .value' package.json >> "${NPM_PACKAGES_FILE_PATH}" \
&& xargs npm install -g < "${NPM_PACKAGES_FILE_PATH}" \
&& rm package.json "${NPM_PACKAGES_FILE_PATH}"
RUN commitlint --version \
&& release-please --version \
&& git config --global --add safe.directory /source-repository

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,8 @@
"version": "0.0.1-local",
"dependencies": {
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3"
"@commitlint/config-conventional": "^18.4.3",
"release-please": "^16.5.1"
},
"license": "MIT"
}

View file

@ -4,6 +4,20 @@ The Process to create a super-linter release is as follows:
1. Merge the release pull request.
## Preview the release pull request
In order to have a preview of the next release before merging a pull
request that updates the configuration of the tooling that we use to create
releases, do the following:
1. Run:
```shell
make release-please-dry-run
```
This command also runs as part of the [CI process](../.github/workflows/ci.yml).
## Release workflows
Every push to the default branch triggers GitHub Actions workflows that:
@ -13,4 +27,16 @@ Every push to the default branch triggers GitHub Actions workflows that:
- `super-linter/super-linter:latest`
- `super-linter/super-linter:slim-latest`
- Update to the release pull request.
- Update the next release pull request.
## Release automation tooling
In order to automate releases, we use
[release-please](https://github.com/googleapis/release-please).
We configure release-please using two files:
- [release-please configuration file](../.github/release-please/release-please-config.json):
contains release-please configuration.
- [release-please manifest file](../.github/release-please/.release-please-manifest.json):
contains information about the current release.

View file

@ -4,9 +4,7 @@ author: 'GitHub'
description: 'It is a simple combination of various linters, written in bash, to help validate your source code.'
runs:
using: 'docker'
# x-release-please-start-major
image: 'docker://ghcr.io/super-linter/super-linter:slim-v5'
# x-release-please-end
image: 'docker://ghcr.io/super-linter/super-linter:slim-v5.7.2' # x-release-please-version
branding:
icon: 'check-square'
color: 'white'

1
version.txt Normal file
View file

@ -0,0 +1 @@
5.7.2