Skip to content

Commit f18744d

Browse files
committed
ci: Add dangerjs, pre-commit and new release workflows to github actions
1 parent 352f880 commit f18744d

File tree

4 files changed

+108
-0
lines changed

4 files changed

+108
-0
lines changed

.cz.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[tool.commitizen]
2+
name = "czespressif"
3+
version = "0.0.0"
4+
update_changelog_on_bump = true
5+
tag_format = "v$version"
6+
changelog_merge_prerelease = true
7+
annotated_tag = true
8+
changelog_start_rev = "v1.0.0"
9+
bump_message = "change: Update version to $new_version"

.github/workflows/dangerjs.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: DangerJS Check
2+
on:
3+
pull_request_target:
4+
types: [opened, edited, reopened, synchronize]
5+
6+
permissions:
7+
pull-requests: write
8+
contents: write
9+
10+
jobs:
11+
pull-request-style-linter:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out PR head
15+
uses: actions/checkout@v4
16+
with:
17+
ref: ${{ github.event.pull_request.head.sha }}
18+
19+
- name: DangerJS pull request linter
20+
uses: espressif/github-actions/danger_pr_review@master
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/new_release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Create a new release from a tag
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
create_release:
10+
name: Create GitHub release
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- name: Get version
16+
id: get_version
17+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
18+
shell: bash
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
- name: Install dependencies
24+
run: pip install commitizen czespressif>=1.3.1
25+
- name: Generate changelog
26+
run: |
27+
cz changelog ${{ steps.get_version.outputs.VERSION }} --file-name changelog_body.md
28+
cat changelog_body.md
29+
- name: Create release
30+
uses: softprops/action-gh-release@v1
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
with:
34+
body_path: changelog_body.md
35+
name: Version ${{ steps.get_version.outputs.VERSION }}
36+
draft: true
37+
prerelease: false

.github/workflows/pre_commit.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Check pre-commit rules
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
pre_commit_check:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
- name: Fetch head and base refs
17+
# This is necessary for pre-commit to check the changes in the PR branch
18+
run: |
19+
git fetch origin ${{ github.base_ref }}:base_ref
20+
git fetch origin pull/${{ github.event.pull_request.number }}/head:pr_ref
21+
- name: Set up Python environment
22+
uses: actions/setup-python@master
23+
with:
24+
python-version: v3.11
25+
- name: Install python packages
26+
run: |
27+
pip install pre-commit
28+
pre-commit install-hooks
29+
- name: Run pre-commit and check for any changes
30+
run: |
31+
echo "Commits being checked:"
32+
git log --oneline --no-decorate base_ref..pr_ref
33+
echo ""
34+
if ! pre-commit run --from-ref base_ref --to-ref pr_ref --show-diff-on-failure ; then
35+
echo ""
36+
echo "::notice::It looks like the commits in this PR have been made without having pre-commit hooks installed."
37+
echo "::notice::Please see https://github.com/espressif/esp-usb-bridge?tab=readme-ov-file#contributing for instructions."
38+
echo ""
39+
exit 1
40+
fi

0 commit comments

Comments
 (0)