Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated publish workflow #10

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 4 additions & 51 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,58 +7,11 @@ jobs:
publish:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup Rust
uses: actions-rs/toolchain@v1
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Get current version
id: cv
run: |
curr_vers=$(cargo pkgid | awk -F'#' '{ print $2 }')
echo "Curr_Vers=${curr_vers}"
echo ::set-output name=curr_version::${curr_vers}

- name: Get current tag
id: git
run: |
if git rev-parse --verify --quiet refs/tags/HEAD > /dev/null
then
curr_tag=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "Curr_Tag=${curr_tag}"
echo ::set-output name=curr_tag::${curr_tag}
else
echo "No git tags found. Please create a git tag."
exit 1
fi

- name: Get last tag
id: gitlast
run: |
last_tag=$(git describe --tags $(git rev-list --tags --max-count=2 | tail -1))
echo "Last_Tag=${last_tag}"
echo ::set-output name=last_tag::${last_tag}

- name: Check version and tag
run: |
curr_tag="${{ steps.git.outputs.curr_tag }}"
curr_ver="${{ steps.cv.outputs.curr_version }}"
last_tag="${{ steps.gitlast.outputs.last_tag }}"
if [ $curr_tag != $curr_ver ]
then
echo "Current version and tag do not match!"
exit 1
fi
if [[ $(printf '%s\n' "$last_tag" "$curr_tag" | sort -V | tail -n 1) != $curr_tag ]]
then
echo "Current tag is not newer than the last tag!"
exit 1
fi

- name: Publish to crates.io
uses: actions-rs/cargo@v1
- uses: katyo/publish-crates@v2
with:
command: publish
args: --token ${{ secrets.CRATES_TOKEN }}
registry-token: ${{ secrets.CRATES_TOKEN }}
Loading