Skip to content

Commit

Permalink
publishing scripts (#51)
Browse files Browse the repository at this point in the history
* upgrade the project to alpha

* create publishing scripts

* swig workflow

* basic publishing scripts

* publishing scripts

* wire the build to the npm install command

* skip binaries when linting

* avoid cmd multi-line syntax

* optional build cache
  • Loading branch information
mmomtchev authored Oct 19, 2024
1 parent 46e4cd5 commit 3e88529
Show file tree
Hide file tree
Showing 12 changed files with 383 additions and 48 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ on:
type: boolean
default: true
description: include TIFF support
conan_cache:
type: boolean
default: true
description: cache conan artifacts


jobs:
build:
Expand Down Expand Up @@ -70,13 +75,9 @@ jobs:

- name: Install dependencies
run: |
npm install
npm install --skip-proj-wasm --skip-proj-native
npx xpm install
- name: Install the xpacks
run: |
npm install xpm
npx xpm install
- name: Get conan home
shell: bash
id: conan_home
Expand All @@ -85,6 +86,7 @@ jobs:
echo path=`npx xpm run -q conan -- config home` >> $GITHUB_OUTPUT
- name: Cache conan artifacts
uses: actions/cache@v4
if: inputs.conan_cache
with:
path: ${{ steps.conan_home.outputs.path }}
key: conan-${{ inputs.id }}
Expand All @@ -96,15 +98,19 @@ jobs:
echo "${{ inputs.enable_tiff && 'npm_config_enable_tiff' || 'npm_config_disable_tiff' }}=true" >> $GITHUB_ENV
- name: Build the native version
shell: bash
run: |
npx xpm run prepare --config native
npx xpm run build --config native
npm install --skip-proj-wasm --build-from-source --verbose --foreground-scripts \
${{ inputs.enable_tiff && '--enable-tiff' || '--disable-tiff' }} \
${{ inputs.inline_projdb && '--enable-inline-projdb' || '--disable-inline-projdb' }}
if: inputs.native

- name: Build the WASM version
shell: bash
run: |
npx xpm run prepare --config wasm
npx xpm run build --config wasm
npm install --skip-proj-native --build-wasm-from-source --verbose --foreground-scripts \
${{ inputs.enable_tiff && '--enable-tiff' || '--disable-tiff' }} \
${{ inputs.inline_projdb && '--enable-inline-projdb' || '--disable-inline-projdb' }}
${EMSDK}/upstream/bin/wasm-opt --enable-bulk-memory --enable-threads --converge -Oz lib/binding/emscripten-wasm32/proj.wasm -o proj.opt.wasm
mv proj.opt.wasm lib/binding/emscripten-wasm32/proj.wasm
if: inputs.wasm
Expand Down
168 changes: 168 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
name: Publish
on:
workflow_dispatch:
inputs:
prerelease:
type: boolean
default: false
description: whether the release should be marked as a prerelease

jobs:
swig:
name: Generate the SWIG wrappers
uses:
./.github/workflows/swig.yml


build-native:
name: Build native ${{ matrix.platform && '' || '' }}
needs: swig

strategy:
fail-fast: false
matrix:
include:
- platform: ubuntu-20.04
id: linux-x64
- platform: macos-latest
id: darwin-arm64
- platform: macos-12
id: darwin-x64
- platform: windows-2019
id: windows-x64

uses:
./.github/workflows/build.yml
with:
platform: ${{ matrix.platform }}
native: true
wasm: false
id: ${{ matrix.id }}
enable_tiff: true


build-wasm:
name: Build WASM
needs: swig

uses:
./.github/workflows/build.yml
with:
platform: ubuntu-latest
native: false
wasm: true
enable_tiff: true
inline_projdb: false
id: emscripten-wasm32


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: proj.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: ./.github/workflows/test-package.yml
needs: [ publish-release, create-npm-package ]
with:
package: proj.js-${{ needs.create-npm-package.outputs.version }}.tgz
download: true
39 changes: 6 additions & 33 deletions .github/workflows/run.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'CI'
name: CI
on: [pull_request, push]

jobs:
Expand All @@ -12,41 +12,14 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
- name: Install dependencies
run: npm ci
run: npm ci --skip-proj-wasm --skip-proj-native
- name: Lint
run: npm run lint


swig:
runs-on: ubuntu-latest
name: Generate the SWIG wrappers

strategy:
fail-fast: false

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- uses: mmomtchev/setup-swig@main
with:
branch: jse
version: main
cache: false

- name: Verify SWIG
run: swig-jse -version

- name: Run SWIG to generate the wrappers
run: npm run swig

- name: Upload SWIG-generated wrappers
uses: actions/upload-artifact@v4
with:
name: swig-generated
path: |
swig/*
uses: ./.github/workflows/swig.yml


build-native:
Expand Down Expand Up @@ -156,7 +129,7 @@ jobs:
path: lib/binding

- name: Install dependencies
run: npm install
run: npm install --skip-proj-wasm --skip-proj-native

- name: Run the Node.js tests
run: npm run test:nodejs
Expand Down Expand Up @@ -205,7 +178,7 @@ jobs:

- name: Install dependencies
run: |
npm install
npm install --skip-proj-wasm --skip-proj-native
npx xpm install
- name: Run the Node.js tests
Expand Down Expand Up @@ -248,7 +221,7 @@ jobs:

- name: Install dependencies
run: |
npm install
npm install --skip-proj-wasm --skip-proj-native
npx xpm install
- name: Run the Node.js tests
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/swig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Generate the SWIG wrappers

on:
workflow_call:

jobs:
swig:
runs-on: ubuntu-latest
name: Generate the SWIG wrappers

strategy:
fail-fast: false

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- uses: mmomtchev/setup-swig@main
with:
branch: jse
version: main
cache: false

- name: Verify SWIG
run: swig-jse -version

- name: Run SWIG to generate the wrappers
run: npm run swig

- name: Upload SWIG-generated wrappers
uses: actions/upload-artifact@v4
with:
name: swig-generated
path: |
swig/*
Loading

0 comments on commit 3e88529

Please sign in to comment.