Github packages publish #60
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: | |
build-native: | |
runs-on: ${{ matrix.platform }} | |
strategy: | |
matrix: | |
platform: [ubuntu-20.04, macos-12, 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: 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 | |
- 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 | |
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: Build magickwand.js (WASM) | |
run: npm install --build-wasm-from-source --verbose --foreground-scripts --skip-magickwand-native | |
- name: Run headless test | |
uses: GabrielBB/xvfb-action@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, 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 |