Skip to content

Commit

Permalink
Download libzim in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mgautierfr committed May 28, 2024
1 parent 893f0ea commit 35a8c6a
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 41 deletions.
47 changes: 28 additions & 19 deletions .github/workflows/check_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,45 @@ jobs:
strategy:
fail-fast: false
matrix:
build: [linux, macos, windows]
build: [linux, macos] #, windows
include:
- build: linux
os: ubuntu-latest
- build: macos
os: macos-latest
- build: windows
os: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download libzim
run: |
if [[ "${{ matrix.build }}" == "linux" ]]
then
ARCH="x86_64"
ARCH_POST="/x86_64-linux-gnu"
LIBZIM_NAME="libzim.so.9"
else
ARCH="arm64"
ARCH_POST=""
LIBZIM_NAME="libzim.9.dylib"
fi
VERSION="9.2.1"
ARCHIVE_NAME="libzim_${{ matrix.build }}-${ARCH}-${VERSION}"
wget "https://download.openzim.org/release/libzim/${ARCHIVE_NAME}.tar.gz"
tar xf ${ARCHIVE_NAME}.tar.gz
ARCHIVE_PATH=$(pwd)/${ARCHIVE_NAME}
LIBZIM_LIB=${ARCHIVE_PATH}/lib${ARCH_POST}
echo "LIBZIM_NAME=$LIBZIM_NAME" >> $GITHUB_ENV
echo "LIBZIM_LIB=$LIBZIM_LIB" >> $GITHUB_ENV
echo "LIBZIM_INCLUDE=${ARCHIVE_PATH}/include" >> $GITHUB_ENV
echo "DYLD_LIBRARY_PATH=${LIBZIM_LIB}:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV

- name: Build release binary
shell: bash
run: |
cargo build --verbose --release
if [ "${{ matrix.os }}" = "windows-latest" ]; then
bin="target/release/zim2waj.exe"
else
bin="target/release/zim2waj"
fi
bin="target/release/zim2waj"
echo "BIN=$bin" >> $GITHUB_ENV
- name: Strip release binary (macos)
Expand All @@ -79,22 +96,14 @@ jobs:
- name: Creating directory for archive
shell: bash
run: |
mkdir -p "$ARCHIVE"/{complete,doc}
cp "$BIN" "$ARCHIVE"/
cp "${LIBZIM_LIB}/${LIBZIM_NAME}" "$ARCHIVE/"
cp {README.md,LICENSE-MIT} "$ARCHIVE"/
cp Changelog.md "$ARCHIVE"/doc/
- name: Build archive (Windows)
shell: bash
if: matrix.os == 'windows-latest'
run: |
7z a "$ARCHIVE.zip" "$ARCHIVE"
certutil -hashfile "$ARCHIVE.zip" SHA256 > "$ARCHIVE.zip.sha256"
echo "ASSET=$ARCHIVE.zip" >> $GITHUB_ENV
echo "ASSET_SUM=$ARCHIVE.zip.sha256" >> $GITHUB_ENV
- name: Build archive (Unix)
shell: bash
if: matrix.os != 'windows-latest'
run: |
tar czf "$ARCHIVE.tar.gz" "$ARCHIVE"
shasum -a 256 "$ARCHIVE.tar.gz" > "$ARCHIVE.tar.gz.sha256"
Expand All @@ -104,7 +113,7 @@ jobs:
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: pre_release-${{ matrix.build }}
name: pre_release-zim2waj-${{ matrix.build }}
path: |
${{ env.ASSET }}
compression-level: 0
Expand Down
38 changes: 34 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,55 @@ jobs:
os:
- ubuntu-latest
- macos-latest
- windows-latest
# - windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check format
run: cargo fmt --all --check

- name: Download libzim
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]
then
OS="linux"
ARCH="x86_64"
ARCH_POST="/x86_64-linux-gnu"
LIBZIM_NAME="libzim.so.9"
else
OS="macos"
ARCH="arm64"
ARCH_POST=""
LIBZIM_NAME="libzim.9.dylib"
fi
VERSION="9.2.1"
ARCHIVE_NAME="libzim_${OS}-${ARCH}-${VERSION}"
wget "https://download.openzim.org/release/libzim/${ARCHIVE_NAME}.tar.gz"
tar xf ${ARCHIVE_NAME}.tar.gz
ARCHIVE_PATH=$(pwd)/${ARCHIVE_NAME}
LIBZIM_LIB=${ARCHIVE_PATH}/lib${ARCH_POST}
echo "LIBZIM_NAME=$LIBZIM_NAME" >> $GITHUB_ENV
echo "LIBZIM_LIB=$LIBZIM_LIB" >> $GITHUB_ENV
echo "LIBZIM_INCLUDE=${ARCHIVE_PATH}/include" >> $GITHUB_ENV
echo "DYLD_LIBRARY_PATH=${LIBZIM_LIB}:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
- name: Build
run: cargo build

