diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2cfe13de..8c8970a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ permissions: contents: write env: - EM_VERSION: 3.1.51 + EM_VERSION: 3.1.52 EM_CACHE_FOLDER: ".emsdk-cache" jobs: @@ -31,13 +31,13 @@ jobs: - name: Setup system libraries cache id: cache-system-libraries - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ${{ env.EM_CACHE_FOLDER }} key: ${{ env.EM_VERSION }}-${{ runner.os }} - name: Setup emsdk cache - uses: mymindstorm/setup-emsdk@v13 + uses: mymindstorm/setup-emsdk@v14 with: version: ${{ env.EM_VERSION }} actions-cache-folder: ${{ env.EM_CACHE_FOLDER }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 03582e86..797dead3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,12 +1,17 @@ name: Release on: + workflow_dispatch: push: branches: - main concurrency: ${{ github.workflow }}-${{ github.ref }} +env: + EM_VERSION: 3.1.52 + EM_CACHE_FOLDER: ".emsdk-cache" + jobs: release: name: Release @@ -27,14 +32,56 @@ jobs: with: node-version-file: .nvmrc + - name: Setup System Libraries Cache + id: cache-system-libraries + uses: actions/cache@v4 + with: + path: ${{ env.EM_CACHE_FOLDER }} + key: ${{ env.EM_VERSION }}-${{ runner.os }} + + - name: Setup EMSDK + uses: mymindstorm/setup-emsdk@v14 + with: + version: ${{ env.EM_VERSION }} + actions-cache-folder: ${{ env.EM_CACHE_FOLDER }} + - name: Install Dependencies run: npm ci - name: Get Next Package Version id: package-version - run: echo "version=$(npx changeset status --output=release.json && jq -r '.releases[0].newVersion' release.json && rm release.json)" >> "$GITHUB_OUTPUT" + run: echo "version=$(npx changeset status --output=release.json && jq -r '.releases[0].newVersion // '$(npm pkg get version)'' release.json && rm release.json)" >> $GITHUB_OUTPUT + + - name: Manual Bump and Pack + if: ${{ github.event_name == 'workflow_dispatch' }} + run: | + npm run bump + npm run build:all + npm pack + + - name: Get Commit ID + if: ${{ github.event_name == 'workflow_dispatch' }} + id: get-commit-id + run: | + echo "short-commit-id=$(git rev-parse --short $GITHUB_SHA)" >> $GITHUB_OUTPUT + echo "commit-id=$(git rev-parse $GITHUB_SHA)" >> $GITHUB_OUTPUT + + - name: Manual Draft Release + if: ${{ github.event_name == 'workflow_dispatch' }} + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + artifacts: "zxing-wasm-${{ steps.package-version.outputs.version }}.tgz" + artifactContentType: application/gzip + body: "This is a draft release of zxing-wasm: ${{ steps.get-commit-id.outputs.short-commit-id }}." + commit: ${{ steps.get-commit-id.outputs.commit-id }} + tag: "v${{ steps.package-version.outputs.version }}-draft.${{ steps.get-commit-id.outputs.short-commit-id }}" + draft: true + name: "zxing-wasm v${{ steps.package-version.outputs.version }}-draft.${{ steps.get-commit-id.outputs.short-commit-id }}" + removeArtifacts: true - name: Create Release Pull Request or Publish to NPM + if: ${{ github.event_name != 'workflow_dispatch' }} id: changesets uses: changesets/action@v1 with: diff --git a/package.json b/package.json index 7f048f12..87a5895f 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "scripts": { "update-hooks": "simple-git-hooks", "changeset": "changeset", - "bump": "changeset version 2>/dev/null | grep . && npm i", + "bump": "changeset version 2>/dev/null | grep . && npm i; exit 0", "submodule:init": "git submodule update --init", "submodule:update": "git submodule update --remote", "cmake": "emcmake cmake -S src/cpp -B build",