diff --git a/.github/workflows/release_ci.yml b/.github/workflows/release_ci.yml index 5d895dce9..af753f82f 100644 --- a/.github/workflows/release_ci.yml +++ b/.github/workflows/release_ci.yml @@ -12,6 +12,7 @@ jobs: NUGET_UPLOAD_GITHUB: ${{ secrets.NUGET_UPLOAD_GITHUB }} HTTPS_IMAGEFLOW_NIGHTLIES: "https://s3-us-west-1.amazonaws.com/imageflow-nightlies" DOCKER_FETCH_COMMIT_SUFFIX: linux64 + profile: release strategy: fail-fast: false @@ -152,9 +153,10 @@ jobs: run: | echo "TARGET_DIR=target/${{ matrix.target }}/" >> $GITHUB_ENV echo "TAG_SHA_SUFFIX=${{ github.ref_name }}-${{ env.GITHUB_SHA_SHORT }}-${{ matrix.suffix }}" >> $GITHUB_ENV - echo "RUSTFLAGS=${{ matrix.target-cpu && format('-C target-cpu={0}',matrix.target-cpu) }} ${{ matrix.target-feature && format('-C target-feature={0}',matrix.target-feature) }}" >> $GITHUB_ENV - echo "PROFILE=release" >> $GITHUB_ENV - echo "REL_BINARIES_DIR=target/${{ matrix.target }}/release/" >> $GITHUB_ENV + echo "RUSTFLAGS=${{ matrix.target-cpu && format('-Ctarget-cpu={0}',matrix.target-cpu) }} ${{ matrix.target-feature && format('-Ctarget-feature={0}',matrix.target-feature) }}" >> $GITHUB_ENV + echo "CARGO_PROFILE_TARGET_FEATURES_ARGS=--${{ env.PROFILE }} ${{ matrix.target && format('--target={0}',matrix.target) }} ${{ matrix.features && format('--features={0}',matrix.features) }}" >> $GITHUB_ENV + echo "CROSS_ARGS=--locked --${{ env.PROFILE }} ${{ matrix.features && format('--features={0}',matrix.features) }}" >> $GITHUB_ENV + echo "REL_BINARIES_DIR=target/${{ matrix.target }}/${{ env.PROFILE }}/" >> $GITHUB_ENV - name: Set env vars IMAGEFLOW_TOOL_PATH, ESTIMATED_ARTIFACT_URL shell: bash @@ -163,9 +165,6 @@ jobs: echo "IMAGEFLOW_TOOL_PATH=${{ env.REL_BINARIES_DIR }}imageflow_tool${{ contains(matrix.os, 'windows') && '.exe' || '' }}" >> $GITHUB_ENV echo "ESTIMATED_ARTIFACT_URL=${{ env.HTTPS_IMAGEFLOW_NIGHTLIES }}/${{ env.IMAGEFLOW_TAG_SHA_SUFFIX }}.${{ env.EXTENSION }}" >> $GITHUB_ENV echo "RELATIVE_ARTIFACT_ARCHIVE=./artifacts/github/imageflow-${{ env.TAG_SHA_SUFFIX }}.${{ env.EXTENSION }}" >> $GITHUB_ENV - echo "CARGO_PROFILE_TARGET_FEATURES_ARGS=--${{ env.PROFILE }} ${{ matrix.target && format('--target={0}',matrix.target) }} ${{ matrix.features && format('--features={0}',matrix.features) }}" >> $GITHUB_ENV - echo "CROSS_ARGS=--locked --${{ env.PROFILE }} ${{ matrix.features && format('--features={0}',matrix.features) }}" >> $GITHUB_ENV - echo "RUSTFLAGS=${{ matrix.target-cpu && format('-C target-cpu={0}',matrix.target-cpu) }}" >> $GITHUB_ENV echo "FETCH_COMMIT_SUFFIX=${{ matrix.commit-suffix }}" >> $GITHUB_ENV echo "CI_TAG=${{ github.ref_name }}" >> $GITHUB_ENV echo "CI=True" >> $GITHUB_ENV @@ -241,12 +240,12 @@ jobs: run: | mkdir -p ./artifacts/staging/headers || true ( - cd ./${TARGET_DIR}doc + cd ./${{ env.TARGET_DIR }}doc tar czf "../docs.${{ env.EXTENSION }}" ./* ) mv ./${{ env.TARGET_DIR }}docs.${{ env.EXTENSION }} ./artifacts/staging/ - cp -R ./${REL_BINARIES_DIR}/{imageflow_,libimageflow}* ./artifacts/staging/ + cp -R ./${{ env.REL_BINARIES_DIR }}/{imageflow_,libimageflow}* ./artifacts/staging/ cp bindings/headers/*.h ./artifacts/staging/headers/ cp bindings/headers/imageflow_default.h ./artifacts/staging/imageflow.h cp ./ci/packaging_extras/{install,uninstall}.sh ./artifacts/staging @@ -256,18 +255,18 @@ jobs: cd ./artifacts/staging tar czf "./archive.${{ env.EXTENSION }}" ./* ) - mkdir -p "./artifacts/upload/$(dirname "${RELATIVE_ARTIFACT_ARCHIVE}")" || true + mkdir -p "./artifacts/upload/$(dirname "${{ env.RELATIVE_ARTIFACT_ARCHIVE }}")" || true mkdir -p ./artifacts/github mkdir -p ./artifacts/upload/releases/${{ github.ref_name }} mkdir -p ./artifacts/upload/commits/${{ github.sha }} - cp "${TEMP_ARCHIVE_NAME}" "./${RELATIVE_ARTIFACT_ARCHIVE}" + cp "${TEMP_ARCHIVE_NAME}" "./${{ env.RELATIVE_ARTIFACT_ARCHIVE }}" cp "${TEMP_ARCHIVE_NAME}" "./artifacts/upload/releases/${{ github.ref_name }}/${{ env.IMAGEFLOW_TAG_SHA_SUFFIX }}.${{ env.EXTENSION }}" cp "${TEMP_ARCHIVE_NAME}" "./artifacts/upload/commits/${{ github.sha }}/${{ matrix.commit-suffix }}.${{ env.EXTENSION }}" env: TEMP_ARCHIVE_NAME: "./artifacts/staging/archive.${{ env.EXTENSION }}" - - name: Upload archive to Github Release + - name: Upload archive to Github Release from ${{ env.RELATIVE_ARTIFACT_ARCHIVE }} uses: Shopify/upload-to-release@master with: name: ${{ env.IMAGEFLOW_TAG_SHA_SUFFIX }}.${{ env.EXTENSION }} @@ -283,7 +282,7 @@ jobs: PACKAGE_SUFFIX: ${{ matrix.suffix }} NUGET_RUNTIME: ${{ matrix.nuget-rid }} REPO_NAME: ${{env.GITHUB_REPOSITORY_OWNER}}\/${{env.GITHUB_REPOSITORY_NAME}} - BINARIES_DIR: "${{ github.workspace }}/${{ env.REL_BINARIES_DIR }}" + BINARIES_DIR: "${{ env.REL_BINARIES_DIR }}" - name: "Create NuGet Package Imageflow.NativeRuntime.${{ matrix.nuget-rid }} in ./artifacts/nuget" shell: bash @@ -293,7 +292,7 @@ jobs: PACKAGE_SUFFIX: ${{ matrix.suffix }} NUGET_RUNTIME: ${{ matrix.nuget-rid }} REPO_NAME: ${{env.GITHUB_REPOSITORY_OWNER}}\/${{env.GITHUB_REPOSITORY_NAME}} - BINARIES_DIR: "${{ github.workspace }}/${{ env.REL_BINARIES_DIR }}" + BINARIES_DIR: "${{ env.REL_BINARIES_DIR }}" - name: Upload ./artifacts/upload to S3 uses: shallwefootball/s3-upload-action@master diff --git a/.github/workflows/test_ci.yml b/.github/workflows/test_ci.yml index 0075e2e92..54c516721 100644 --- a/.github/workflows/test_ci.yml +++ b/.github/workflows/test_ci.yml @@ -12,6 +12,8 @@ on: jobs: test: + env: + PROFILE: release strategy: fail-fast: false matrix: @@ -105,15 +107,19 @@ jobs: run: | echo "TARGET_DIR=target/${{ matrix.target }}/" >> $GITHUB_ENV echo "REL_BINARIES_DIR=target/${{ matrix.target }}/release/" >> $GITHUB_ENV - echo "RUSTFLAGS=${{ matrix.target-cpu && format('-C target-cpu={0}',matrix.target-cpu) }} ${{ matrix.target-feature && format('-C target-feature={0}',matrix.target-feature) }}" >> $GITHUB_ENV + echo "RUSTFLAGS=${{ matrix.target-cpu && format('-Ctarget-cpu={0}',matrix.target-cpu) }} ${{ matrix.target-feature && format('-Ctarget-feature={0}',matrix.target-feature) }}" >> $GITHUB_ENV + echo "CARGO_PROFILE_TARGET_FEATURES_ARGS=--${{ env.PROFILE }} ${{ matrix.target && format('--target={0}',matrix.target) }} ${{ matrix.features && format('--features={0}',matrix.features) }}" >> $GITHUB_ENV + echo "CROSS_ARGS=--locked --${{ env.PROFILE }} ${{ matrix.features && format('--features={0}',matrix.features) }}" >> $GITHUB_ENV + echo "REL_BINARIES_DIR=target/${{ matrix.target }}/${{ env.PROFILE }}/" >> $GITHUB_ENV - - name: Test - run: cargo test --all --locked --target ${{ matrix.target }} --release ${{ matrix.features && format('--features={0}',matrix.features) }} + - name: "cargo test --all --locked ${{ env.CARGO_PROFILE_TARGET_FEATURES_ARGS }}" + run: cargo test --all --locked ${{ env.CARGO_PROFILE_TARGET_FEATURES_ARGS }} shell: bash if: matrix.cross != 'true' + # matrix items USING CROSS - - name: Cross Test + - name: cross cargo test --target ${{ matrix.target }} ${{ env.CROSS_ARGS }} uses: houseabsolute/actions-rust-cross@v1.0.1 env: RUSTFLAGS: ${{ env.RUSTFLAGS }} @@ -121,6 +127,5 @@ jobs: command: "test" target: ${{ matrix.target }} toolchain: stable - args: - "--locked --release ${{ matrix.features && format('--features={0}',matrix.features) }}" + args: "${{ env.CROSS_ARGS }}" if: matrix.cross == 'true' diff --git a/ci/pack_nuget/pack.sh b/ci/pack_nuget/pack.sh index dc802b06a..ab23404de 100755 --- a/ci/pack_nuget/pack.sh +++ b/ci/pack_nuget/pack.sh @@ -33,18 +33,6 @@ if [[ -z "$BINARIES_DIR" ]]; then exit 1 fi -# fail if BINARIES_DIR is relative (windows or unix) -if [[ "${BINARIES_DIR:0:1}" != "/" && "${BINARIES_DIR:0:1}" != "\\" ]]; then - echo "BINARIES_DIR cannot be relative: $BINARIES_DIR" - exit 1 -fi - -# fail if BINARIES_DIR is not a directory -if [[ ! -d "$BINARIES_DIR" ]]; then - echo "BINARIES_DIR is not a directory: $BINARIES_DIR" - exit 1 -fi - # fail if BINARIES_DIR doesn't have a trailing slash if [[ "${BINARIES_DIR: -1}" != "/" ]]; then echo "BINARIES_DIR must end with a slash: $BINARIES_DIR" @@ -62,6 +50,16 @@ if [[ -z "$NUGET_RUNTIME" ]]; then exit 1 fi +# Resolve the relative path in BINARIES_DIR relative to the root of the repository (../../) +# We are currintly in ci/pack_nuget/pack.sh +BINARIES_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.."; pwd)/$BINARIES_DIR + +# fail if BINARIES_DIR is not a directory +if [[ ! -d "$BINARIES_DIR" ]]; then + echo "BINARIES_DIR is not a directory: $BINARIES_DIR" + exit 1 +fi + export NUGET_COMBINED_NAME="$NUGET_PACKAGE_NAME.$NUGET_PACKAGE_VERSION"