From 074bad85db5529a182f243e48ce5716e6dd71e7e Mon Sep 17 00:00:00 2001 From: henrrypg Date: Wed, 5 Jun 2024 16:23:50 -0500 Subject: [PATCH 1/3] ci: change release workflow --- .github/workflows/release.yml | 80 +++++++++-------------------------- pyproject.toml | 29 +++++++++++++ 2 files changed, 49 insertions(+), 60 deletions(-) create mode 100644 pyproject.toml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 41edb7cb..56d40c01 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,67 +1,27 @@ name: Release + on: [workflow_dispatch] jobs: - bumpversion: - runs-on: ubuntu-latest - outputs: - version: ${{ steps.tag_version.outputs.new_version }} - previous_tag: ${{ steps.tag_version.outputs.previous_tag }} - bump_commit_sha: ${{ steps.bumpversion.outputs.commit_hash }} - steps: - - uses: actions/checkout@v3 - - name: Get next version - id: tag_version - uses: mathieudutour/github-tag-action@v6.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - default_bump: false - default_prerelease_bump: false - dry_run: true - - name: Set up Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: "3.8" - - name: Create bumpversion - if: steps.tag_version.outputs.new_version - run: | - pip install bump2version - bump2version --new-version ${{ steps.tag_version.outputs.new_version }} setup.cfg - - name: Update Changelog - if: steps.tag_version.outputs.new_version - uses: stefanzweifel/changelog-updater-action@v1.6.2 - with: - latest-version: ${{ steps.tag_version.outputs.new_tag }} - release-notes: ${{ steps.tag_version.outputs.changelog }} - - name: Commit bumpversion - id: bumpversion - if: steps.tag_version.outputs.new_version - uses: stefanzweifel/git-auto-commit-action@v4.14.1 - with: - branch: ${{ github.ref }} - commit_message: "chore(release): preparing ${{ steps.tag_version.outputs.new_version }}" - file_pattern: CHANGELOG.md setup.cfg drydock/* release: - needs: bumpversion - if: needs.bumpversion.outputs.version runs-on: ubuntu-latest - outputs: - tag: ${{ steps.tag_version.outputs.new_tag }} - changelog: ${{ steps.tag_version.outputs.changelog }} + concurrency: release + permissions: + id-token: write + contents: write + steps: - - uses: actions/checkout@v3 - - name: Create tag - id: tag_version - uses: mathieudutour/github-tag-action@v6.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - commit_sha: ${{ needs.bumpversion.outputs.bump_commit_sha }} - default_bump: false - default_prerelease_bump: false - - name: Create a GitHub release - if: steps.tag_version.outputs.new_tag - uses: ncipollo/release-action@v1 - with: - tag: ${{ steps.tag_version.outputs.new_tag }} - name: Release ${{ steps.tag_version.outputs.new_tag }} - body: ${{ steps.tag_version.outputs.changelog }} + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Python Semantic Release + uses: python-semantic-release/python-semantic-release@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + git_committer_name: 'Automatic Release Bot' + git_committer_email: 'support@edunext.co' + commit: true + tag: true + changelog: true + push: true diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..938976f2 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,29 @@ +[tool.semantic_release] +assets = [] +build_command_env = [] +commit_message = "chore(release): preparing {version}" +commit_parser = "angular" +logging_use_named_masks = false +major_on_zero = true +allow_zero_version = true +no_git_verify = false +tag_format = "v{version}" + +[tool.semantic_release.branches.main] +match = "(main|master)" +prerelease = false + +[tool.semantic_release.changelog] +changelog_file = "CHANGELOG.md" + +[tool.semantic_release.changelog.environment] +keep_trailing_newline = true + +[tool.semantic_release.commit_author] +env = "GIT_COMMIT_AUTHOR" +default = "semantic-release " + +[tool.semantic_release.commit_parser_options] +allowed_tags = ["build", "chore", "ci", "docs", "feat", "fix", "perf", "style", "refactor", "test"] +minor_tags = ["feat"] +patch_tags = ["fix", "perf"] From 50d5fd7fceef6e5a6fb98cfa386fbaedd47bfa7e Mon Sep 17 00:00:00 2001 From: henrrypg Date: Thu, 6 Jun 2024 15:14:19 -0500 Subject: [PATCH 2/3] refactor: workflow and use pyproject to keep all setup --- .github/workflows/release.yml | 18 ++++---- Makefile | 18 ++++++++ pyproject.toml | 82 ++++++++++++++++++++++++++--------- setup.cfg | 15 ------- setup.py | 57 ------------------------ 5 files changed, 90 insertions(+), 100 deletions(-) create mode 100644 Makefile delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 56d40c01..50f239d8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,12 +16,14 @@ jobs: fetch-depth: 0 - name: Python Semantic Release - uses: python-semantic-release/python-semantic-release@master + uses: actions/setup-python@v2 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - git_committer_name: 'Automatic Release Bot' - git_committer_email: 'support@edunext.co' - commit: true - tag: true - changelog: true - push: true + python-version: 3.8 + + - name: Install Semantic Release + run: make install-semantic-release + + - name: Run Semantic Release + run: make release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..0cd605eb --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +.DEFAULT_GOAL := help + +install-semantic-release: ## install semantic-release + @echo "Installing semantic-release." + pip install python-semantic-release + +release: ## release a new version + @echo "Releasing a new version." + semantic-release -vv version --changelog --push --tag --commit + +selfcheck: ## check that the Makefile is well-formed + @echo "The Makefile is well-formed." + +ESCAPE = \033 +help: ## Print this help + @grep -E '^([.a-zA-Z_-]+:.*?## .*|######* .+)$$' Makefile \ + | sed 's/######* \(.*\)/@ $(ESCAPE)[1;31m\1$(ESCAPE)[0m/g' | tr '@' '\n' \ + | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[33m%-30s\033[0m %s\n", $$1, $$2}' diff --git a/pyproject.toml b/pyproject.toml index 938976f2..e221eb70 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,29 +1,71 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "drydock" +version = "17.3.4" +description = "A Tutor plugin to manage our opinionated Open edX operations" +readme = "README.md" +requires-python = ">=3.8" +license = { text = "AGPLv3" } +authors = [ + { name = "eduNEXT" } +] +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "License :: OSI Approved :: GNU Affero General Public License v3", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] +dependencies = [ + "tutor>=17.0.2,<18.0.0" +] + +[project.urls] +Homepage = "https://github.com/edunext/drydock" +Code = "https://github.com/edunext/drydock" +"Issue tracker" = "https://github.com/edunext/drydock/issues" + +[tool.setuptools.packages.find] +where = ["."] +exclude = ["tests*"] + +[project.entry-points."tutor.plugin.v1"] +drydock = "drydock.plugin" + +[tool.isort] +include_trailing_comma = true +indent = " " +line_length = 120 +multi_line_output = 3 + +[tool.wheel] +universal = true + [tool.semantic_release] -assets = [] -build_command_env = [] commit_message = "chore(release): preparing {version}" -commit_parser = "angular" -logging_use_named_masks = false -major_on_zero = true -allow_zero_version = true -no_git_verify = false -tag_format = "v{version}" +version_toml = [ + "pyproject.toml:project.version", +] +version_variables = [ + "drydock/__about__.py:__version__", +] [tool.semantic_release.branches.main] match = "(main|master)" -prerelease = false - -[tool.semantic_release.changelog] -changelog_file = "CHANGELOG.md" [tool.semantic_release.changelog.environment] keep_trailing_newline = true -[tool.semantic_release.commit_author] -env = "GIT_COMMIT_AUTHOR" -default = "semantic-release " - -[tool.semantic_release.commit_parser_options] -allowed_tags = ["build", "chore", "ci", "docs", "feat", "fix", "perf", "style", "refactor", "test"] -minor_tags = ["feat"] -patch_tags = ["fix", "perf"] +[tool.semantic_release.remote] +name = "origin" +type = "github" +ignore_token_for_push = false +insecure = false diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index e8e6905a..00000000 --- a/setup.cfg +++ /dev/null @@ -1,15 +0,0 @@ -[bumpversion] -current_version = 17.3.4 -commit = False -tag = False - -[bumpversion:file:drydock/__about__.py] - -[isort] -include_trailing_comma = True -indent = ' ' -line_length = 120 -multi_line_output = 3 - -[wheel] -universal = 1 diff --git a/setup.py b/setup.py deleted file mode 100644 index d71a2405..00000000 --- a/setup.py +++ /dev/null @@ -1,57 +0,0 @@ -import io -import os -from setuptools import setup, find_packages - -HERE = os.path.abspath(os.path.dirname(__file__)) - - -def load_readme(): - with io.open(os.path.join(HERE, "README.md"), "rt", encoding="utf8") as f: - return f.read() - - -def load_about(): - about = {} - with io.open( - os.path.join(HERE, "drydock", "__about__.py"), - "rt", - encoding="utf-8", - ) as f: - exec(f.read(), about) # pylint: disable=exec-used - return about - - -ABOUT = load_about() - - -setup( - name="drydock", - version=ABOUT["__version__"], - url="https://github.com/edunext/drydock", - project_urls={ - "Code": "https://github.com/edunext/drydock", - "Issue tracker": "https://github.com/edunext/drydock/issues", - }, - license="AGPLv3", - author="eduNEXT", - description="A Tutor plugin to manage our opinionated Open edX operations", - long_description=load_readme(), - packages=find_packages(exclude=["tests*"]), - include_package_data=True, - python_requires=">=3.8", - install_requires=["tutor>=17.0.2,<18.0.0"], - entry_points={"tutor.plugin.v1": ["drydock = drydock.plugin"] - }, - classifiers=[ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "License :: OSI Approved :: GNU Affero General Public License v3", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - ], -) From 2d9370a249fff0897927fc70914387d19b459bb3 Mon Sep 17 00:00:00 2001 From: henrrypg Date: Fri, 7 Jun 2024 08:20:51 -0500 Subject: [PATCH 3/3] fix: address suggestions --- .github/workflows/release.yml | 5 +++-- Makefile | 11 +++++++---- pyproject.toml | 23 ++++++++--------------- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 50f239d8..67688af6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,8 +20,9 @@ jobs: with: python-version: 3.8 - - name: Install Semantic Release - run: make install-semantic-release + - name: Install dependencies + run: | + pip install -e .[dev] - name: Run Semantic Release run: make release diff --git a/Makefile b/Makefile index 0cd605eb..901ff101 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,16 @@ .DEFAULT_GOAL := help -install-semantic-release: ## install semantic-release - @echo "Installing semantic-release." - pip install python-semantic-release - release: ## release a new version @echo "Releasing a new version." + @echo "This is a remote release, it will push to the remote repository." semantic-release -vv version --changelog --push --tag --commit +local-release: + @echo "Releasing a new version." + @echo "This is a local release, it will not push to the remote repository." + @echo "You can push the changes and release manually." + semantic-release -vv version --changelog --commit --no-push + selfcheck: ## check that the Makefile is well-formed @echo "The Makefile is well-formed." diff --git a/pyproject.toml b/pyproject.toml index e221eb70..f8b2dbc5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "drydock" -version = "17.3.4" +dynamic = ["version"] description = "A Tutor plugin to manage our opinionated Open edX operations" readme = "README.md" requires-python = ">=3.8" @@ -28,6 +28,11 @@ dependencies = [ "tutor>=17.0.2,<18.0.0" ] +[project.optional-dependencies] +dev = [ + "python-semantic-release", +] + [project.urls] Homepage = "https://github.com/edunext/drydock" Code = "https://github.com/edunext/drydock" @@ -40,20 +45,14 @@ exclude = ["tests*"] [project.entry-points."tutor.plugin.v1"] drydock = "drydock.plugin" -[tool.isort] -include_trailing_comma = true -indent = " " -line_length = 120 -multi_line_output = 3 +[tool.setuptools.dynamic] +version = {attr = "drydock.__about__.__version__"} [tool.wheel] universal = true [tool.semantic_release] commit_message = "chore(release): preparing {version}" -version_toml = [ - "pyproject.toml:project.version", -] version_variables = [ "drydock/__about__.py:__version__", ] @@ -63,9 +62,3 @@ match = "(main|master)" [tool.semantic_release.changelog.environment] keep_trailing_newline = true - -[tool.semantic_release.remote] -name = "origin" -type = "github" -ignore_token_for_push = false -insecure = false