-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor/crates publish pipeline #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f6d1ba4
feat: restructure publish workflow to use matrix strategy for crate p…
marcjazz 5f558c4
refactor: simplify publish workflow by consolidating jobs and improvi…
marcjazz d970d78
refactor: enhance CI workflows by adding path filters for push and pu…
marcjazz 92a5d54
refactor: remove path filters from CI and deploy workflows for cleane…
marcjazz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,169 +1,88 @@ | ||
| name: Publish Rust Crates to crates.io | ||
| name: Publish Rust Crates | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| deploy_environment: | ||
| description: "Deployment Environment" | ||
| required: true | ||
| description: Deployment environment | ||
| required: false | ||
| default: pre-prod | ||
| type: string | ||
|
|
||
| release: | ||
| types: [created] | ||
|
|
||
| jobs: | ||
| publish_crates: | ||
| publish: | ||
| name: Publish / ${{ matrix.crate }} | ||
| runs-on: ubuntu-latest | ||
| environment: ${{ inputs.deploy_environment || 'pre-prod' }} | ||
| environment: ${{ github.event.inputs.deploy_environment || 'pre-prod' }} | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| max-parallel: 4 | ||
| matrix: | ||
| phase: [foundation, core, frameworks, root] | ||
| include: | ||
| # foundation layer | ||
| - phase: foundation | ||
| crate: authkestra-core | ||
| - phase: foundation | ||
| crate: authkestra-macros | ||
|
marcjazz marked this conversation as resolved.
|
||
|
|
||
| # core dependents | ||
| - phase: core | ||
| crate: authkestra-token | ||
| - phase: core | ||
| crate: authkestra-session | ||
| - phase: core | ||
| crate: authkestra-guard | ||
| - phase: core | ||
| crate: authkestra-flow | ||
| - phase: core | ||
| crate: authkestra-providers-github | ||
| - phase: core | ||
| crate: authkestra-providers-google | ||
| - phase: core | ||
| crate: authkestra-providers-discord | ||
| - phase: core | ||
| crate: authkestra-oidc | ||
|
|
||
| # framework adapters | ||
| - phase: frameworks | ||
| crate: authkestra-axum | ||
| - phase: frameworks | ||
| crate: authkestra-actix | ||
|
|
||
| # final crate | ||
| - phase: root | ||
| crate: authkestra | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Rust toolchain | ||
| - name: Install Rust | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| toolchain: stable | ||
|
|
||
| - name: Configure cargo credentials | ||
| - name: Publish crate | ||
| run: | | ||
| mkdir -p $HOME/.cargo | ||
| cat > $HOME/.cargo/config.toml <<EOF | ||
| [registry] | ||
| token = "${{ secrets.CARGO_REGISTRY_TOKEN }}" | ||
| EOF | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
| CRATE="${{ matrix.crate }}" | ||
| echo "Publishing $CRATE..." | ||
|
|
||
| - name: Publish authkestra-core | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
| run: | | ||
| echo "Publishing authkestra-core..." | ||
| if cargo publish --package "authkestra-core" --dry-run 2>&1 | grep -q "already exists"; then | ||
| echo "::warning::Version for authkestra-core already exists on crates.io, skipping." | ||
| else | ||
| cargo publish --package "authkestra-core" | ||
| sleep 10 | ||
| fi | ||
| - name: Publish authkestra-token | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
| run: | | ||
| echo "Publishing authkestra-token..." | ||
| if cargo publish --package "authkestra-token" --dry-run 2>&1 | grep -q "already exists"; then | ||
| echo "::warning::Version for authkestra-token already exists on crates.io, skipping." | ||
| else | ||
| cargo publish --package "authkestra-token" | ||
| sleep 10 | ||
| fi | ||
| - name: Publish authkestra-session | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
| run: | | ||
| echo "Publishing authkestra-session..." | ||
| if cargo publish --package "authkestra-session" --dry-run 2>&1 | grep -q "already exists"; then | ||
| echo "::warning::Version for authkestra-session already exists on crates.io, skipping." | ||
| else | ||
| cargo publish --package "authkestra-session" | ||
| sleep 10 | ||
| fi | ||
| - name: Publish authkestra-guard | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
| run: | | ||
| echo "Publishing authkestra-guard..." | ||
| if cargo publish --package "authkestra-guard" --dry-run 2>&1 | grep -q "already exists"; then | ||
| echo "::warning::Version for authkestra-guard already exists on crates.io, skipping." | ||
| else | ||
| cargo publish --package "authkestra-guard" | ||
| sleep 10 | ||
| fi | ||
| - name: Publish authkestra-oidc | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
| run: | | ||
| echo "Publishing authkestra-oidc..." | ||
| if cargo publish --package "authkestra-oidc" --dry-run 2>&1 | grep -q "already exists"; then | ||
| echo "::warning::Version for authkestra-oidc already exists on crates.io, skipping." | ||
| else | ||
| cargo publish --package "authkestra-oidc" | ||
| sleep 10 | ||
| fi | ||
| - name: Publish authkestra-providers-github | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
| run: | | ||
| echo "Publishing authkestra-providers-github..." | ||
| if cargo publish --package "authkestra-providers-github" --dry-run 2>&1 | grep -q "already exists"; then | ||
| echo "::warning::Version for authkestra-providers-github already exists on crates.io, skipping." | ||
| else | ||
| cargo publish --package "authkestra-providers-github" | ||
| sleep 10 | ||
| fi | ||
| - name: Publish authkestra-providers-google | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
| run: | | ||
| echo "Publishing authkestra-providers-google..." | ||
| if cargo publish --package "authkestra-providers-google" --dry-run 2>&1 | grep -q "already exists"; then | ||
| echo "::warning::Version for authkestra-providers-google already exists on crates.io, skipping." | ||
| else | ||
| cargo publish --package "authkestra-providers-google" | ||
| sleep 10 | ||
| fi | ||
| - name: Publish authkestra-providers-discord | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
| run: | | ||
| echo "Publishing authkestra-providers-discord..." | ||
| if cargo publish --package "authkestra-providers-discord" --dry-run 2>&1 | grep -q "already exists"; then | ||
| echo "::warning::Version for authkestra-providers-discord already exists on crates.io, skipping." | ||
| else | ||
| cargo publish --package "authkestra-providers-discord" | ||
| sleep 10 | ||
| fi | ||
| - name: Publish authkestra-flow | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
| run: | | ||
| echo "Publishing authkestra-flow..." | ||
| if cargo publish --package "authkestra-flow" --dry-run 2>&1 | grep -q "already exists"; then | ||
| echo "::warning::Version for authkestra-flow already exists on crates.io, skipping." | ||
| else | ||
| cargo publish --package "authkestra-flow" | ||
| sleep 10 | ||
| fi | ||
| - name: Publish authkestra-axum | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
| run: | | ||
| echo "Publishing authkestra-axum..." | ||
| if cargo publish --package "authkestra-axum" --dry-run 2>&1 | grep -q "already exists"; then | ||
| echo "::warning::Version for authkestra-axum already exists on crates.io, skipping." | ||
| else | ||
| cargo publish --package "authkestra-axum" | ||
| sleep 10 | ||
| fi | ||
| - name: Publish authkestra-actix | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
| run: | | ||
| echo "Publishing authkestra-actix..." | ||
| if cargo publish --package "authkestra-actix" --dry-run 2>&1 | grep -q "already exists"; then | ||
| echo "::warning::Version for authkestra-actix already exists on crates.io, skipping." | ||
| else | ||
| cargo publish --package "authkestra-actix" | ||
| sleep 10 | ||
| fi | ||
| - name: Publish authkestra | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
| run: | | ||
| echo "Publishing authkestra..." | ||
| if cargo publish --package "authkestra" --dry-run 2>&1 | grep -q "already exists"; then | ||
| echo "::warning::Version for authkestra already exists on crates.io, skipping." | ||
| else | ||
| cargo publish --package "authkestra" | ||
| sleep 10 | ||
| VERSION=$(cargo metadata --no-deps --format-version=1 \ | ||
| | jq -r ".packages[] | select(.name==\"$CRATE\") | .version") | ||
|
|
||
| RESPONSE=$(curl -s https://crates.io/api/v1/crates/$CRATE) | ||
|
|
||
| if echo "$RESPONSE" | jq -e '.versions' >/dev/null 2>&1; then | ||
| if echo "$RESPONSE" | jq -r '.versions[].num' | grep -q "$VERSION"; then | ||
|
marcjazz marked this conversation as resolved.
Outdated
|
||
| echo "::warning::$CRATE $VERSION already exists. Skipping." | ||
| exit 0 | ||
| fi | ||
|
marcjazz marked this conversation as resolved.
|
||
| fi | ||
|
marcjazz marked this conversation as resolved.
Outdated
|
||
|
|
||
| cargo publish -p ${{ matrix.crate }} | ||
| sleep 20 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.