Skip to content

Commit

Permalink
ci(repo): Fix publish crate action
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Jan 24, 2025
1 parent 825fd5a commit 83c5bd0
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/actions/setup-rust/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ runs:
tool: [email protected]

- uses: Swatinem/rust-cache@v2
if: inputs.cache == 'true'
if: inputs.cache == 'true' || github.event_name != 'release' || github.event_name != 'workflow_dispatch'
with:
cache-on-failure: true
shared-key: "workspace-${{ inputs.target }}"
Expand All @@ -67,12 +67,12 @@ runs:
. -> target
- name: Run sccache-cache only on non-release runs
if: inputs.cache == 'true' && github.event_name != 'release' && github.event_name != 'workflow_dispatch'
if: inputs.cache == 'true' || github.event_name != 'release' || github.event_name != 'workflow_dispatch'
uses: mozilla-actions/[email protected]

- name: Set Rust caching env vars only on non-release runs
shell: sh
if: inputs.cache == 'true' && github.event_name != 'release' && github.event_name != 'workflow_dispatch'
if: inputs.cache == 'true' || github.event_name != 'release' || github.event_name != 'workflow_dispatch'
run: |-
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
49 changes: 43 additions & 6 deletions .github/workflows/publish_release.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
name: Publish on Crates.io

on:
release:
types:
- published
workflow_dispatch:
inputs:
version:
description: "Version to release"
required: true
type: string

env:
CI: true
RUST_VERSION: 1.81.0
RUST_NIGHTLY_VERSION: nightly-2024-11-06

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand All @@ -22,13 +26,46 @@ jobs:
name: Publish on Crates.io
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Check Cargo.toml version
id: check-version
run: |
CURRENT_VERSION=$(grep -m1 '^version =' Cargo.toml | cut -d '"' -f2)
if [ "$CURRENT_VERSION" == "${{ inputs.version }}" ]; then
echo "skip_steps=true" >> $GITHUB_OUTPUT
else
echo "skip_steps=false" >> $GITHUB_OUTPUT
fi
- name: Configure Git
if: ${{ inputs.version != '' && steps.check-version.outputs.skip_steps == 'false' }}
run: |
git config --global user.name GitHub Actions
git config user.email [email protected]
- name: Install Rust
uses: ./.github/actions/setup-rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
toolchain: ${{ steps.check-version.outputs.skip_steps == 'false' && env.RUST_NIGHTLY_VERSION || env.RUST_VERSION }}
target: x86_64-unknown-linux-gnu,wasm32-unknown-unknown
components: clippy, rustfmt

- name: Setup Node && PNPM
if: ${{ inputs.version != '' && steps.check-version.outputs.skip_steps == 'false' }}
uses: ./.github/actions/setup-node

- name: Bump Version
if: ${{ inputs.version != '' && steps.check-version.outputs.skip_steps == 'false' }}
run: |
make bump-version VERSION=${{ inputs.version }}
git add .
git commit -m "Bump version to v${{ inputs.version }}"
git push
- name: Publish Crate
uses: katyo/publish-crates@v2
Expand Down
5 changes: 4 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ sv-webserver = { version = "0.0.18", path = "crates/sv-webserver" }
[workspace.metadata.cargo-machete]
ignored = ["fuel-core", "tokio", "anyhow"]

[workspace.metadata.workspaces]
netlink-proto = { version = "=0.11.3" }

[profile.release]
opt-level = 3
lto = "thin"
Expand Down
3 changes: 3 additions & 0 deletions crates/fuel-streams-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ test-helpers = [
"fuel-streams-store/test-helpers",
"fuel-streams-types/test-helpers",
]

[target.'cfg(target_os = "linux")'.dependencies]
netlink-proto = { version = "=0.11.3", optional = true }
3 changes: 3 additions & 0 deletions crates/fuel-streams-domains/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ test-helpers = [
"fuel-streams-store/test-helpers",
"fuel-streams-types/test-helpers",
]

[target.'cfg(target_os = "linux")'.dependencies]
netlink-proto = { version = "=0.11.3", optional = true }
3 changes: 3 additions & 0 deletions crates/fuel-streams-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ tracing = { workspace = true }
[features]
default = []
test-helpers = []

[target.'cfg(target_os = "linux")'.dependencies]
netlink-proto = { version = "=0.11.3", optional = true }

0 comments on commit 83c5bd0

Please sign in to comment.