Skip to content

Commit

Permalink
ci(repo): Fix publish crates action
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Jan 24, 2025
1 parent 825fd5a commit 75f770c
Show file tree
Hide file tree
Showing 4 changed files with 49 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
47 changes: 42 additions & 5 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,14 +26,47 @@ 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
with:
toolchain: ${{ env.RUST_VERSION }}
cache: "false"
toolchain: ${{ env.RUST_NIGHTLY_VERSION }}
target: x86_64-unknown-linux-gnu,wasm32-unknown-unknown

- 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
id: publish-crates
Expand Down
5 changes: 2 additions & 3 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ 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" }
[patch.crates-io]
netlink-proto = { git = "https://github.com/pedronauck/netlink-proto", branch = "main" }

[profile.release]
opt-level = 3
Expand Down

0 comments on commit 75f770c

Please sign in to comment.