Skip to content

Commit

Permalink
Fix workflow (#37)
Browse files Browse the repository at this point in the history
* Use upload-artifact@v3 and download-artifact@v3

* Use checkout@v4

* Don't use cargo@v1

* Don't use set-output
  • Loading branch information
OlivierHecart authored Dec 19, 2023
1 parent b3c0256 commit adc779b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 58 deletions.
22 changes: 5 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
os: [ubuntu-latest, macOS-latest, windows-latest]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# For Windows, install llvm and use a workaround to resolve link error with C:\msys64\mingw64\bin\libclang.dll
# Credits: https://github.com/rust-rocksdb/rust-rocksdb/pull/484
Expand All @@ -50,25 +50,13 @@ jobs:
rustup component add rustfmt clippy
- name: Code format check
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
run: cargo fmt --check

- name: Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all --examples -- -D warnings
run: cargo clippy --all --examples -- -D warnings

- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --verbose --all-targets
run: cargo build --verbose --all-targets

- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --verbose
run: cargo test --verbose
96 changes: 55 additions & 41 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,15 @@ jobs:
name: Code checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install Rust toolchain
run: |
rustup show
rustup component add rustfmt clippy
- name: Code format check
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
run: cargo fmt --check
- name: Clippy check
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets -- -D warnings
run: cargo clippy --all-targets -- -D warnings
- name: Environment setup
id: env
shell: bash
Expand All @@ -56,26 +50,26 @@ jobs:
echo "GITHUB_SHA=${GITHUB_SHA:0:8}"
GIT_BRANCH=`[[ $GITHUB_REF =~ ^refs/heads/.* ]] && echo ${GITHUB_REF/refs\/heads\//} || true`
echo "GIT_BRANCH=${GIT_BRANCH}"
echo ::set-output name=GIT_BRANCH::"${GIT_BRANCH}"
echo "GIT_BRANCH=${GIT_BRANCH}" >> $GITHUB_OUTPUT
GIT_TAG=`[[ $GITHUB_REF =~ ^refs/tags/.* ]] && echo ${GITHUB_REF/refs\/tags\//} || true`
echo "GIT_TAG=${GIT_TAG}"
echo ::set-output name=GIT_TAG::"${GIT_TAG}"
echo "GIT_TAG=${GIT_TAG}" >> $GITHUB_OUTPUT
ZENOH_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)
echo "ZENOH_VERSION=${ZENOH_VERSION}"
echo ::set-output name=ZENOH_VERSION::"${ZENOH_VERSION}"
echo "ZENOH_VERSION=${ZENOH_VERSION}" >> $GITHUB_OUTPUT
if [ -n "${GIT_TAG}" ]; then
IS_RELEASE="true"
echo "IS_RELEASE=${IS_RELEASE}"
echo ::set-output name=IS_RELEASE::"${IS_RELEASE}"
echo "IS_RELEASE=${IS_RELEASE}" >> $GITHUB_OUTPUT
PKG_VERSION=${ZENOH_VERSION}
elif [ -n "${GIT_BRANCH}" ]; then
PKG_VERSION=${GIT_BRANCH}-${GITHUB_SHA:0:8}
else
PKG_VERSION=${ZENOH_VERSION}-${GITHUB_SHA:0:8}
fi
echo "PKG_VERSION=${PKG_VERSION}"
echo ::set-output name=PKG_VERSION::"${PKG_VERSION}"
echo "PKG_VERSION=${PKG_VERSION}" >> $GITHUB_OUTPUT
outputs:
GIT_BRANCH: ${{ steps.env.outputs.GIT_BRANCH }}
GIT_TAG: ${{ steps.env.outputs.GIT_TAG }}
Expand All @@ -91,44 +85,69 @@ jobs:
fail-fast: false
matrix:
job:
- { target: x86_64-unknown-linux-gnu, arch: amd64, os: ubuntu-20.04 }
- {
target: x86_64-unknown-linux-gnu,
arch: amd64,
os: ubuntu-20.04,
build-cmd: "cargo",
}
- {
target: x86_64-unknown-linux-musl,
arch: amd64,
os: ubuntu-20.04,
use-cross: true,
build-cmd: "cross",
}
- {
target: arm-unknown-linux-gnueabi,
arch: armel,
os: ubuntu-20.04,
use-cross: true,
build-cmd: "cross",
}
- {
target: arm-unknown-linux-gnueabihf,
arch: armhf,
os: ubuntu-20.04,
use-cross: true,
build-cmd: "cross",
}
- {
target: armv7-unknown-linux-gnueabihf,
arch: armhf,
os: ubuntu-20.04,
use-cross: true,
build-cmd: "cross",
}
- {
target: aarch64-unknown-linux-gnu,
arch: arm64,
os: ubuntu-20.04,
use-cross: true,
build-cmd: "cross",
}
- {
target: x86_64-apple-darwin,
arch: darwin,
os: macos-latest,
build-cmd: "cargo",
}
- {
target: aarch64-apple-darwin,
arch: darwin,
os: macos-latest,
build-cmd: "cargo",
}
- {
target: x86_64-pc-windows-msvc,
arch: win64,
os: windows-2019,
build-cmd: "cargo",
}
- {
target: x86_64-pc-windows-gnu,
arch: win64,
os: windows-2019,
build-cmd: "cargo",
}
- { target: x86_64-apple-darwin, arch: darwin, os: macos-latest }
- { target: aarch64-apple-darwin, arch: darwin, os: macos-latest }
- { target: x86_64-pc-windows-msvc, arch: win64, os: windows-2019 }
- { target: x86_64-pc-windows-gnu, arch: win64, os: windows-2019 }
steps:
- name: Checkout source code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 500 # NOTE: get long history for git-version crate to correctly compute a version
- name: Fetch Git tags # NOTE: workaround for https://github.com/actions/checkout/issues/290
Expand Down Expand Up @@ -156,6 +175,8 @@ jobs:
;;
esac
cargo install cross --git https://github.com/cross-rs/cross
- name: Windows > Install LLVM and Clang # required for bindgen to work, see https://github.com/rust-lang/rust-bindgen/issues/1797
uses: KyleMayes/install-llvm-action@v1
if: matrix.job.os == 'windows-2019'
Expand All @@ -172,18 +193,11 @@ jobs:
rustup target add ${{ matrix.job.target }}
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.job.use-cross }}
command: build
args: --release --target=${{ matrix.job.target }}
run: ${{ matrix.job.build-cmd }} build --release --target=${{ matrix.job.target }}

