From f14a3b170656070027067a232ab21d93b7551662 Mon Sep 17 00:00:00 2001 From: nieyuyao Date: Wed, 10 Apr 2024 21:52:16 +0800 Subject: [PATCH] chore: v0.0.1 --- .github/workflows/ci.yml | 18 ++------------- .github/workflows/release.yml | 43 +++++++++++++++++++++++++++++++++++ README.md | 7 +++--- package.json | 2 +- release.sh | 11 ++++++++- 5 files changed, 60 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e6d9af3..c7b068f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,20 +5,17 @@ name: CI on: push: - branches: - - main - - tags + branches: ['main'] pull_request: branches: ['main'] jobs: build: runs-on: ubuntu-latest - environment: release strategy: matrix: - node-version: [16.x, 18.x] + node-version: [16.x, 18.x, 20.x] steps: - uses: actions/checkout@v4 with: @@ -44,14 +41,3 @@ jobs: - name: test run: npm run test - - release: - if: ${{ startsWith(github.ref, 'refs/tags') && startsWith(github.ref_name, 'v') }} - runs-on: ubuntu-latest - needs: [build] - environment: release - steps: - - name: release - run: npm run release - env: - NPM_AUTH_TOKEN: ${{ vars.NPM_PUBLISH_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1fbe09d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,43 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: CI + +on: + push: + tags: + - 'v*' + +jobs: + release: + if: 'cancelled' + runs-on: ubuntu-latest + environment: release + + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - name: setup node + uses: actions/setup-node@v4 + with: + cache: 'npm' + node-version: 20 + + - name: install dependencies + run: npm install + + - name: setup emscripten + run: cd emsdk && ./emsdk install latest && ./emsdk activate latest && cd .. + + - name: build esm + run: npm run build:esm + + - name: build cjs + run: npm run build:cjs + + - name: release + run: npm run release + env: + NPM_AUTH_TOKEN: ${{ vars.NPM_TOKEN }} diff --git a/README.md b/README.md index 8051b16..120e3f9 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # webp.wasm -webp.wasm is a pure Webassembly / Javascript port of libwebp. +webp.wasm is a pure Webassembly / Javascript port of libwebp. The library supports encoding animated webp. ![CI](https://github.com/nieyuyao/webp-wasm/workflows/CI/badge.svg) +![Release](https://badgen.net/github/release/nieyuyao/webp-wasm/stable) ## APIs @@ -72,7 +73,7 @@ const webpData = await encodeRGBA(imgData.data, canvas.width, canvas.height) ... ``` -#### encode + #### encode A more advanced API is based on the WebPConfig. Only the lossless and quality parameters are supported now !!!. You can generate low-quality webp with this function. @@ -222,7 +223,7 @@ The image height in pixels. Raw data in pixels. -> Note: It looks like an `ImageData` object, but it is not. There is actually no `ImageData` in node. +> Note: It has same properties as browser `ImageData` object, but it is not. There is actually no `ImageData` in node. ## Playing Examples diff --git a/package.json b/package.json index 41dace6..45fa957 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wasm-webp", - "version": "0.0.1-beta.2", + "version": "0.0.1", "description": "", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", diff --git a/release.sh b/release.sh index 18323a1..4e3bfb0 100644 --- a/release.sh +++ b/release.sh @@ -1,3 +1,12 @@ echo -e "registry=https://registry.npmjs.org/\n_authToken=$NPM_AUTH_TOKEN" > .npmrc -npm publish --tag beta + +# get the version +NODE_VERSION=$(node -p -e "require('./package.json').version") + +if [[ $NODE_VERSION =~ "beta" ]]; then + # beta + npm publish --tag beta +else + npm publish +fi \ No newline at end of file