Skip to content

Commit

Permalink
Port changes for crates.io publish from tsumugu
Browse files Browse the repository at this point in the history
  • Loading branch information
taoky committed Aug 26, 2024
1 parent 80ac7f6 commit c68c951
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Generate Cargo.toml.cache (Ignore version=)
run: |
sed '/^version = /d' Cargo.toml > Cargo.toml.cache
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
target
key: musl-cargo-${{ hashFiles('**/Cargo.toml') }}
key: musl-cargo-${{ hashFiles('./Cargo.toml.cache') }}
- name: Remove files for a build with correct version info
run: |
find target/ -name 'shadow*' -exec rm -r {} + || true
find target/ -name 'tsumugu' -delete || true
find target/ -name 'yukina' -delete || true
- name: Test & Compile
run: |
mkdir -p ~/.cargo/{git,registry}
Expand Down Expand Up @@ -65,3 +68,8 @@ jobs:
path: |
target/x86_64-unknown-linux-musl/release/yukina
target/x86_64-unknown-linux-musl/release/kv
- name: Release to crates.io
if: startsWith(github.ref, 'refs/tags/')
uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
Cargo.toml.cache
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.PHONY: check release

check:
cargo fmt --check
cargo clippy
cargo test

release:
ifndef version
$(error version is not set. Usage: make release version=<version> msg="<msg>")
endif
ifndef msg
$(error msg is not set. Usage: make release version=<version> msg="<msg>")
endif
@full_version=$(shell echo $(version) | grep -q '\.' && echo "0.$(version)" || echo "0.$(version).0"); \
echo $$full_version; \
cargo set-version $$full_version; \
git commit -a -m "Bump version to $$full_version" ; \
git tag $(version) -m "$(msg)"
echo "Run 'git push' and 'git push --tag' afterwards."

0 comments on commit c68c951

Please sign in to comment.