Skip to content

Commit

Permalink
chore(ci): fix release
Browse files Browse the repository at this point in the history
  • Loading branch information
Sec-ant committed Jan 30, 2024
1 parent 2db5388 commit 75fef5b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ permissions:
contents: write

env:
EM_VERSION: 3.1.51
EM_VERSION: 3.1.52
EM_CACHE_FOLDER: ".emsdk-cache"

jobs:
Expand All @@ -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 }}
Expand Down
49 changes: 48 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 75fef5b

Please sign in to comment.