Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI to publish to crates.io (#24)
- Loading branch information
Showing
4 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,6 @@ indent_style = space | |
[*.rs] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[*.{yml,yaml}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
|
||
# Checking if current tag matches the package version | ||
current_tag=$(echo $GITHUB_REF | tr -d 'refs/tags/v') | ||
file_tag=$(grep '^version = ' Cargo.toml | cut -d '=' -f 2 | tr -d '"' | tr -d ' ') | ||
if [ "$current_tag" != "$file_tag" ]; then | ||
echo "Error: the current tag does not match the version in package file(s)." | ||
echo "$current_tag vs $file_tag" | ||
exit 1 | ||
fi | ||
|
||
echo 'OK' | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Publish to crates.io | ||
on: | ||
push: | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
name: Rust project | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: hecrj/setup-rust-action@master | ||
with: | ||
rust-version: stable | ||
- name: Check release validity | ||
run: sh .github/scripts/check-release.sh | ||
- name: Build | ||
run: cargo build --release | ||
- name: Login | ||
run: cargo login ${{ secrets.CRATES_TOKEN }} | ||
- name: Publish to crates.io | ||
run: cargo publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters