From 0610861b3c10a0e0ec5cfad37ecfacf983625af1 Mon Sep 17 00:00:00 2001 From: jingxiaoping Date: Thu, 6 Feb 2025 17:59:13 +0800 Subject: [PATCH] add workflow Change-Id: I926c42126cafa8c03674a851b478d17058bd3ac7 --- .github/workflows/auto_format_docs.yml | 44 +++++++++++++++++++++++ .github/workflows/auto_format_python.yml | 45 ++++++++++++++++++++++++ .github/workflows/auto_release.yml | 39 +++++++------------- 3 files changed, 102 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/auto_format_docs.yml create mode 100644 .github/workflows/auto_format_python.yml diff --git a/.github/workflows/auto_format_docs.yml b/.github/workflows/auto_format_docs.yml new file mode 100644 index 0000000..bb98ae7 --- /dev/null +++ b/.github/workflows/auto_format_docs.yml @@ -0,0 +1,44 @@ +name: Format Code + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + format: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: "16" + + - name: Install Prettier + run: | + npm install --save-dev prettier + + - name: Format YAML and Markdown files + run: | + npx prettier --write "**/*.yml" "**/*.md" + + - name: Check for changes + id: check_changes + run: | + git diff --exit-code || echo "Changes detected" + + - name: Commit changes + if: steps.check_changes.outputs.exit_code != 0 + run: | + git config --local user.name "github-actions" + git config --local user.email "github-actions@github.com" + git add . + git commit -m "Format YAML and Markdown files with Prettier" || echo "No changes to commit" + git push diff --git a/.github/workflows/auto_format_python.yml b/.github/workflows/auto_format_python.yml new file mode 100644 index 0000000..65ba8c9 --- /dev/null +++ b/.github/workflows/auto_format_python.yml @@ -0,0 +1,45 @@ +name: Auto Format Python Code with Black + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + format: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.9" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install black + + - name: Run Black + run: | + black . + + - name: Check for changes + id: check_changes + run: | + git diff --exit-code || echo "Changes detected" + + - name: Commit changes + if: steps.check_changes.outputs.exit_code != 0 + run: | + git config --local user.name "github-actions" + git config --local user.email "github-actions@github.com" + git add . + git commit -m "Format Python code with Black" || echo "No changes to commit" + git push diff --git a/.github/workflows/auto_release.yml b/.github/workflows/auto_release.yml index 65ba8c9..46080b4 100644 --- a/.github/workflows/auto_release.yml +++ b/.github/workflows/auto_release.yml @@ -1,15 +1,11 @@ -name: Auto Format Python Code with Black +name: Release on: - push: - branches: - - main - pull_request: - branches: - - main + release: + types: [created] jobs: - format: + build: runs-on: ubuntu-latest steps: @@ -21,25 +17,16 @@ jobs: with: python-version: "3.9" - - name: Install dependencies + - name: Install build dependencies run: | - python -m pip install --upgrade pip - pip install black + python -m pip install --upgrade pip setuptools wheel - - name: Run Black + - name: Build the package run: | - black . + python setup.py bdist_wheel - - name: Check for changes - id: check_changes - run: | - git diff --exit-code || echo "Changes detected" - - - name: Commit changes - if: steps.check_changes.outputs.exit_code != 0 - run: | - git config --local user.name "github-actions" - git config --local user.email "github-actions@github.com" - git add . - git commit -m "Format Python code with Black" || echo "No changes to commit" - git push + - name: Upload the package + uses: actions/upload-artifact@v4 + with: + name: python-package + path: dist/*.whl \ No newline at end of file