Skip to content

Commit

Permalink
ci: configure release-please dry-run and changelog (#5039)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
ferrarimarco committed Dec 21, 2023
1 parent 0bb35c3 commit 641c65a
Show file tree
Hide file tree
Showing 12 changed files with 1,224 additions and 30 deletions.
26 changes: 26 additions & 0 deletions .github/release-please/release-please-config.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Empty file added CHANGELOG.md
Empty file.
45 changes: 36 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand All @@ -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) \
Expand Down Expand Up @@ -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 \
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
15 changes: 9 additions & 6 deletions dev-dependencies/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"

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}"

ENTRYPOINT [ "commitlint" ]
RUN commitlint --version \
&& release-please --version \
&& git config --global --add safe.directory /source-repository
Loading

0 comments on commit 641c65a

Please sign in to comment.