| 1 |
name: Emscripten |
| 2 |
|
| 3 |
on: |
| 4 |
workflow_dispatch: |
| 5 |
push: |
| 6 |
branches: [ master ] |
| 7 |
|
| 8 |
jobs: |
| 9 |
js-build: |
| 10 |
name: Build liblouis for js |
| 11 |
|
| 12 |
runs-on: ubuntu-latest |
| 13 |
|
| 14 |
steps: |
| 15 |
- name: Harden Runner |
| 16 |
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 |
| 17 |
with: |
| 18 |
egress-policy: audit |
| 19 |
|
| 20 |
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
- name: Obtain liblouis-js |
| 26 |
run: git clone https://github.com/liblouis/liblouis-js.git |
| 27 |
|
| 28 |
- name: Pull the docker image |
| 29 |
run: docker pull dolp/liblouis-js-build-travis:1.37.3-64bit |
| 30 |
|
| 31 |
- name: Run the docker image |
| 32 |
run: docker run --rm -v $(pwd):/src dolp/liblouis-js-build-travis:1.37.3-64bit /bin/bash ".github/workflows/scripts/emscripten-build.sh" |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
- name: Upload the release assets |
| 55 |
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a |
| 56 |
with: |
| 57 |
name: build-no-tables-utf32.js |
| 58 |
path: ./out/build-no-tables-utf32.js |
| 59 |
|
| 60 |
- name: Upload the assets to the snapshot release |
| 61 |
|
| 62 |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository =='liblouis/liblouis'}} |
| 63 |
uses: shogo82148/actions-upload-release-asset@394b3c11c3cfc038b5396ad265c074065cf875c3 |
| 64 |
with: |
| 65 |
github_token: ${{ secrets.GITHUB_TOKEN }} |
| 66 |
upload_url: https://uploads.github.com/repos/liblouis/liblouis/releases/8031256/assets{?name,label} |
| 67 |
asset_path: ./out/build-no-tables-utf32.js |
| 68 |
asset_name: build-no-tables-utf32.js |
| 69 |
asset_content_type: application/javascript |
| 70 |
overwrite: true |
| 71 |
|
| 72 |
- name: Publish JS file and tables to js-build |
| 73 |
|
| 74 |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository =='liblouis/liblouis'}} |
| 75 |
env: |
| 76 |
GITHUB_TOKEN: ${{ secrets.JS_BUILD_GITHUB_TOKEN }} |
| 77 |
run: | |
| 78 |
# clone the repository to a location outside of the liblouis |
| 79 |
# repository to avoid issues caused by nested repositories |
| 80 |
git clone --depth 1 https://github.com/liblouis/js-build.git ../js-build |
| 81 |
rm -f ../js-build/build-*.js |
| 82 |
rm -rf ../js-build/tables/ |
| 83 |
cp -R ./out-emscripten-install/share/liblouis/tables/ ../js-build/tables/ |
| 84 |
cp -Rf ./out/* ../js-build/ |
| 85 |
cd ../js-build |
| 86 |
git add --all |
| 87 |
git remote set-url origin https://${GITHUB_TOKEN}@github.com/liblouis/js-build.git |
| 88 |
git config user.name "Github CI" |
| 89 |
git config user.email "[email protected]" |
| 90 |
BUILD_VERSION=commit-$(echo $GITHUB_SHA | cut -c1-6) |
| 91 |
if [[ -z $(git diff --cached --exit-code) ]]; then |
| 92 |
: Build is identical to previous build. Omitting commit, only adding tag. |
| 93 |
else |
| 94 |
git commit -m "Automatic build of version ${BUILD_VERSION}" |
| 95 |
git push origin master:master |
| 96 |
fi |
| 97 |
git tag -a ${BUILD_VERSION} -m "automatic build for version ${BUILD_VERSION}" |
| 98 |
git push origin $BUILD_VERSION:$BUILD_VERSION |