fix: install protoc with github action #59
Workflow file for this run
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
name: Upload Rust Package | |
on: push | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v2 | |
with: | |
version: "24.x" | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Build | |
run: cargo build --verbose | |
deploy: | |
needs: build | |
# commit contains a tag => deploy | |
if: startsWith( github.ref, 'refs/tags/v' ) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v2 | |
with: | |
version: "24.x" | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Install cargo-edit | |
run: cargo install cargo-edit | |
- name: Set VERSION environment variable | |
run: | | |
echo GitHub_ref: $GITHUB_REF | |
arrTag=(${GITHUB_REF//\// }) | |
VERSION="${arrTag[2]}" | |
echo Version: $VERSION | |
VERSION="${VERSION//v}" | |
echo Clean Version: $VERSION | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
- name: Set version in Cargo.toml | |
run: cargo set-version ${{ env.VERSION }} | |
- name: Cargo Login | |
run: cargo login ${{ secrets.CRATES_IO_API_KEY }} | |
- name: Create Crates.io package | |
# add --allow-dirty because Cargo.toml was just modified to set tag version | |
# add --no-verify because build.rs recomputes protos | |
run: cargo publish --allow-dirty --no-verify |