Skip to content

Github packages publish #74

Github packages publish

Github packages publish #74

Workflow file for this run

name: Github packages publish
on:
workflow_dispatch:
inputs:
prerelease:
type: boolean
default: false
description: whether the release should be marked as a prerelease
jobs:
swig:
runs-on: ubuntu-latest
name: Generate the SWIG wrappers
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- uses: mmomtchev/setup-swig@main
with:
branch: jse
version: v5.0.5
- name: Verify SWIG
run: swig-jse -version
- name: Run SWIG to generated the wrappers
run: npx xpm run generate
- name: Upload SWIG-generated wrappers
uses: actions/upload-artifact@v4
with:
name: swig
path: swig/*
build-native:
name: Build the native modules
runs-on: ${{ matrix.platform }}
needs: swig
strategy:
matrix:
platform:
- ubuntu-20.04
- macos-12
- macos-latest
- windows-2022
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Download the SWIG-generated wrappers
uses: actions/download-artifact@v4
with:
name: swig
path: swig
- name: Install fonts on Ubuntu
run: sudo apt-get install -y fonts-ubuntu || true
if: startsWith(matrix.platform, 'ubuntu')
- name: Build magickwand.js (native)
run: npm install --build-from-source --verbose --foreground-scripts --skip-magickwand-wasm --enable-conan --disable-display
- run: npx mocha test/node.test.ts test/integration.test.ts
env:
MOCHA_INTEGRATION: node
MOCHA_MAGICK_INSTALL: "node -e \"fs.symlinkSync(process.env.GITHUB_WORKSPACE, path.resolve('node_modules', 'magickwand.js'), os.platform() == 'win32' ? 'junction': 'dir')\""
- name: Node.js platform ID string
id: platform
shell: bash
run: node -p '"plat=" + os.platform() + "-" + os.arch()' >> "$GITHUB_OUTPUT"
- name: Upload native artifact ${{ matrix.platform }}
uses: actions/upload-artifact@v4
with:
name: ${{ steps.platform.outputs.plat }}
path: lib/binding/*
build-wasm:
name: Build the WASM module
runs-on: ubuntu-latest
needs: swig
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Setup emscripten
uses: mymindstorm/setup-emsdk@v14
with:
version: 3.1.53
- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Download the SWIG-generated wrappers
uses: actions/download-artifact@v4
with:
name: swig
path: swig
- name: Build magickwand.js (WASM)
run: npm install --build-wasm-from-source --verbose --foreground-scripts --skip-magickwand-native --enable-conan --disable-display
- name: Run headless test
uses: coactions/setup-xvfb@v1
env:
MOCHA_INTEGRATION: browser
MOCHA_MAGICK_INSTALL: ln -s ${{ github.workspace }} node_modules/magickwand.js
with:
run: npx mocha test/browser.test.ts test/integration.test.ts
- name: Upload native artifact emscripten-wasm32
uses: actions/upload-artifact@v4
with:
name: emscripten-wasm32
path: lib/binding/*
create-release:
name: Create the Github release
runs-on: ubuntu-latest
needs: [ build-native, build-wasm ]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Create Release
uses: ncipollo/release-action@v1
with:
draft: true
prerelease: ${{ inputs.prerelease }}
pack-prebuilt-binaries:
name: Pack the prebuilt binaries
runs-on: ubuntu-latest
needs: [ create-release ]
permissions:
contents: write
strategy:
fail-fast: false
matrix:
platform: [linux-x64, win32-x64, darwin-x64, darwin-arm64, emscripten-wasm32]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Download the artifact for ${{ matrix.platform }}
uses: actions/download-artifact@v4
with:
name: ${{ matrix.platform }}
path: lib/binding
- name: Pack
run:
tar -zcvf ${{ matrix.platform }}.tar.gz lib/binding
- name: Publish
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: ${{ matrix.platform }}.tar.gz
updateOnlyUnreleased: true
omitDraftDuringUpdate: true
omitPrereleaseDuringUpdate: true
create-npm-package:
name: Create the npm package
runs-on: ubuntu-latest
needs: [ build-native, build-wasm ]
permissions:
contents: write
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Download the SWIG-generated wrappers
uses: actions/download-artifact@v4
with:
name: swig
path: swig
- run: npm pack
- name: Get version
id: version
run: node -p '"version=" + require("./package.json").version' >> "$GITHUB_OUTPUT"
- name: Upload the npm package
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: magickwand.js-${{ steps.version.outputs.version }}.tgz
updateOnlyUnreleased: true
omitDraftDuringUpdate: true
omitPrereleaseDuringUpdate: true
publish-release:
name: Publish the Github release
runs-on: ubuntu-latest
needs: [ create-npm-package, pack-prebuilt-binaries ]
steps:
- name: Publish the draft release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
omitDraftDuringUpdate: false
draft: false
omitPrereleaseDuringUpdate: true
test_package:
name: Test the npm package
uses: mmomtchev/magickwand.js/.github/workflows/test-package.yml@main
needs: [ publish-release, create-npm-package ]
with:
package: magickwand.js-${{ needs.create-npm-package.outputs.version }}.tgz
download: true