Github packages publish #68
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Github packages publish | |
on: workflow_dispatch | |
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: | |
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: | |
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: | |
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 | |
pack-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 | |
create-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' | |
- 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 | |
test_package: | |
uses: mmomtchev/magickwand.js/.github/workflows/test-package.yml@main | |
needs: create-npm-package | |
with: | |
package: magickwand.js-${{ needs.create-npm-package.outputs.version }}.tgz | |
download: true |