Skip to content

Commit

Permalink
Merge pull request #27 from lexara-prime-ai/dev
Browse files Browse the repository at this point in the history
Updated workflows
  • Loading branch information
irfanghat authored Jun 1, 2024
2 parents 0c574a0 + 658ebec commit 6276dfd
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions .github/workflows/cargo-publish.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,50 @@
name: Publish to crates.io

'on':
push:
branches: [ "master" ]
tags: '*'

jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Chekout sources
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: 'cargo publish --token ${CRATES_IO_TOKEN}'

- name: Extract current version
id: extract_version
run: |
current_version=$(grep '^version' Cargo.toml | sed -E 's/version = "(.*)"/\1/')
echo "current_version=${current_version}" >> $GITHUB_ENV
- name: Get latest published version
id: get_latest_version
run: |
crate_name=$(grep '^name' Cargo.toml | sed -E 's/name = "(.*)"/\1/')
latest_version=$(curl -s https://crates.io/api/v1/crates/${crate_name} | jq -r .crate.max_version)
echo "latest_version=${latest_version}" >> $GITHUB_ENV
- name: Compare versions
id: compare_versions
run: |
if [ "${{ env.current_version }}" == "${{ env.latest_version }}" ]; then
echo "Version is already published."
exit 1
else
echo "New version detected."
fi
- name: Publish to crates.io
if: steps.compare_versions.outcome == 'success'
run: 'cargo publish --token ${CRATES_IO_TOKEN}'
env:
CRATES_IO_TOKEN: '${{secrets.CRATES_IO_TOKEN}}'
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}

0 comments on commit 6276dfd

Please sign in to comment.