Skip to content

Commit

Permalink
replace bumpversion with make update-version command
Browse files Browse the repository at this point in the history
- remove bumpversion
- add command update-version to Makefile
- update the use of make command
  • Loading branch information
CunliangGeng committed Jun 20, 2024
1 parent f9e0020 commit 219ce86
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 28 deletions.
17 changes: 0 additions & 17 deletions .bumpversion.cfg

This file was deleted.

3 changes: 1 addition & 2 deletions .github/workflows/publish_gh_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ jobs:
- name: Upgrade pip and install dependencies
run: |
python3 -m pip install --upgrade pip
pip install bump2version
- name: Update package version and change log
run: |
bumpversion --current-version ${{ inputs.current_version }} --new-version ${{ inputs.new_version }} fake
make update-version CURRENT_VERSION=${{ inputs.current_version }} NEW_VERSION=${{ inputs.new_version }}
docker run --rm -v "$(pwd)":/usr/local/src/your-app \
githubchangeloggenerator/github-changelog-generator \
-u ${{ github.repository_owner }} \
Expand Down
32 changes: 31 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: clean clean-build clean-pyc clean-test release build
.PHONY: clean clean-build clean-pyc clean-test release build update-version

help:
@echo "clean - remove all build, test, coverage and Python artifacts"
Expand All @@ -8,6 +8,7 @@ help:
@echo "release - upload package to pypi"
@echo "build - build package"
@echo "update - update pip, build, twine packages"
@echo "update-version - update NPLinker version. Usage: make update-version CURRENT_VERSION=0.1.0 NEW_VERSION=0.2.0"

clean: clean-build clean-pyc clean-test

Expand Down Expand Up @@ -44,3 +45,32 @@ venv:

clean-venv:
rm -rf venv


# Define the files to update version
FILES := src/nplinker/__init__.py pyproject.toml CITATION.cff

# Rule to update the version in the specified files
update-version:
ifndef CURRENT_VERSION
$(error CURRENT_VERSION is not provided. Usage: make update-version CURRENT_VERSION=0.1.0 NEW_VERSION=0.2.0)
endif
ifndef NEW_VERSION
$(error NEW_VERSION is not provided. Usage: make update-version CURRENT_VERSION=0.1.0 NEW_VERSION=0.2.0)
endif
@for file in $(FILES); do \
if ! grep -qE "__version__ = \"$(CURRENT_VERSION)\"|version = \"$(CURRENT_VERSION)\"|version: \"$(CURRENT_VERSION)\"" $$file; then \
echo "Error: Current version $(CURRENT_VERSION) not found in $$file"; \
exit 1; \
fi; \
done

@echo "Updating version from $(CURRENT_VERSION) to $(NEW_VERSION) for following files:"
@for file in $(FILES); do \
echo " $$file"; \
sed -i '' 's/__version__ = "$(CURRENT_VERSION)"/__version__ = "$(NEW_VERSION)"/' $$file; \
sed -i '' 's/version = "$(CURRENT_VERSION)"/version = "$(NEW_VERSION)"/' $$file; \
sed -i '' 's/version: "$(CURRENT_VERSION)"/version: "$(NEW_VERSION)"/' $$file; \
done
@echo "Version update complete."
@find . -name "*.bak" -type f -delete
8 changes: 2 additions & 6 deletions README.dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,10 @@ All these mike operations will be recorded as git commits of branch `gh-pages`.

## Versioning

Bumping the version across all files is done with [bumpversion](https://github.com/c4urself/bump2version), e.g.
Updating the version of the NPLinker package is done with make command `update-version`, e.g.

```shell
bumpversion major
bumpversion minor
bumpversion patch

bumpversion --current-version 2.0.0 --new-version 2.1.0 fakepart
make update-version CURRENT_VERSION=0.0.1 NEW_VERSION=0.0.2
```

## Making a release
Expand Down
2 changes: 1 addition & 1 deletion project_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ help you decide which tool to use for packaging.
## Package version number

- We recommend using [semantic versioning](https://guide.esciencecenter.nl/#/best_practices/releases?id=semantic-versioning).
- For convenience, the package version is stored in a single place: `nplinker/.bumpversion.cfg`.
- You can update the version using make command, e.g. `make update-version CURRENT_VERSION=0.0.1 NEW_VERSION=0.0.2`.
- Don't forget to update the version number before [making a release](https://guide.esciencecenter.nl/#/best_practices/releases)!

## Logging
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ dependencies = [
dev = [
# packaging
"build",
"bump2version",
"wheel",
# formatting and linting
"ruff",
Expand Down

0 comments on commit 219ce86

Please sign in to comment.