Skip to content

Commit

Permalink
CI: split binaries into separate packages (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm authored Sep 21, 2024
1 parent c495221 commit 9483ac9
Show file tree
Hide file tree
Showing 75 changed files with 9,511 additions and 3,593 deletions.
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"project": "./tsconfig.json",
"sourceType": "module"
},
"ignorePatterns": ["dist/**"],
"ignorePatterns": [
"packages/*/dist/**"
],

"env": {
"jest/globals": true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gh-release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- if: steps.check.outputs.changed == 'true'
uses: volta-cli/action@v4
- if: steps.check.outputs.changed == 'true'
run: npm ci
run: npm ci --force

# Generate the release's markdown template
- if: steps.check.outputs.changed == 'true'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gh-repo-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: |
DATA=$(jq --raw-output --compact-output '{description: .description, homepage: .homepage}' package.json)
DATA=$(jq --raw-output --compact-output '{description: .description, homepage: .homepage}' packages/chdman/package.json)
curl \
--fail-with-body \
-X PATCH \
Expand All @@ -32,7 +32,7 @@ jobs:
env:
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- run: |
DATA=$(jq --raw-output --compact-output '{names: .keywords}' package.json)
DATA=$(jq --raw-output --compact-output '{names: .keywords}' packages/chdman/package.json)
curl \
--fail-with-body \
-X PUT \
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/mame-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
ls -al chdman
- name: Rename binary
run: |
dir="artifacts/bin/linux/${{ matrix.nodejs_arch }}"
dir="artifacts/packages/chdman-linux-${{ matrix.nodejs_arch }}"
mkdir -p "${dir}"
mv chdman "${dir}/"
- uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
- name: Rename binary
run: |
# shellcheck disable=SC2016
dir="artifacts/bin/$(node --eval 'console.log(`${process.platform}/${process.arch}`)')"
dir="artifacts/packages/chdman-$(node --eval 'console.log(`${process.platform}-${process.arch}`)')"
mkdir -p "${dir}"
mv chdman "${dir}/"
- uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -197,7 +197,7 @@ jobs:
ls -al chdman.exe
- name: Rename binary
run: |
dir="artifacts/bin/win32/${{ matrix.nodejs_arch }}"
dir="artifacts/packages/chdman-win32-${{ matrix.nodejs_arch }}"
mkdir -p "${dir}"
mv chdman.exe "${dir}/"
- uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -232,11 +232,11 @@ jobs:
else
new_version="${major_version}.${minor_version}.0"
fi
npm version "${new_version}" --no-git-tag-version || true
lerna version "${new_version}" --yes || true
chmod +x bin/**/*
chmod +x packages/chdman-*-*/chdman*
ls -alR
git add package*.json bin
git add package*.json lerna.json packages
USER_EMAIL="${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com"
echo "USER_EMAIL=${USER_EMAIL}" >> "${GITHUB_OUTPUT}"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/node-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ jobs:
- uses: volta-cli/action@v4
with:
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm ci --force
- id: publish
name: npm publish
run: |
set -x
npm whoami
npm publish
lerna publish from-package --yes
{
echo "PACKAGE_NAME=$(jq --raw-output '.name' package.json)"
echo "PACKAGE_VERSION=$(jq --raw-output '.version' package.json)"
Expand Down
28 changes: 16 additions & 12 deletions .github/workflows/node-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
filters: |
changes:
- '.github/workflows/node-test.yml'
- 'bin/**'
- 'src/**'
- 'test/**'
- 'packages/*/src/**'
- 'packages/*/test/**'
- 'packages/chdman-*-*/**'
- '*'
node-lint:
Expand All @@ -41,7 +41,7 @@ jobs:
# Setup and install
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
- run: npm ci
- run: npm ci --force
# Lint the source files
- run: npm run lint

Expand All @@ -51,16 +51,20 @@ jobs:
if: ${{ needs.path-filter.outputs.changes == 'true' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-13, macos-14, windows-latest ]
node-version: [ lts, 16.6.0 ]
node-version:
- lts
# Using this instead of v16.6.0 to get npm v8.1+ to fix workspace issues
- 16.12.0
steps:
# Setup and install
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm ci --force
- if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt-get update
Expand All @@ -71,14 +75,14 @@ jobs:
# Test the source files
- run: npm run test:unit

# Test building
- run: npm run build

# Test running
- run: |
npm start -- help
npm start -- createcd --input test/fixtures/cue/multiple.cue --output multiple.chd --hunksize 14688
npm start -- info --input multiple.chd
npm start --workspace=packages/chdman -- help
npm start --workspace=packages/chdman -- createcd --input test/fixtures/cue/multiple.cue --output multiple.chd --hunksize 14688
npm start --workspace=packages/chdman -- info --input multiple.chd
# Test building
- run: npm run build

# !!! This check should be required by GitHub !!!
test-status-check:
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/node-version-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ jobs:
# Setup and install
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
- run: npm ci
- run: npm ci --force

# Bump the version and commit to the default branch
- id: bump-and-commit
run: |
npm run "bump:${{ inputs.increment }}"
for PACKAGE in packages/chdman-*; do
# shellcheck disable=SC2005
echo "$(jq '. + (input|{description,keywords,homepage,bugs,license,author,funding,repository})' "${PACKAGE}/package.json" packages/chdman/package.json)" > "${PACKAGE}/package.json"
done
git add --all
USER_EMAIL="${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com"
Expand All @@ -45,7 +49,7 @@ jobs:
echo "USER_NAME=${USER_NAME}" >> "${GITHUB_OUTPUT}"
git config --global user.name "${USER_NAME}"
PACKAGE_VERSION="$(jq --raw-output '.version' package.json)"
PACKAGE_VERSION="$(jq --raw-output '.version' packages/chdman/package.json)"
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> "${GITHUB_OUTPUT}"
git commit -m "v${PACKAGE_VERSION}"
env:
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,8 @@ dist

# Custom
*.chd
.nx/
packages/*/dist/
packages/*/test/fixtures/*/build/
packages/*/junit.xml
packages/*/LICENSE
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
| OS | Architectures | Additional Instructions |
|------------------------|-------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Windows](./bin/win32) | <ul><li>x64</li><li>x86</li></ul> | |
| [macOS](./bin/darwin) | <ul><li>arm64 (Apple Silicon)</li><li>x64 (Intel)</li></ul> | [SDL2](https://www.libsdl.org/) is required to be installed separately:</li><pre>brew install sdl2</pre> |
| [macOS](./bin/darwin) | <ul><li>arm64 (Apple Silicon)</li><li>x64 (Intel)</li></ul> | [SDL2](https://www.libsdl.org/) is required to be installed separately:<pre>brew install sdl2</pre> |
| [Linux](./bin/linux) | <ul><li>x64</li><li>x86</li><li>arm (armhf)</li><li>arm64 (aarch64)</li></ul> | [SDL2](https://www.libsdl.org/) is required to be installed separately:<ul><li>Debian: `apt-get install libsdl2-2.0-0`</li><li>Gentoo: `emerge libsdl2`</li><li>Red Hat: `dnf install SDL2`</li></ul> |

## Running
Expand Down
20 changes: 20 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "0.269.0",
"packages": [
"packages/*"
],
"command": {
"version": {
"changelog": false,
"gitTagVersion": false,
"push": false,
"npmClientArgs": [
"--force"
]
},
"publish": {
"throttle": true
}
}
}
Loading

0 comments on commit 9483ac9

Please sign in to comment.