Skip to content

Build LibHeif

Build LibHeif #74

Workflow file for this run

name: Build LibHeif
on:
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:
jobs:
check:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set_release.outputs.version }}
name: ${{ steps.set_release.outputs.name }}
body: ${{ steps.set_release.outputs.body }}
steps:
- name: Get Libheif Release
id: libheif_release
uses: joutvhu/get-release@v1
with:
owner: strukturag
repo: libheif
latest: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get Current Release
id: latest_release
uses: joutvhu/get-release@v1
with:
pattern: 'v.+_libheif'
latest: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set version by release
id: cut_suffix
run: |
echo "::set-output name=version::$(echo ${{ steps.latest_release.outputs.tag_name }} | cut -f 1 -d _)"
- name: Set version
id: set_release
if: ${{ steps.cut_suffix.outputs.version != steps.libheif_release.outputs.tag_name }}
run: |
echo "::set-output name=version::$(echo ${{ steps.libheif_release.outputs.tag_name }} | cut -c 2-)"
echo "::set-output name=name::${{ steps.libheif_release.outputs.name }}"
echo "::set-output name=body::${{ steps.libheif_release.outputs.body }}"
build:
runs-on: ubuntu-latest
needs: check
env:
EMSCRIPTEN_VERSION: 3.1.47
if: ${{ needs.check.outputs.version != null }}
steps:
- uses: actions/checkout@v3
- name: Download and extract libheif
run: |
chmod +x libheif.sh
./libheif.sh ${{ needs.check.outputs.version }} --extract
- name: Install emscripten
working-directory: libheif
run: |
./scripts/install-ci-linux.sh
- name: Prepare CI
working-directory: libheif
run: |
./scripts/prepare-ci.sh
- name: Run CI
working-directory: libheif
run: |
./scripts/run-ci.sh
- name: Copy file
run: |
mkdir -p dist
rm -rf dist/*
cp libheif/libheif.js dist/libheif.min.js
cp libheif/COPYING dist/LICENSE
ls -a -R
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: libheif-js
path: |
dist/libheif.min.js
dist/LICENSE
unminify:
runs-on: ubuntu-latest
needs: build
steps:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install packages
run: npm i -g unminify
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: libheif-js
path: dist
- name: Unminify libheif
run: unminify dist/libheif.min.js | sudo tee dist/libheif.js
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: libheif
path: |
dist/libheif.min.js
dist/libheif.js
dist/LICENSE
- uses: joutvhu/delete-artifact@v1
with:
name: libheif-js
release:
runs-on: ubuntu-latest
needs: [check, build]
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create Release
id: create_release
uses: joutvhu/create-release@v1
with:
tag_name: v${{ needs.check.outputs.version }}_libheif
name: Release libheif ${{ needs.check.outputs.name }}
body: |
Create libheif.js for https://github.com/strukturag/libheif/releases/tag/v${{ needs.check.outputs.version }}
${{ needs.check.outputs.body }}
draft: false
release: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
upload:
runs-on: ubuntu-latest
needs: [unminify, release]
if: ${{ needs.release.outputs.upload_url != null }}
permissions:
contents: write
packages: write
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: libheif
- name: Upload libheif file
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_name: libheif.min.js
asset_path: ./libheif.min.js
asset_content_type: text/javascript
- name: Upload unminify file
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_name: libheif.js
asset_path: ./libheif.js
asset_content_type: text/javascript
- name: Upload LICENSE file
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_name: LICENSE
asset_path: ./LICENSE
asset_content_type: text/plain
- uses: joutvhu/delete-artifact@v1
with:
name: libheif