From b168a7d93e570f15593ab38c5b0e80f04828d845 Mon Sep 17 00:00:00 2001 From: Henrry Pulgarin <39854568+Henrrypg@users.noreply.github.com> Date: Wed, 12 Jun 2024 17:33:59 -0400 Subject: [PATCH] ci: change release workflow - olive (#110) --- .github/workflows/release.yml | 83 ++++++++++------------------------- Makefile | 21 +++++++++ pyproject.toml | 64 +++++++++++++++++++++++++++ setup.cfg | 15 ------- setup.py | 60 ------------------------- 5 files changed, 108 insertions(+), 135 deletions(-) create mode 100644 Makefile create mode 100644 pyproject.toml delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 41edb7cb..67688af6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,67 +1,30 @@ 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: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install dependencies + run: | + pip install -e .[dev] + + - 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..901ff101 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +.DEFAULT_GOAL := help + +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." + +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 new file mode 100644 index 00000000..5a0bcfc1 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,64 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "drydock" +dynamic = ["version"] +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.optional-dependencies] +dev = [ + "python-semantic-release", +] + +[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.setuptools.dynamic] +version = {attr = "drydock.__about__.__version__"} + +[tool.wheel] +universal = true + +[tool.semantic_release] +commit_message = "chore(release): preparing {version}" +version_variables = [ + "drydock/__about__.py:__version__", +] + +[tool.semantic_release.branches.olive] +match = "olive" + +[tool.semantic_release.changelog.environment] +keep_trailing_newline = true diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 62975d57..00000000 --- a/setup.cfg +++ /dev/null @@ -1,15 +0,0 @@ -[bumpversion] -current_version = v15.9.0 -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 63030bd4..00000000 --- a/setup.py +++ /dev/null @@ -1,60 +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.rst"), "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.7", - install_requires=["tutor>=15.0.0,<16.0.0"], - entry_points={ - "tutor.plugin.v1": [ - "drydock = drydock.plugin", - "drydock-backups = drydock_backups.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.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - ], -)