- name: Test code
run: cargo test --verbose

- name: Prepare artefact dir
run: |
mkdir ARTEFACTS
cp target/debug/zim2waj ARTEFACTS
cp ${LIBZIM_LIB}/${LIBZIM_NAME} ARTEFACTS
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.os }}
name: zim2waj-${{ matrix.os }}
path: |
target/debug/zim2waj
target/debug/zim2waj.exe
ARTEFACTS/*
compression-level: 0
44 changes: 26 additions & 18 deletions .github/workflows/pre_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,45 @@ jobs:
strategy:
fail-fast: false
matrix:
build: [linux, macos, windows]
build: [linux, macos]
include:
- build: linux
os: ubuntu-latest
- build: macos
os: macos-latest
- build: windows
os: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download libzim
run: |
if [[ "${{ matrix.build }}" == "linux" ]]
then
ARCH="x86_64"
ARCH_POST="/x86_64-linux-gnu"
LIBZIM_NAME="libzim.so.9"
else
ARCH="arm64"
ARCH_POST=""
LIBZIM_NAME="libzim.9.dylib"
fi
VERSION="9.2.1"
ARCHIVE_NAME="libzim_${{ matrix.build }}-${ARCH}-${VERSION}"
wget "https://download.openzim.org/release/libzim/${ARCHIVE_NAME}.tar.gz"
tar xf ${ARCHIVE_NAME}.tar.gz
ARCHIVE_PATH=$(pwd)/${ARCHIVE_NAME}
LIBZIM_LIB=${ARCHIVE_PATH}/lib${ARCH_POST}
echo "LIBZIM_NAME=$LIBZIM_NAME" >> $GITHUB_ENV
echo "LIBZIM_LIB=$LIBZIM_LIB" >> $GITHUB_ENV
echo "LIBZIM_INCLUDE=${ARCHIVE_PATH}/include" >> $GITHUB_ENV
echo "DYLD_LIBRARY_PATH=${LIBZIM_LIB}:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV

- name: Build release binary
shell: bash
run: |
cargo build --verbose --release
if [ "${{ matrix.os }}" = "windows-latest" ]; then
bin="target/release/zim2waj.exe"
else
bin="target/release/zim2waj"
fi
bin="target/release/zim2waj"
echo "BIN=$bin" >> $GITHUB_ENV
- name: Strip release binary (macos)
Expand All @@ -91,21 +108,12 @@ jobs:
run: |
mkdir -p "$ARCHIVE"/{complete,doc}
cp "$BIN" "$ARCHIVE"/
cp "${LIBZIM_LIB}/${LIBZIM_NAME}" "$ARCHIVE/"
cp {README.md,LICENSE-MIT} "$ARCHIVE"/
cp Changelog.md "$ARCHIVE"/doc/
- name: Build archive (Windows)
shell: bash
if: matrix.os == 'windows-latest'
run: |
7z a "$ARCHIVE.zip" "$ARCHIVE"
certutil -hashfile "$ARCHIVE.zip" SHA256 > "$ARCHIVE.zip.sha256"
echo "ASSET=$ARCHIVE.zip" >> $GITHUB_ENV
echo "ASSET_SUM=$ARCHIVE.zip.sha256" >> $GITHUB_ENV
- name: Build archive (Unix)
shell: bash
if: matrix.os != 'windows-latest'
run: |
tar czf "$ARCHIVE.tar.gz" "$ARCHIVE"
shasum -a 256 "$ARCHIVE.tar.gz" > "$ARCHIVE.tar.gz.sha256"
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Download libzim
run: |
VERSION="9.2.1"
ARCHIVE_NAME="libzim_linux-x86_64-${VERSION}"
wget "https://download.openzim.org/release/libzim/${ARCHIVE_NAME}.tar.gz"
tar xf ${ARCHIVE_NAME}.tar.gz
ARCHIVE_PATH=$(pwd)/${ARCHIVE_NAME}
LIBZIM_LIB=${ARCHIVE_PATH}/lib/x86_64-linux-gnu
echo "LIBZIM_LIB=$LIBZIM_LIB" >> $GITHUB_ENV
echo "LIBZIM_INCLUDE=${ARCHIVE_PATH}/include" >> $GITHUB_ENV

- name: Publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
Expand Down

0 comments on commit 35a8c6a

Please sign in to comment.