Skip to content

forc-node v0.71.3

forc-node v0.71.3 #94

Workflow file for this run

name: CI
on:
push:
branches:
- master
pull_request:
release:
types: [published]
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
REGISTRY: ghcr.io
RUST_VERSION: 1.93.0
jobs:
cancel-previous-runs:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
get-fuel-core-version:
runs-on: ubuntu-latest
outputs:
fuel_core_version: ${{ steps.get-version.outputs.fuel_core_version }}
steps:
- uses: actions/checkout@v6
- name: Get fuel-core version
id: get-version
run: |
version=$(grep 'fuel-core-client' Cargo.toml | head -1 | sed -E 's/.*version = "([0-9]+\.[0-9]+)".*/\1/')
# Append .0 to get the patch version (e.g., 0.48 -> 0.48.0)
version="${version}.0"
echo "fuel_core_version=$version" >> $GITHUB_OUTPUT
echo "Detected fuel-core version: $version"
lint-toml-files:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install Cargo.toml linter
uses: baptiste0928/cargo-install@v1
with:
crate: cargo-toml-lint
version: "0.1"
- name: Run Cargo.toml linter
run: git ls-files | grep Cargo.toml$ | xargs --verbose -n 1 cargo-toml-lint
- name: Notify if Job Fails
uses: ravsamhq/notify-slack-action@v1
if: always() && github.ref == 'refs/heads/master'
with:
status: ${{ job.status }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: "{workflow} has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>"
footer: ""
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }}
cargo-verifications:
needs: [cancel-previous-runs]
runs-on: ubuntu-latest
strategy:
matrix:
include:
- command: fmt
args: --all --verbose -- --check
- command: clippy
args: --all-targets --all-features
- command: check
args: --locked --all-targets --all-features
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "github"
key: "${{ matrix.command }}${{ matrix.args }}"
- name: ${{ matrix.command }} ${{ matrix.args }}
run: cargo ${{ matrix.command }} ${{ matrix.args }}
env:
RUSTFLAGS: "-D warnings"
cargo-test:
name: cargo test
needs: [cancel-previous-runs, get-fuel-core-version]
runs-on: warp-ubuntu-latest-x64-4x
strategy:
matrix:
include:
- args: --all-features -- --test-threads 1
- args: --no-default-features -- --test-threads 1
steps:
- uses: actions/checkout@v6
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "warpbuild"
key: "test${{ matrix.args }}"
- name: Install fuel-core for tests
run: |
curl -sSLf https://github.com/FuelLabs/fuel-core/releases/download/v${{ needs.get-fuel-core-version.outputs.fuel_core_version }}/fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu.tar.gz -L -o fuel-core.tar.gz
tar -xvf fuel-core.tar.gz
chmod +x fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu/fuel-core
mv fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu/fuel-core /usr/local/bin/fuel-core
- name: cargo test ${{ matrix.args }}
run: cargo test --locked --release ${{ matrix.args }}
env:
RUSTFLAGS: "-D warnings"
- name: Notify if Job Fails
uses: ravsamhq/notify-slack-action@v1
if: always() && github.ref == 'refs/heads/master'
with:
status: ${{ job.status }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: "{workflow} has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>"
footer: ""
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_NOTIFY_BUILD }}
RUSTFLAGS: -D warnings
publish-crates:
# Only do this job if publishing a release
needs:
- lint-toml-files
- cargo-verifications
- cargo-test
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Extract crate name from tag
id: extract_crate
run: |
TAG="${GITHUB_REF#refs/tags/}"
CRATE_NAME=$(echo "$TAG" | sed -E 's/-[0-9]+\.[0-9]+\.[0-9]+.*//')
echo "crate_name=$CRATE_NAME" >> $GITHUB_OUTPUT
- name: Verify tag version
run: |
curl -sSLf "https://github.com/TomWright/dasel/releases/download/v1.24.3/dasel_linux_amd64" -L -o dasel && chmod +x dasel
mv ./dasel /usr/local/bin/dasel
./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }}
- name: Publish crate
run: cargo publish -p ${{ steps.extract_crate.outputs.crate_name }} --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Notify if Job Fails
uses: ravsamhq/notify-slack-action@v1
if: always()
with:
status: ${{ job.status }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: "{workflow} has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>"
footer: ""
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TOOLING }}
build-release:
name: build release binaries
runs-on: ${{ matrix.job.os }}
if: github.event_name == 'release' && github.event.action == 'published'
needs: cancel-previous-runs
permissions:
contents: write
strategy:
matrix:
job:
- os: ubuntu-latest
platform: linux
target: x86_64-unknown-linux-gnu
target_suffix: linux_amd64
cross_image: x86_64-linux-gnu
- os: ubuntu-latest
platform: linux
target: aarch64-unknown-linux-gnu
target_suffix: linux_arm64
cross_image: aarch64-linux-gnu
- os: macos-latest
platform: darwin
target: x86_64-apple-darwin
target_suffix: darwin_amd64
- os: macos-latest
platform: darwin
target: aarch64-apple-darwin
target_suffix: darwin_arm64
steps:
- name: Checkout sources
uses: actions/checkout@v6
- name: Extract crate name from tag
id: extract_crate
run: |
TAG="${GITHUB_REF#refs/tags/}"
# Extract crate name (everything before the last version number)
CRATE_NAME=$(echo "$TAG" | sed -E 's/-[0-9]+\.[0-9]+\.[0-9]+.*//')
echo "crate_name=$CRATE_NAME" >> $GITHUB_OUTPUT
echo "Building crate: $CRATE_NAME"
- name: Check if crate has binary target
id: check_binary
run: |
CRATE_NAME="${{ steps.extract_crate.outputs.crate_name }}"
# Check if the crate's Cargo.toml has a [[bin]] section or src/main.rs
if [ -f "${CRATE_NAME}/src/main.rs" ] || grep -q '^\[\[bin\]\]' "${CRATE_NAME}/Cargo.toml" 2>/dev/null; then
echo "has_binary=true" >> $GITHUB_OUTPUT
echo "Crate $CRATE_NAME has binary target"
# Extract binary names from Cargo.toml
if grep -q '^\[\[bin\]\]' "${CRATE_NAME}/Cargo.toml" 2>/dev/null; then
# Extract all binary names from [[bin]] sections
BINARIES=$(grep -A3 '^\[\[bin\]\]' "${CRATE_NAME}/Cargo.toml" | grep '^name' | sed 's/name = "\([^"]*\)"/\1/' | tr '\n' ' ')
else
# Default to crate name if using src/main.rs
BINARIES="$CRATE_NAME"
fi
echo "binaries=$BINARIES" >> $GITHUB_OUTPUT
echo "Binary targets: $BINARIES"
else
echo "has_binary=false" >> $GITHUB_OUTPUT
echo "Crate $CRATE_NAME is library-only, skipping binary build"
fi
- name: Setup cross build environment
if: steps.check_binary.outputs.has_binary == 'true'
uses: FuelLabs/sway-nightly-binaries/.github/actions/setup-cross-build@0f842ee1f5c50f9260f0e6d09367b415dc572af8
with:
target: ${{ matrix.job.target }}
cross_image: ${{ matrix.job.cross_image }}
os: ${{ matrix.job.os }}
rust_version: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
if: steps.check_binary.outputs.has_binary == 'true'
with:
cache-on-failure: true
key: "${{ matrix.job.target }}"
- name: Prepare RocksDB build env
if: steps.check_binary.outputs.has_binary == 'true' && runner.os == 'Linux'
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update
sudo apt-get install -y build-essential clang llvm-dev libclang-dev pkg-config
echo "LIBCLANG_PATH=$(llvm-config --libdir)" >> "$GITHUB_ENV"
echo "BINDGEN_EXTRA_CLANG_ARGS=--sysroot=/usr" >> "$GITHUB_ENV"
- name: Use Cross
if: steps.check_binary.outputs.has_binary == 'true'
uses: baptiste0928/cargo-install@v1
with:
crate: cross
cache-key: "${{ matrix.job.target }}"
- name: Build ${{ steps.extract_crate.outputs.crate_name }}
if: steps.check_binary.outputs.has_binary == 'true'
run: |
cross build --profile=release --target ${{ matrix.job.target }} -p ${{ steps.extract_crate.outputs.crate_name }}
- name: Strip release binary x86_64-linux-gnu
if: steps.check_binary.outputs.has_binary == 'true' && matrix.job.target == 'x86_64-unknown-linux-gnu'
run: |
for bin in ${{ steps.check_binary.outputs.binaries }}; do
strip "target/${{ matrix.job.target }}/release/$bin"
done
- name: Strip release binary aarch64-linux-gnu
if: steps.check_binary.outputs.has_binary == 'true' && matrix.job.target == 'aarch64-unknown-linux-gnu'
run: |
for bin in ${{ steps.check_binary.outputs.binaries }}; do
docker run --rm -v \
"$PWD/target:/target:Z" \
ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main \
aarch64-linux-gnu-strip \
/target/aarch64-unknown-linux-gnu/release/$bin
done
- name: Strip release binary mac
if: steps.check_binary.outputs.has_binary == 'true' && matrix.job.os == 'macos-latest'
run: |
for bin in ${{ steps.check_binary.outputs.binaries }}; do
strip -x "target/${{ matrix.job.target }}/release/$bin"
done
- name: Prep assets
if: steps.check_binary.outputs.has_binary == 'true'
id: prep_assets
env:
PLATFORM_NAME: ${{ matrix.job.platform }}
TARGET: ${{ matrix.job.target }}
TARGET_SUFFIX: ${{ matrix.job.target_suffix }}
CRATE_NAME: ${{ steps.extract_crate.outputs.crate_name }}
BINARIES: ${{ steps.check_binary.outputs.binaries }}
run: |
# Get tag name
# See: https://github.qkg1.topmunity/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
TAG="${GITHUB_REF#refs/tags/}"
echo "version is: $TAG"
# setup artifact filename using simplified target names (e.g., linux_amd64, darwin_arm64)
ARTIFACT="${TAG}-${{ env.TARGET_SUFFIX }}"
ZIP_FILE_NAME="$ARTIFACT.tar.gz"
echo "ZIP_FILE_NAME=$ZIP_FILE_NAME" >> $GITHUB_ENV
# create zip file
mkdir -pv "$ARTIFACT"
for bin in $BINARIES; do
cp "target/${{ matrix.job.target }}/release/$bin" "$ARTIFACT"
done
tar -czvf $ZIP_FILE_NAME "$ARTIFACT"
- name: Upload release archive
uses: softprops/action-gh-release@v2
if: steps.check_binary.outputs.has_binary == 'true' && github.ref_type == 'tag'
with:
files: ${{ env.ZIP_FILE_NAME }}
update-releases:
name: Update releases.toml
needs: publish-crates
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout release tag
uses: actions/checkout@v6
with:
ref: ${{ github.ref }}
persist-credentials: false
- name: Extract crate info from tag
id: extract
run: |
TAG="${{ github.ref_name }}"
CRATE_NAME=$(echo "$TAG" | sed -E 's/-[0-9]+\.[0-9]+\.[0-9]+.*//')
VERSION=$(echo "$TAG" | sed -E 's/^.*-([0-9]+\.[0-9]+\.[0-9]+.*)/\1/')
echo "crate_name=$CRATE_NAME" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Fetch latest releases.toml from main
run: |
git fetch origin main
git checkout origin/main -- releases.toml 2>/dev/null || true
- name: Update releases.toml
run: ./.github/workflows/scripts/update_releases.sh ${{ steps.extract.outputs.crate_name }} ${{ steps.extract.outputs.version }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.GITHUB_TOKEN }}
base: main
branch: chore/releases-${{ github.ref_name }}
commit-message: "chore: update releases.toml for ${{ github.ref_name }}"
title: "chore: update releases.toml for ${{ github.ref_name }}"
body: |
Auto-generated PR to update `releases.toml` after publishing `${{ github.ref_name }}`.
This tracks the dependency versions used in this release for compatibility reference.
labels: automated,releases