Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump zxing-cpp to d0c1f34 and add pkg.pr.new #103

Merged
merged 1 commit into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/large-pots-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"zxing-wasm": patch
---

Bump zxing-cpp to `d0c1f34`
4 changes: 0 additions & 4 deletions .codesandbox/ci.json

This file was deleted.

40 changes: 40 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Setup
description: Setup the project

inputs:
emsdk-version:
description: EMSDK Version
required: true
default: 3.1.56
emsdk-cache-dir:
description: EMSDK Cache Directory
required: true
default: .emsdk-cache

runs:
using: composite
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: Setup System Libraries Cache
id: cache-system-libraries
uses: actions/cache@v4
with:
path: ${{ inputs.emsdk-cache-dir }}
key: ${{ inputs.emsdk-version }}-${{ runner.os }}

- name: Setup EMSDK
uses: mymindstorm/setup-emsdk@v14
with:
version: ${{ inputs.emsdk-version }}
actions-cache-folder: ${{ inputs.emsdk-cache-dir }}

- name: Install Dependencies
shell: bash
run: npm ci
22 changes: 22 additions & 0 deletions .github/workflows/preview-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Preview Release

on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
preview-release:
runs-on: ubuntu-latest
steps:
- name: Setup
uses: ./.github/actions/setup

- name: Build
run: npm run prepublishOnly

- name: Publish Preview Release
run: npx pkg-pr-new publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79 changes: 5 additions & 74 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Release

on:
workflow_dispatch:
push:
branches:
- main
Expand All @@ -14,92 +13,24 @@ permissions:
id-token: write

env:
EM_VERSION: 3.1.56
EM_CACHE_FOLDER: ".emsdk-cache"
NPM_CONFIG_PROVENANCE: true

concurrency: ${{ github.workflow }}-${{ github.ref }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
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 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: Get Package Name
if: ${{ github.event_name == 'workflow_dispatch' }}
id: get-package-name
run: echo "package-name=$(npm pkg get name | jq -r)" >> $GITHUB_OUTPUT

- name: Get Normalized Package Name
if: ${{ github.event_name == 'workflow_dispatch' }}
id: get-normalized-package-name
uses: frabert/replace-string-action@v2
with:
pattern: "^.*?([^/]+)$"
string: ${{ steps.get-package-name.outputs.package-name }}
replace-with: "$1"

- name: Patch package.json
if: ${{ github.event_name == 'workflow_dispatch' }}
run: npm pkg set version=${{ steps.get-commit-id.outputs.short-commit-id }}

- name: Build and Pack
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
npm run prepublishOnly
npm pack
- name: Draft Release
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "${{ steps.get-normalized-package-name.outputs.replaced }}-${{ steps.get-commit-id.outputs.short-commit-id }}.tgz"
artifactContentType: application/gzip
body: "This is a draft release of ${{ steps.get-package-name.outputs.package-name }}: ${{ steps.get-commit-id.outputs.short-commit-id }}."
commit: ${{ steps.get-commit-id.outputs.commit-id }}
tag: "draft"
draft: true
name: "draft"
removeArtifacts: true
- name: Setup
uses: ./.github/actions/setup
Comment on lines +26 to +27
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

Ensure the local action used in the "Setup" step is well-documented.

  • The action.yml file for the local action exists.
  • There is no documentation (README.md) for the setup action.
  • Test workflows for the setup action exist.

Please add documentation for the setup action to ensure it is well-documented.

Analysis chain

Ensure the local action used in the "Setup" step is well-documented and tested.

Would you like assistance in documenting or testing this action?

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the local action used in the "Setup" step.

# Test: Check if the action script exists and is executable.
if [[ -f ./.github/actions/setup/action.yml ]]; then
  echo "Setup action script exists."
else
  echo "Setup action script does not exist."
fi

Length of output: 110



Script:

#!/bin/bash
# Description: Verify the documentation and testing of the local action used in the "Setup" step.

# Check for README or documentation files in the action's directory.
if [[ -f ./.github/actions/setup/README.md ]]; then
  echo "Documentation for setup action exists."
else
  echo "Documentation for setup action does not exist."
fi

# Check for any test workflows that validate the action's functionality.
if grep -q 'uses: ./.github/actions/setup' .github/workflows/*.yml; then
  echo "Test workflows for setup action exist."
else
  echo "Test workflows for setup action do not exist."
fi

Length of output: 417


Consider adding conditions or checks to prevent unintended releases in the steps for version management and publishing.

steps:
  - name: Get Next Package Version
    if: github.event_name == 'push' && github.ref == 'refs/heads/main'
    id: package-version
    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: Create Release Pull Request or Publish to NPM
    if: github.event_name == 'push' && github.ref == 'refs/heads/main'
    id: changesets
    uses: changesets/action@v1
    with:
      version: npm run bump
      publish: npx changeset publish
      commit: "chore(release): v${{ steps.package-version.outputs.version }}"
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Also applies to: 30-30


- name: Get Next Package Version
if: ${{ github.event_name != 'workflow_dispatch' }}
id: package-version
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: Create Release Pull Request or Publish to NPM
if: ${{ github.event_name != 'workflow_dispatch' }}
id: changesets
uses: changesets/action@v1
with:
Expand Down
85 changes: 38 additions & 47 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading