diff --git a/.github/workflows/cargo-release.yml b/.github/workflows/cargo-release.yml new file mode 100644 index 0000000..4f6ebc3 --- /dev/null +++ b/.github/workflows/cargo-release.yml @@ -0,0 +1,42 @@ +name: Upload to Cargo + +on: + release: + types: [published] + +jobs: + publish: + name: Publish to Crates.io + + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + ref: 'main' + + - name: Download Rust Tools + uses: ./.github/actions/install-rust-tools + + - name: Extract tag version + run: | + TAG=${GITHUB_REF##*/} + VERSION=${TAG#v} + echo "Version: $VERSION" + echo "version=$VERSION" >> $GITHUB_ENV + + - name: Update version in Cargo.toml + run: | + sed -i -E "s/^version = \".*\"/version = \"${{ env.version }}\"/" Cargo.toml + + - name: Commit version update + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git add Cargo.toml + git commit -m "Update version to ${{ env.version }}" + git push origin main