Skip to content

Commit

Permalink
Merge pull request #20 from catdad-experiments/libheif-latest
Browse files Browse the repository at this point in the history
updating to libheif 1.17.1, outputting js and wasm versions
  • Loading branch information
catdad authored Nov 5, 2023
2 parents 0fbb479 + f506f1e commit dc3ca88
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 15 deletions.
55 changes: 46 additions & 9 deletions .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ on:

jobs:
emscripten:
strategy:
matrix:
target: [js, wasm]
env:
EMSCRIPTEN_VERSION: 1.37.26
EMSCRIPTEN_VERSION: 3.1.47
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install emscripten
Expand All @@ -22,24 +25,54 @@ jobs:
working-directory: libheif
run: |
./scripts/prepare-ci.sh
- name: Run tests
- name: Run build and tests (JS)
if: ${{ matrix.target=='js' }}
working-directory: libheif
run: |
./scripts/run-ci.sh
- name: Run build and tests (WASM)
if: ${{ matrix.target=='wasm' }}
working-directory: libheif
run: |
sed s/USE_WASM=0/USR_WASM=1/g ./scripts/run-ci.sh > ./scripts/run-ci-wasm.sh
chmod +x ./scripts/run-ci-wasm.sh
./scripts/run-ci-wasm.sh
ls -la
- name: Dist prep
run: ./dist-prep.sh
run: ./dist-prep.sh ${{ matrix.target }}
- name: Artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: libheif-dist
name: ${{ matrix.target }}
path: dist
release:
runs-on: ubuntu-20.04
needs: [emscripten]
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
path: ./
- name: Arrange artifacts
run: |
mv js libheif
mv wasm libheif-wasm
touch libheif.tar.gz
tar -czf libheif.tar.gz libheif libheif-wasm
ls -lR
- name: Publish grouped artifacts
uses: actions/upload-artifact@v3
with:
name: libheif-dist
path: '.'
- name: Release
if: startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request'
uses: actions/github-script@v2
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs').promises;
const path = require('path');
console.log('environment', process.versions);
const { repo: { owner, repo }, sha, ref } = context;
Expand All @@ -55,12 +88,16 @@ jobs:
console.log('created release', { release });
for (let file of await fs.readdir('./dist')) {
for (let file of [
'./libheif.tar.gz',
'./libheif/libheif.js',
'./libheif/LICENSE'
]) {
console.log('uploading', file);
await github.repos.uploadReleaseAsset({
owner, repo,
release_id: release.data.id,
name: file,
data: await fs.readFile(`./dist/${file}`)
name: path.basename(file),
data: await fs.readFile(file)
});
}
37 changes: 32 additions & 5 deletions dist-prep.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
set -e

build_target="$1"

echoerr() { echo "$@" 1>&2; }

function assertFile {
Expand All @@ -12,11 +14,36 @@ function assertFile {

mkdir -p dist
rm -rf dist/*
cp libheif/libheif.js dist/libheif.js
cp libheif/COPYING dist/LICENSE

assertFile dist/libheif.js
assertFile dist/LICENSE
ls -la libheif

function copyJs() {
cp libheif/libheif.js dist/libheif.js
cp libheif/COPYING dist/LICENSE

assertFile dist/libheif.js
assertFile dist/LICENSE

chown $(whoami) dist/libheif.js dist/LICENSE
}

function copyWasm() {
copyJs

cp libheif/libheif.wasm dist/libheif.wasm
assertFile dist/libheif.wasm
chown $(whoami) dist/libheif.wasm
}

if [ "$build_target" = "js" ]
then
copyJs
elif [ "$build_target" = "wasm" ]
then
copyWasm
else
echo "unknown build target: $build_target"
exit 1
fi

chown $(whoami) dist/libheif.js dist/LICENSE
ls -la dist
2 changes: 1 addition & 1 deletion libheif
Submodule libheif updated 254 files

0 comments on commit dc3ca88

Please sign in to comment.