Skip to content

Commit

Permalink
ci: change release workflow (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrrypg authored Jun 12, 2024
1 parent f21d338 commit 2ecac04
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 132 deletions.
83 changes: 23 additions & 60 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
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/[email protected]
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/[email protected]
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 }}
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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}'
64 changes: 64 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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.main]
match = "(main|master)"

[tool.semantic_release.changelog.environment]
keep_trailing_newline = true
15 changes: 0 additions & 15 deletions setup.cfg

This file was deleted.

57 changes: 0 additions & 57 deletions setup.py

This file was deleted.

0 comments on commit 2ecac04

Please sign in to comment.