Skip to content

Commit cea0779

Browse files
committed
attempt a reusable publish rust job
1 parent f55187f commit cea0779

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

.github/workflows/publish-rust-client.yml

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
name: Publish Rust Client
1+
name: Publish Rust Crate
22

33
on:
44
workflow_dispatch:
55
inputs:
6+
package_path:
7+
description: Path to directory with package to release
8+
required: true
9+
type: string
610
level:
711
description: Level
812
required: true
@@ -34,7 +38,7 @@ on:
3438

3539
jobs:
3640
test_rust:
37-
name: Test Rust client
41+
name: Test Rust Crate
3842
runs-on: ubuntu-latest
3943
steps:
4044
- name: Git Checkout
@@ -43,25 +47,34 @@ jobs:
4347
- name: Setup Environment
4448
uses: ./.github/actions/setup
4549
with:
46-
cargo-cache-key: cargo-rust-client
50+
cargo-cache-key: cargo-rust-${{ github.event.inputs.package_path }}
4751
clippy: true
4852
rustfmt: true
4953
solana: true
54+
55+
- name: Convert package_path to required variables
56+
run: |
57+
PACKAGE_PATH="${{ github.event.inputs.package_path }}"
58+
RECIPE_SUFFIX="${PACKAGE_PATH//\//-}"
59+
TAG_PREFIX="$(basename "$PACKAGE_PATH")"
60+
61+
echo "RECIPE_SUFFIX=$RECIPE_SUFFIX" >> $GITHUB_ENV
62+
echo "TAG_PREFIX=$TAG_PREFIX" >> $GITHUB_ENV
5063
5164
- name: Format
52-
run: make format-clients-rust
65+
run: make format-${{ env.RECIPE_SUFFIX }}
5366

5467
- name: Lint
55-
run: make clippy-clients-rust
68+
run: make clippy-${{ env.RECIPE_SUFFIX }}
5669

57-
- name: Build program
58-
run: make build-program
70+
- name: Build
71+
run: make build-${{ env.RECIPE_SUFFIX }}
5972

6073
- name: Test
61-
run: make test-clients-rust
74+
run: make test-${{ env.RECIPE_SUFFIX }}
6275

6376
publish_rust:
64-
name: Publish Rust Client
77+
name: Publish Rust Crate
6578
runs-on: ubuntu-latest
6679
needs: test_rust
6780
permissions:
@@ -73,8 +86,8 @@ jobs:
7386
- name: Setup Environment
7487
uses: ./.github/actions/setup
7588
with:
76-
cargo-cache-key: cargo-publish-rust-client
77-
cargo-cache-fallback-key: cargo-rust-client
89+
cargo-cache-key: cargo-publish-rust-${{ github.event.inputs.package_path }}
90+
cargo-cache-fallback-key: cargo-rust-${{ github.event.inputs.package_path }}
7891
clippy: true
7992
rustfmt: true
8093

@@ -95,7 +108,7 @@ jobs:
95108
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
96109
git config --global user.name "github-actions[bot]"
97110
98-
- name: Publish Rust Client
111+
- name: Publish Rust Crate
99112
id: publish
100113
env:
101114
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
@@ -112,14 +125,10 @@ jobs:
112125
OPTIONS=""
113126
fi
114127
115-
./scripts/publish-rust.sh clients/rust $LEVEL $OPTIONS
116-
117-
- name: Push Commit and Tag
118-
if: github.event.inputs.dry_run != 'true'
119-
run: git push origin --follow-tags
128+
./scripts/publish-rust.sh ${{ github.event.inputs.package_path }} $LEVEL $OPTIONS
120129
121130
- name: Create GitHub release
122131
if: github.event.inputs.create_release == 'true' && github.event.inputs.dry_run != 'true'
123132
uses: ncipollo/release-action@v1
124133
with:
125-
tag: rust@v${{ steps.publish.outputs.new_version }}
134+
tag: ${{ env.TAG_PREFIX }}@v${{ steps.publish.outputs.new_version }}

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ lint-docs-%:
2323
lint-features-%:
2424
cargo $(nightly) hack check --feature-powerset --all-targets --manifest-path $(subst -,/,$*)/Cargo.toml
2525

26-
test-%:
27-
cargo $(nightly) test --manifest-path $(subst -,/,$*)/Cargo.toml
26+
build-%:
27+
cargo build --manifest-path $(subst -,/,$*)/Cargo.toml
2828

2929
build-program:
3030
cargo build-sbf --manifest-path program/Cargo.toml --features bpf-entrypoint
3131

32+
test-%:
33+
cargo $(nightly) test --manifest-path $(subst -,/,$*)/Cargo.toml
34+
3235
test-program:
3336
cargo test-sbf --manifest-path program/Cargo.toml --features bpf-entrypoint
3437

0 commit comments

Comments
 (0)