diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 8af4f874..620dffd9 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -21,6 +21,40 @@ concurrency: cancel-in-progress: true jobs: + + update-changelog: + name: "Update CHANGELOG (on release)" + if: github.event_name == 'push' && contains(github.ref, 'refs/tags') + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: ansys/actions/doc-deploy-changelog@v6 + with: + token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} + + vulnerabilities: + name: Vulnerabilities + runs-on: ubuntu-latest + steps: + - name: PyAnsys Vulnerability check (on main) + if: github.ref == 'refs/heads/main' + uses: ansys/actions/check-vulnerabilities@v6 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + python-package-name: ${{ env.PACKAGE_NAME }} + token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} + + - name: PyAnsys Vulnerability check (on dev mode) + if: github.ref != 'refs/heads/main' + uses: ansys/actions/check-vulnerabilities@v6 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + python-package-name: ${{ env.PACKAGE_NAME }} + token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} + dev-mode: true + branch-name: if: github.event_name == 'pull_request' name: Check the name of the branch diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml new file mode 100644 index 00000000..3926690d --- /dev/null +++ b/.github/workflows/label.yml @@ -0,0 +1,97 @@ +name: Labeler + +on: + pull_request: + # opened, reopened, and synchronize are default for pull_request + # edited - when PR title or body is changed + # labeled - when labels are added to PR + types: [opened, reopened, synchronize, edited, labeled] + push: + branches: [ main ] + paths: + - '../labels.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + label-syncer: + name: Syncer + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: micnncim/action-label-syncer@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + labeler: + name: Set labels + needs: [label-syncer] + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + # Label based on modified files + - name: Label based on changed files + uses: actions/labeler@v5 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + sync-labels: true + + - uses: actions-ecosystem/action-add-labels@v1 + if: | + startsWith(github.event.pull_request.head.ref, 'doc') || + startsWith(github.event.pull_request.head.ref, 'docs') + with: + labels: documentation + - uses: actions-ecosystem/action-add-labels@v1 + if: | + startsWith(github.event.pull_request.head.ref, 'maint') || + startsWith(github.event.pull_request.head.ref, 'no-ci') || + startsWith(github.event.pull_request.head.ref, 'ci') + with: + labels: maintenance + + - uses: actions-ecosystem/action-add-labels@v1 + if: startsWith(github.event.pull_request.head.ref, 'feat') + with: + labels: enhancement + + - uses: actions-ecosystem/action-add-labels@v1 + if: | + startsWith(github.event.pull_request.head.ref, 'fix') || + startsWith(github.event.pull_request.head.ref, 'patch') + with: + labels: bug + + commenter: + runs-on: ubuntu-latest + steps: + - name: Suggest to add labels + uses: peter-evans/create-or-update-comment@v4 + # Execute only when no labels have been applied to the pull request + if: toJSON(github.event.pull_request.labels.*.name) == '{}' + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + Please add one of the following labels to add this contribution to the Release Notes :point_down: + - [bug](https://github.com/ansys/ansys-tools-visualization-interface/pulls?q=label%3Abug+) + - [documentation](https://github.com/ansys/ansys-tools-visualization-interface/pulls?q=label%3Adocumentation+) + - [enhancement](https://github.com/ansys/ansys-tools-visualization-interface/pulls?q=label%3Aenhancement+) + - [good first issue](https://github.com/ansys/ansys-tools-visualization-interface/pulls?q=label%3Agood+first+issue) + - [maintenance](https://github.com/ansys/ansys-tools-visualization-interface/pulls?q=label%3Amaintenance+) + - [release](https://github.com/ansys/ansys-tools-visualization-interface/pulls?q=label%3Arelease+) + + changelog-fragment: + name: "Create changelog fragment" + needs: [labeler] + permissions: + contents: write + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: ansys/actions/doc-changelog@v6 + with: + token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..8040b0f4 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +This project uses [towncrier](https://towncrier.readthedocs.io/) and the changes for the upcoming release can be found in . + + \ No newline at end of file diff --git a/doc/changelog.d/58.added.md b/doc/changelog.d/58.added.md new file mode 100644 index 00000000..66e50ac8 --- /dev/null +++ b/doc/changelog.d/58.added.md @@ -0,0 +1 @@ +feat: add changelog and vulnerability check \ No newline at end of file diff --git a/doc/changelog.d/changelog_template.jinja b/doc/changelog.d/changelog_template.jinja new file mode 100644 index 00000000..0cf429a3 --- /dev/null +++ b/doc/changelog.d/changelog_template.jinja @@ -0,0 +1,15 @@ +{% if sections[""] %} +{% for category, val in definitions.items() if category in sections[""] %} + +### {{ definitions[category]['name'] }} + +{% for text, values in sections[""][category].items() %} +- {{ text }} {{ values|join(', ') }} +{% endfor %} + +{% endfor %} +{% else %} +No significant changes. + + +{% endif %} diff --git a/pyproject.toml b/pyproject.toml index ffd57162..7318bd95 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi" [project] name = "ansys-tools-visualization-interface" -version = "0.2.dev0" +version = "0.3.dev0" description = "A Python visualization interface for PyAnsys libraries" readme = "README.rst" requires-python = ">=3.9,<4" @@ -91,3 +91,38 @@ known-first-party = ["ansys"] [tool.ruff.lint.pydocstyle] # Settings: https://docs.astral.sh/ruff/settings/#lintpydocstyle convention = "google" + +[tool.towncrier] +package = "ansys.tools.visualization_interface" +directory = "doc/changelog.d" +filename = "CHANGELOG.md" +start_string = "\n" +underlines = ["", "", ""] +template = "doc/changelog.d/changelog_template.jinja" +title_format = "## [{version}](https://github.com/ansys/{repo-name}/releases/tag/v{version}) - {project_date}" +issue_format = "[#{issue}](https://github.com/ansys/{repo-name}/pull/{issue})" + +[[tool.towncrier.type]] +directory = "added" +name = "Added" +showcontent = true + +[[tool.towncrier.type]] +directory = "changed" +name = "Changed" +showcontent = true + +[[tool.towncrier.type]] +directory = "fixed" +name = "Fixed" +showcontent = true + +[[tool.towncrier.type]] +directory = "dependencies" +name = "Dependencies" +showcontent = true + +[[tool.towncrier.type]] +directory = "miscellaneous" +name = "Miscellaneous" +showcontent = true \ No newline at end of file