- name: Debian package
if: contains(matrix.job.target, '-linux-gnu')
uses: actions-rs/cargo@v1
with:
command: deb
args: --no-build --target=${{ matrix.job.target }}
run: cargo deb --no-build --target=${{ matrix.job.target }}

- name: Packaging
id: package
Expand All @@ -199,35 +213,35 @@ jobs:
echo "Packaging ${MAIN_PKG_NAME}:"
zip ${MAIN_PKG_NAME} *.so
cd -
echo ::set-output name=MAIN_PKG_NAME::"${MAIN_PKG_NAME}"
echo "MAIN_PKG_NAME=${MAIN_PKG_NAME}" >> $GITHUB_OUTPUT
# check if debian packages has been created and packages them in a single tgz
if [[ -d target/${TARGET}/debian ]]; then
cd target/${TARGET}/debian
echo "Packaging ${DEBS_PKG_NAME}:"
zip ${DEBS_PKG_NAME} *.deb
cd -
echo ::set-output name=DEBS_PKG_NAME::"${DEBS_PKG_NAME}"
echo "DEBS_PKG_NAME=${DEBS_PKG_NAME}" >> $GITHUB_OUTPUT
fi
;;
*apple*)
cd "target/${TARGET}/release/"
echo "Packaging ${MAIN_PKG_NAME}:"
zip ${MAIN_PKG_NAME} *.dylib
cd -
echo ::set-output name=MAIN_PKG_NAME::"${MAIN_PKG_NAME}"
echo "MAIN_PKG_NAME=${MAIN_PKG_NAME}" >> $GITHUB_OUTPUT
;;
*windows*)
cd "target/${TARGET}/release/"
echo "Packaging ${MAIN_PKG_NAME}:"
7z -y a "${MAIN_PKG_NAME}" *.dll
cd -
echo ::set-output name=MAIN_PKG_NAME::"${MAIN_PKG_NAME}"
echo "MAIN_PKG_NAME=${MAIN_PKG_NAME}" >> $GITHUB_OUTPUT
;;
esac
- name: "Upload packages"
uses: actions/upload-artifact@master
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.job.target }}
path: |
Expand All @@ -241,7 +255,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Download result of previous builds
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
path: ARTIFACTS
- name: Publish as github release
Expand Down Expand Up @@ -271,7 +285,7 @@ jobs:
scp -o "StrictHostKeyChecking=no" -r * ${SSH_TARGET}:${DOWNLOAD_DIR}/
echo "---- cleanup identity"
ssh-add -D
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install Rust toolchain
run: rustup show
- name: Publish to crates.io
Expand Down

0 comments on commit adc779b

Please sign in to comment.