Skip to content

Commit

Permalink
version: bump to 0.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
waltzofpearls committed Jan 26, 2023
1 parent 91df703 commit 6a285a7
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
on:
push:
tags:
- "v*.*.*" # push events to matching v*.*.*, i.e. v0.1.8, v20.15.10
- "v*.*.*" # push events to matching v*.*.*, i.e. v0.1.5, v20.15.10

jobs:
build-linux:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: ci
on: [push, pull_request]
on: [ push, pull_request ]

jobs:
check:
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 37 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
.PHONY: help
help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: build
build:
build: ## Build release with cargo for the current OS
cargo build --release

.PHONY: lint
lint:
lint: ## Run clippy linter
cargo clippy --workspace --tests --all-features -- -D warnings

.PHONY: test
test:
test: ## Run unit tests
RUST_BACKTRACE=1 cargo test

.PHONY: cover
cover:
cover: ## Generate test coverage report
docker run \
--security-opt seccomp=unconfined \
-v ${PWD}:/volume \
Expand All @@ -20,31 +24,18 @@ cover:
cargo tarpaulin --color auto --out Html --output-dir ./target
open target/tarpaulin-report.html

.PHONY: cross
cross: build
docker build -t $(APP)/cross -f cross.Dockerfile .
docker run -it --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $$PWD:/src/$(APP) \
-w /src/$(APP) \
$(APP)/cross \
/bin/bash -c ' \
cross build --target x86_64-unknown-linux-gnu --release && \
cross build --target x86_64-unknown-linux-musl --release && \
cross build --target armv7-unknown-linux-gnueabihf --release \
'

.PHONY: bench
bench:
bench: ## Generate benchmark report
cargo bench --bench parse -- --verbose
open target/criterion/report/index.html

APP = belt
VERSION := $(shell cargo metadata -q | jq -r '.packages[] | select(.name == "$(APP)") | .version')
UNAME_S := $(shell uname -s)
NEXT_VERSION := $(shell echo "$(VERSION)" | awk -F. -v OFS=. '{$$NF += 1 ; print}')

.PHONY: package
package:
package: ## Make release package based on the current OS
ifdef OS # windows
mkdir -p target/package
tar -a -cvf target/package/$(APP)-$(VERSION)-windows-x86_64-msvc.zip \
Expand All @@ -61,13 +52,34 @@ else ifeq ($(UNAME_S),Linux) # linux
-C $$PWD LICENSE README.md
endif

version:
.PHONY: show-version-files
show-version-files: ## Find all files with the current version
@grep -rn --color \
--exclude-dir ./target \
--exclude-dir ./.git \
--exclude-dir={target,.git} \
--exclude Cargo.lock \
--fixed-strings '$(VERSION)' .
--fixed-strings '"$(VERSION)"' .

.PHONY: bump-version
bump-version: ## Bump version in files that contain the current version
@echo "Bumping version $(VERSION) -> $(NEXT_VERSION)..."
@for file in $(shell grep -rl --exclude-dir={target,.git} --exclude Cargo.lock --fixed-strings '"$(VERSION)"' .); do \
echo "In file $$file"; \
sed -i '' -e 's/$(VERSION)/$(NEXT_VERSION)/g' $$file; \
done
@echo
@echo "Bumped version in the following files:"
@make show-version-files

.PHONY: release
release: ## Make a new tag based on the version from Cargo.toml and push to GitHub
@if [[ "$(shell git tag -l)" == *"v$(VERSION)"* ]]; then \
echo "Tag v$(VERSION) already exists"; \
else \
echo "Tagging v$(VERSION) and pushing to GitHub..."; \
git tag -a v$(VERSION) -m "Release v$(VERSION)"; \
git push origin v$(VERSION); \
fi

.PHONY: publish
publish:
publish: ## Publish to crates.io
cargo publish --manifest-path dateparser/Cargo.toml
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,34 @@ Date string in the following formats can be parsed by `belt`:
// chinese yyyy mm dd
"2014年04月08日",
```

## How to make a new release

List files that need to be updated with new version number:

```shell
make show-version-files
```

It will output something like this:

```shell
./dateparser/Cargo.toml:3:version = "0.1.8"
./dateparser/README.md:26:dateparser = "0.1.8"
./dateparser/README.md:60:dateparser = "0.1.8"
./belt/Cargo.toml:3:version = "0.1.8"
```

Next, manually update verion numbers in those listed files or automatically bump the version with,
`make bump-verison`. When auto incrementing version with `make bump-version`, it will only bump the
patch version, for example, 0.1.8 will become 0.1.9.

**NOTE**: you may need to run `cargo run` to update `belt` and `dateparser` versions in `Cargo.lock`
file.

Once version numbers are updated in files, run the following command to tag the new version and push to
GitHub. This will trigger build and release workflow in GitHub Actions:

```shell
make release
```
2 changes: 1 addition & 1 deletion belt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "belt"
version = "0.1.7"
version = "0.1.8"
authors = ["Rollie Ma <[email protected]>"]
edition = "2018"
publish = false
Expand Down
2 changes: 1 addition & 1 deletion dateparser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dateparser"
version = "0.1.7"
version = "0.1.8"
authors = ["Rollie Ma <[email protected]>"]
description = "Parse dates in string formats that are commonly used"
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions dateparser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Add to your `Cargo.toml`:

```toml
[dependencies]
dateparser = "0.1.7"
dateparser = "0.1.8"
```

And then use `dateparser` in your code:
Expand Down Expand Up @@ -57,7 +57,7 @@ Convert returned `DateTime<Utc>` to pacific time zone datetime with `chrono-tz`:
```toml
[dependencies]
chrono-tz = "0.6.3"
dateparser = "0.1.7"
dateparser = "0.1.8"
```

```rust
Expand Down

0 comments on commit 6a285a7

Please sign in to comment.