Skip to content

Release

Release #20

Workflow file for this run

name: Release
on:
release:
types:
- published
jobs:
build:
env:
NUGET_UPLOAD_NUGET: ${{ secrets.NUGET_UPLOAD_NUGET }}
NUGET_UPLOAD_GITHUB: ${{ secrets.NUGET_UPLOAD_GITHUB }}
HTTPS_IMAGEFLOW_NIGHTLIES: "https://s3-us-west-1.amazonaws.com/imageflow-nightlies"
DOCKER_FETCH_COMMIT_SUFFIX: linux64
strategy:
fail-fast: false
matrix:
include:
- name: x86_64-ubuntu-20
suffix: ubuntu-x86_64
os: ubuntu-20.04
target-cpu: x86-64
commit-suffix: linux64
nuget-rid: linux-x64
target: x86_64-unknown-linux-gnu
- name: ARM64-ubuntu-24
suffix: ubuntu-arm64
os: ubuntu-24-arm-32gb
target-cpu: generic
commit-suffix: linux_arm64_glibc239
nuget-rid: linux-arm64
target: aarch64-unknown-linux-gnu
features: neon
cross: 'true'
- name: x86_64-macos-13
suffix: osx-x86_64
os: macos-13
target-cpu: haswell
commit-suffix: mac64
nuget-rid: osx-x64
target: x86_64-apple-darwin
- name: ARM64-macos-14
suffix: osx-aarch64
os: macos-14
target-cpu: apple-m1
commit-suffix: mac_aarch64
nuget-rid: osx-arm64
target: aarch64-apple-darwin
- name: x86_64-windows
suffix: win-x86_64
os: windows-2022
target-cpu: x86-64
commit-suffix: win-x86_64
nuget-rid: win-x64
target: x86_64-pc-windows-msvc
- name: win32
suffix: win-x86
os: windows-2022
target-cpu: i686
commit-suffix: win-x86
nuget-rid: win-x86
target: i686-pc-windows-msvc
- name: ARM64-windows
suffix: win-arm64
os: windows-11-arm-32gb
target-cpu: generic
commit-suffix: win-arm64
nuget-rid: win-arm64
target: aarch64-pc-windows-msvc
woa: 'true'
- name: x86_64-linux-musl
suffix: linux-musl-x64
commit-suffix: linux-musl-x64
nuget-rid: linux-musl-x64
os: ubuntu-24.04
target-cpu: x86-64
target: x86_64-unknown-linux-musl
target-feature: -crt-static
features: mimalloc
cross: 'true'
- name: ARM64-linux-musl
suffix: linux-musl-arm64
commit-suffix: linux_arm64_musl
nuget-rid: linux-musl-arm64
os: ubuntu-24-arm-32gb
target-cpu: generic
target-feature: -crt-static
target: aarch64-unknown-linux-musl
features: mimalloc
cross: 'true'
# todo target: aarch64-pc-windows-msvc instead of in test_woa.yml (once an official image is released)
# todo: Someday rewrite imageflow for wasm32-unknown-emscripten
runs-on: ${{ matrix.os }}
name: "${{ (matrix.cross == 'true') && 'cross ' || ''}}${{ matrix.name }}${{ matrix.target-cpu && format(' cpu: {0}', matrix.target-cpu) }}${{ matrix.target && format(' target: {0}', matrix.target) }}${{ matrix.features && format(' features: {0}', matrix.features) }} runs-on:${{ matrix.os }}"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: "WOA: Setup Windows ARM64"
uses: ./.github/actions/setup-win-arm64
if: matrix.woa == 'true'
- name: "WOA: Checkout code again with git, so git commands work."
uses: actions/checkout@v4
if: matrix.woa == 'true'
# Setup for matrix item NOT using cross or WOA
- uses: Swatinem/rust-cache@v2
with:
key: ${{matrix.name}}
if: matrix.cross != 'true' && matrix.woa != 'true'
- uses: dtolnay/rust-toolchain@stable
if: matrix.cross != 'true' && matrix.woa != 'true'
- run: rustup show
- name: Install NASM
uses: ./.github/actions/install-nasm
if: matrix.cross != 'true' && matrix.woa != 'true'
- name: Install i686 target
if: ${{ matrix.target == 'i686-pc-windows-msvc' && matrix.cross != 'true' }}
uses: dtolnay/rust-toolchain@stable
with:
target: i686-pc-windows-msvc
- run: rustup show
# Setup vars
- uses: FranzDiebold/[email protected]
- name: Set EXTENSION=zip if windows
if: contains(matrix.os, 'windows')
shell: bash
run: echo "EXTENSION=zip" >> $GITHUB_ENV
- name: Set EXTENSION=tar.gz if not windows
if: ${{ !contains(matrix.os, 'windows') }}
shell: bash
run: echo "EXTENSION=tar.gz" >> $GITHUB_ENV
- name: Set ENV vars TARGET_DIR, REL_BINARIES_DIR, TAG_SHA_SUFFIX
shell: bash
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
- name: Set env vars IMAGEFLOW_TOOL_PATH, ESTIMATED_ARTIFACT_URL
shell: bash
run: |
echo "IMAGEFLOW_TAG_SHA_SUFFIX=imageflow-${{ env.TAG_SHA_SUFFIX }}" >> $GITHUB_ENV
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/${{ env.IMAGEFLOW_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
echo "CI_REPO=${{ github.repository }}" >> $GITHUB_ENV
echo "CI_JOB_URL=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_ENV
echo "CI_JOB_TITLE=GitHub ${{ github.job_id }} ${{ matrix.name }}" >> $GITHUB_ENV
echo "CI_STRING=GitHub actions" >> $GITHUB_ENV
echo "CI_PULL_REQUEST_INFO=${{ github.event_name!='release' }}" >> $GITHUB_ENV
echo "CI_BUILD_URL=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_ENV
echo "ESTIMATED_DOCS_URL=${{ env.HTTPS_IMAGEFLOW_NIGHTLIES }}/doc" >> $GITHUB_ENV
echo "DEBUG=False" >> $GITHUB_ENV
echo "TARGET_CPU=${{ matrix.target-cpu }}" >> $GITHUB_ENV
- name: "Build ${{ env.PROFILE }}"
if: matrix.cross != 'true' && matrix.woa != 'true'
run: cargo build --all ${{ env.CARGO_PROFILE_TARGET_FEATURES_ARGS }}
shell: bash
#env:
# OPT_LEVEL: 0
- name: "Build ${{ env.PROFILE }}"
if: matrix.woa == 'true'
run: "& Launch-VsDevShell.ps1 | cargo build --all ${{ env.CARGO_PROFILE_TARGET_FEATURES_ARGS }}"
shell: powershell
- name: "Build ${{ env.PROFILE }} (Cross)"
uses: houseabsolute/[email protected]
with:
command: "build"
target: ${{ matrix.target }}
toolchain: stable
args: "${{ env.CROSS_ARGS }}"
if: matrix.cross == 'true'
- name: imageflow_tool diagnose --show-compilation-info
run: "${{ env.IMAGEFLOW_TOOL_PATH }} diagnose --show-compilation-info"
shell: bash
- name: "Test ${{ env.PROFILE }}"
run: cargo test --all --locked ${{ env.CARGO_PROFILE_TARGET_FEATURES_ARGS }}
shell: bash
if: matrix.cross != 'true'
- name: "Test ${{ env.PROFILE }} (WOA)"
run: "& Launch-VsDevShell.ps1 | cargo test --all ${{ env.CARGO_PROFILE_TARGET_FEATURES_ARGS }}"
shell: powershell
if: matrix.woa == 'true'
- name: "Test ${{ env.PROFILE }} (Cross)"
uses: houseabsolute/[email protected]
with:
command: "test"
target: ${{ matrix.target }}
toolchain: stable
args: "${{ env.CROSS_ARGS }}"
if: matrix.cross == 'true'
- name: "Build ${{ env.PROFILE }} Docs"
run: cargo doc --all --no-deps ${{ env.CARGO_PROFILE_TARGET_FEATURES_ARGS }}
if: matrix.cross != 'true'
# actions-rust-cross does not support cargo doc
- name: "mkdir -p ./${{ env.TARGET_DIR }}doc"
run: |
mkdir -p ./${{ env.TARGET_DIR }}doc
touch ./${{ env.TARGET_DIR }}doc/not-available.txt
if: matrix.cross == 'true'
- name: Create .zip / .tar.gz files for upload to Github Release & S3
shell: bash
run: |
mkdir -p ./artifacts/staging/headers || true
(
cd ./${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 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
rm ./artifacts/staging/*.{o,d,rlib} || true
rm ./artifacts/staging/*-* || true
(
cd ./artifacts/staging
tar czf "./archive.${{ env.EXTENSION }}" ./*
)
mkdir -p "./artifacts/upload/$(dirname "${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}" "./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
uses: Shopify/upload-to-release@master
with:
name: ${{ env.IMAGEFLOW_TAG_SHA_SUFFIX }}.${{ env.EXTENSION }}
path: ${{ env.RELATIVE_ARTIFACT_ARCHIVE }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
content-type: application/${{ env.EXTENSION == 'tar.gz' && 'gzip' || 'zip' }}
- name: "Create NuGet Package Imageflow.NativeTool.${{ matrix.nuget-rid }} in ./artifacts/nuget"
shell: bash
run: ./ci/pack_nuget/pack.sh tool
env:
CI_TAG: ${{ github.ref_name }}
PACKAGE_SUFFIX: ${{ matrix.suffix }}
NUGET_RUNTIME: ${{ matrix.nuget-rid }}
REPO_NAME: ${{ github.repository }}
BINARIES_DIR: "${{ github.workspace }}/${{ env.REL_BINARIES_DIR }}"
- name: "Create NuGet Package Imageflow.NativeRuntime.${{ matrix.nuget-rid }} in ./artifacts/nuget"
shell: bash
run: ./ci/pack_nuget/pack.sh
env:
CI_TAG: ${{ github.ref_name }}
PACKAGE_SUFFIX: ${{ matrix.suffix }}
NUGET_RUNTIME: ${{ matrix.nuget-rid }}
REPO_NAME: ${{ github.repository }}
BINARIES_DIR: "${{ github.workspace }}/${{ env.REL_BINARIES_DIR }}"
- name: Upload ./artifacts/upload to S3
uses: shallwefootball/s3-upload-action@master
with:
aws_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
aws_bucket: ${{ secrets.AWS_BUCKET }}
source_dir: ./artifacts/upload
destination_dir: ''
- name: Upload ./artifacts/nuget to S3
uses: shallwefootball/s3-upload-action@master
with:
aws_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
aws_bucket: ${{ secrets.AWS_BUCKET }}
source_dir: ./artifacts/nuget/
destination_dir: 'nuget'
- name: Publish to nuget.pkg.github.com
run: |
for f in ./artifacts/nuget/*.nupkg
do
curl -vX PUT -u "${{github.repository_owner}}:${{ secrets.GITHUB_TOKEN }}" -F package=@$f https://nuget.pkg.github.com/${{github.repository_owner}}/
done
shell: bash
if: ${{ env.NUGET_UPLOAD_GITHUB == 'true' }}
- name: Publish to nuget.org
run: |
for f in ./artifacts/nuget/*.nupkg
do
curl -L "https://www.nuget.org/api/v2/package" -H "X-NuGet-ApiKey: ${{ secrets.NUGET_API_KEY }}" -H "X-NuGet-Client-Version: 4.1.0" -A "NuGet Command Line/3.4.4.1321 (Unix 4.4.0.92)" --upload-file "$f" --fail
done
shell: bash
if: ${{ env.NUGET_UPLOAD_NUGET == 'true' }}
publish:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: FranzDiebold/[email protected]
- name: Publish To Docker
run: |
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
./ci/travis_publish_docker_images.sh docker/imageflow_tool imazen/imageflow_tool
env:
PUBLISH_DOCKER: True
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
PUBLISH_DOCKER_TAG: ${{ github.ref_name }}
IMAGEFLOW_DOWNLOAD_URL_TAR_GZ: ${{ env.HTTPS_IMAGEFLOW_NIGHTLIES }}/commits/${{ github.sha }}/${{ env.DOCKER_FETCH_COMMIT_SUFFIX }}.tar.gz