diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9bff66..71d793f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,8 @@ name: Cargo Build & Test on: push: + branches: + - main pull_request: workflow_dispatch: @@ -32,8 +34,18 @@ jobs: echo "changed=false" >> $GITHUB_ENV fi + - name: Tag the release + if: github.ref == 'refs/heads/main' && env.changed == 'true' + run: | + version=$(grep '^version\s*=' Cargo.toml | sed -E 's/version[[:space:]]*=[[:space:]]*"(.*)"/\1/') + + echo "Tagging version: $version" + + git tag -a v$version -m "Release v$version" + git push origin v$version + - name: Publish to crates.io - if: env.changed == 'true' + if: github.ref == 'refs/heads/main' && env.changed == 'true' run: cargo publish env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}