diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db88e8aff..027dc039f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - run: yarn install --frozen-lockfile - run: yarn clean - run: yarn build:packages - - run: npm run publish-release -- canary + - run: npx --yes -w packages wet-run@1.2.3 release prerelease --prerelease canary --provenance --log-level verbose if: ${{ github.ref == 'refs/heads/main' }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/lerna.json b/lerna.json deleted file mode 100644 index b72311af4..000000000 --- a/lerna.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "packages": ["packages/*", "examples/*", "scripts/*"], - "npmClient": "yarn", - "useWorkspaces": true, - "version": "independent", - "ignoreChanges": ["**/test/**", "**/*.md"] -} diff --git a/package.json b/package.json index 07c962c72..4f63e49d1 100644 --- a/package.json +++ b/package.json @@ -32,8 +32,7 @@ "build:packages": "turbo run build --filter '!./examples/*'", "build": "turbo run build", "i18n": "turbo run i18n", - "prepare": "husky install", - "publish-release": "npm run publish-release -w packages --" + "prepare": "husky install" }, "resolutions": { "playwright": "1.45.3" diff --git a/packages/mux-active-viewer-count/package.json b/packages/mux-active-viewer-count/package.json index 43670054d..2295c16f3 100644 --- a/packages/mux-active-viewer-count/package.json +++ b/packages/mux-active-viewer-count/package.json @@ -57,8 +57,7 @@ "copypolyfills": "shx mkdir -p src/polyfills && shx cp ../../shared/polyfills/index.ts ./src/polyfills/index.ts", "build:types": "tsc", "postbuild:types": "downlevel-dts ./dist/types ./dist/types-ts3.4", - "build": "npm-run-all --parallel 'build:esm --minify' 'build:iife --minify' 'build:cjs --minify' 'build:esm-module --minify'", - "publish-release": "../../scripts/publish.sh" + "build": "npm-run-all --parallel 'build:esm --minify' 'build:iife --minify' 'build:cjs --minify' 'build:esm-module --minify'" }, "devDependencies": { "@open-wc/testing": "^4.0.0", diff --git a/packages/mux-audio-react/package.json b/packages/mux-audio-react/package.json index f15ae4b36..a0961d03c 100644 --- a/packages/mux-audio-react/package.json +++ b/packages/mux-audio-react/package.json @@ -50,8 +50,7 @@ "build:esm": "esbuild src/index.tsx --target=es2019 --bundle --sourcemap --metafile=./dist/esm.json --format=esm --outdir=dist --out-extension:.js=.mjs --external:react --external:prop-types --external:@mux/* --define:PLAYER_VERSION=\"'$npm_package_version'\"", "build:types": "tsc", "postbuild:types": "downlevel-dts ./dist/types ./dist/types-ts3.4", - "build": "npm-run-all --parallel 'build:cjs --minify' 'build:esm --minify'", - "publish-release": "../../scripts/publish.sh" + "build": "npm-run-all --parallel 'build:cjs --minify' 'build:esm --minify'" }, "peerDependencies": { "@types/react": "^17.0.0 || ^17.0.0-0 || ^18 || ^18.0.0-0 || ^19 || ^19.0.0-0", diff --git a/packages/mux-audio/package.json b/packages/mux-audio/package.json index b1b779a79..c0af89553 100644 --- a/packages/mux-audio/package.json +++ b/packages/mux-audio/package.json @@ -60,8 +60,7 @@ "copypolyfills": "shx mkdir -p src/polyfills && shx cp ../../shared/polyfills/index.ts ./src/polyfills/index.ts", "build:types": "tsc", "postbuild:types": "downlevel-dts ./dist/types ./dist/types-ts3.4", - "build": "npm-run-all --parallel 'build:esm --minify' 'build:iife --minify' 'build:cjs --minify' 'build:esm-module --minify'", - "publish-release": "../../scripts/publish.sh" + "build": "npm-run-all --parallel 'build:esm --minify' 'build:iife --minify' 'build:cjs --minify' 'build:esm-module --minify'" }, "dependencies": { "@mux/playback-core": "0.27.0", diff --git a/packages/mux-elements-codemod/package.json b/packages/mux-elements-codemod/package.json index 89bba2d29..037f88853 100644 --- a/packages/mux-elements-codemod/package.json +++ b/packages/mux-elements-codemod/package.json @@ -19,8 +19,7 @@ "dev": "npm-run-all --parallel dev:types dev:esm", "build:esm": "esbuild src/index.ts --target=es2019 --format=esm --outdir=dist --out-extension:.js=.mjs", "build:types": "tsc", - "build": "npm-run-all --parallel build:esm", - "publish-release": "../../scripts/publish.sh" + "build": "npm-run-all --parallel build:esm" }, "dependencies": { "chalk": "^5.0.1", diff --git a/packages/mux-player-react/package.json b/packages/mux-player-react/package.json index a28838dde..525987504 100644 --- a/packages/mux-player-react/package.json +++ b/packages/mux-player-react/package.json @@ -80,8 +80,7 @@ "build:esm:lazy": "esbuild src/lazy.tsx --splitting --target=es2019 --bundle --sourcemap --metafile=./dist/esm.lazy.json --format=esm --loader:.css=text --outdir=dist --out-extension:.js=.mjs --external:react --external:@mux/* --external:prop-types --define:PLAYER_VERSION=\"'$npm_package_version'\"", "build:types": "tsc", "postbuild:types": "downlevel-dts ./dist/types ./dist/types-ts3.4", - "build": "npm-run-all --parallel 'build:cjs --minify' 'build:esm --minify' 'build:esm:lazy --minify'", - "publish-release": "../../scripts/publish.sh" + "build": "npm-run-all --parallel 'build:cjs --minify' 'build:esm --minify' 'build:esm:lazy --minify'" }, "peerDependencies": { "@types/react": "^17.0.0 || ^17.0.0-0 || ^18 || ^18.0.0-0 || ^19 || ^19.0.0-0", diff --git a/packages/mux-player/package.json b/packages/mux-player/package.json index bb5e576d5..a73177604 100644 --- a/packages/mux-player/package.json +++ b/packages/mux-player/package.json @@ -90,8 +90,7 @@ "copypolyfills": "shx mkdir -p src/polyfills && shx cp ../../shared/polyfills/index.ts ./src/polyfills/index.ts", "build:types": "tsc", "postbuild:types": "downlevel-dts ./dist/types ./dist/types-ts3.4", - "build": "npm-run-all --parallel 'build:esm --minify' 'build:iife --minify' 'build:cjs --minify' 'build:esm-module --minify' 'build:themes'", - "publish-release": "../../scripts/publish.sh" + "build": "npm-run-all --parallel 'build:esm --minify' 'build:iife --minify' 'build:cjs --minify' 'build:esm-module --minify' 'build:themes'" }, "dependencies": { "@mux/mux-video": "0.22.0", diff --git a/packages/mux-uploader-react/package.json b/packages/mux-uploader-react/package.json index ef78e0017..6aee78130 100644 --- a/packages/mux-uploader-react/package.json +++ b/packages/mux-uploader-react/package.json @@ -52,8 +52,7 @@ "build:esm": "esbuild src/index.tsx --target=es2019 --minify --bundle --sourcemap --metafile=./dist/esm.json --format=esm --loader:.css=text --outdir=dist --out-extension:.js=.mjs --external:react --external:prop-types", "build:types": "tsc", "postbuild:types": "downlevel-dts ./dist/types ./dist/types-ts3.4", - "build": "npm-run-all --parallel 'build:cjs --minify' 'build:esm --minify'", - "publish-release": "../../scripts/publish.sh" + "build": "npm-run-all --parallel 'build:cjs --minify' 'build:esm --minify'" }, "peerDependencies": { "@types/react": "^17.0.0 || ^17.0.0-0 || ^18 || ^18.0.0-0 || ^19 || ^19.0.0-0", diff --git a/packages/mux-uploader/package.json b/packages/mux-uploader/package.json index 704c4b221..f031df046 100644 --- a/packages/mux-uploader/package.json +++ b/packages/mux-uploader/package.json @@ -62,8 +62,7 @@ "copypolyfills": "shx mkdir -p src/polyfills && shx cp ../../shared/polyfills/index.ts ./src/polyfills/index.ts", "build:types": "tsc", "postbuild:types": "downlevel-dts ./dist/types ./dist/types-ts3.4", - "build": "npm-run-all --parallel 'build:esm --minify' 'build:iife --minify' 'build:cjs --minify' 'build:esm-module --minify'", - "publish-release": "../../scripts/publish.sh" + "build": "npm-run-all --parallel 'build:esm --minify' 'build:iife --minify' 'build:cjs --minify' 'build:esm-module --minify'" }, "dependencies": { "@mux/upchunk": "^3.4.0" diff --git a/packages/mux-video-react/package.json b/packages/mux-video-react/package.json index 39c17c5bb..3d50d7adf 100644 --- a/packages/mux-video-react/package.json +++ b/packages/mux-video-react/package.json @@ -51,8 +51,7 @@ "build:esm": "esbuild src/index.tsx --target=es2019 --bundle --sourcemap --metafile=./dist/esm.json --format=esm --outdir=dist --out-extension:.js=.mjs --external:react --external:prop-types --external:@mux/* --define:PLAYER_VERSION=\"'$npm_package_version'\"", "build:types": "tsc", "postbuild:types": "downlevel-dts ./dist/types ./dist/types-ts3.4", - "build": "npm-run-all --parallel 'build:cjs --minify' 'build:esm --minify'", - "publish-release": "../../scripts/publish.sh" + "build": "npm-run-all --parallel 'build:cjs --minify' 'build:esm --minify'" }, "peerDependencies": { "@types/react": "^17.0.0 || ^17.0.0-0 || ^18 || ^18.0.0-0 || ^19 || ^19.0.0-0", diff --git a/packages/mux-video/package.json b/packages/mux-video/package.json index 894ba1a3e..498f7e60d 100644 --- a/packages/mux-video/package.json +++ b/packages/mux-video/package.json @@ -61,8 +61,7 @@ "copypolyfills": "shx mkdir -p src/polyfills && shx cp ../../shared/polyfills/index.ts ./src/polyfills/index.ts", "build:types": "tsc", "postbuild:types": "downlevel-dts ./dist/types ./dist/types-ts3.4", - "build": "npm-run-all --parallel 'build:esm --minify' 'build:iife --minify' 'build:cjs --minify' 'build:esm-module --minify'", - "publish-release": "../../scripts/publish.sh" + "build": "npm-run-all --parallel 'build:esm --minify' 'build:iife --minify' 'build:cjs --minify' 'build:esm-module --minify'" }, "dependencies": { "@mux/playback-core": "0.27.0", diff --git a/packages/playback-core/package.json b/packages/playback-core/package.json index d7559d7d1..63b0fe08d 100644 --- a/packages/playback-core/package.json +++ b/packages/playback-core/package.json @@ -54,8 +54,7 @@ "prebuild:types": "shx mkdir -p ./dist/types", "build:types": "tsc", "postbuild:types": "downlevel-dts ./dist/types ./dist/types-ts3.4 --to=3.4", - "build": "npm-run-all --parallel 'build:esm --minify' 'build:iife --minify' 'build:cjs --minify' 'build:esm-module --minify'", - "publish-release": "../../scripts/publish.sh" + "build": "npm-run-all --parallel 'build:esm --minify' 'build:iife --minify' 'build:cjs --minify' 'build:esm-module --minify'" }, "dependencies": { "hls.js": "~1.5.11", diff --git a/scripts/publish.sh b/scripts/publish.sh deleted file mode 100755 index 2ebe07873..000000000 --- a/scripts/publish.sh +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/bin/env bash - -# npm publish with goodies -# inspired by https://gist.github.com/stevemao/280ef22ee861323993a0 -# -# release with optional argument `patch`/`minor`/`major`/`canary`/`` -# defaults to conventional-recommended-bump - -dry_run=false -canary_run=false -release_type= -PKG_NAME=$(cat package.json | jq -r '.name') - -function main { - processCommandLineArgs "$@" - if "$dry_run"; then - echo - echo "Running publish on $PKG_NAME in dry-run move. This will run things locally but never push to the remote" - echo - fi - if "$canary_run"; then - canary "$0" - else - release "$@" - fi -} - -function processCommandLineArgs { - for arg in "$@" - do - case $arg in - canary) - canary_run=true - ;; - --help|help) - echo "Commands:" - echo " $0 Publish a release from conventional commits." - echo " $0 canary Publish a canary." - echo " $0 patch Publish a patch release." - echo " $0 minor Publish a minor release." - echo " $0 major Publish a major release." - echo " $0 Publish a release with a specific version." - echo - echo " $0 --dry-run Run the release as a dry-run." - exit 0 - ;; - --dry-run|n) - dry_run=true - ;; - patch|minor|major) - release_type=$arg - ;; - *) - ;; - esac - done -} - -function release { - BUMP=$(npx -p conventional-changelog-angular -p conventional-recommended-bump -c 'conventional-recommended-bump -p angular') - # jq to get version from yarn https://jqplay.org/s/LqIS_qy2MBx - VERSION=$(yarn version --no-git-tag-version --new-version ${release_type:-$BUMP} --json | jq -r 'select(.data | startswith("New version")).data | split(": ")[1]') - - npx conventional-changelog-cli -p angular -i CHANGELOG.md -s - - if "$dry_run"; then - echo - echo "In non-dry-run, will run the following commands" - echo " git add CHANGELOG.md" - echo " git commit -m \"docs(CHANGELOG): $VERSION\"" - echo - else - git add CHANGELOG.md - git commit -m "docs(CHANGELOG): $VERSION" - fi - - if "$dry_run"; then - echo "Running the following command" "yarn version --force --allow-same-version --new-version $VERSION --message \"chore(release): %s\"" - echo "Running the same command with --no-git-tag-version" - echo - yarn version --force --allow-same-version --new-version $VERSION --message "chore(release): %s" --no-git-tag-version - else - yarn version --force --allow-same-version --new-version $VERSION --message "chore(release): %s" - fi - - if "$dry_run"; then - echo - echo "In non-dry-run, will run the following commands" - echo " git push --follow-tags" - echo " npx conventional-github-releaser -p angular" - echo - else - git push --follow-tags - npx conventional-github-releaser -p angular - fi - - echo "Beginning release $PKG_NAME@$VERSION" - if "$dry_run"; then - echo - echo "In non-dry-run, will run the following commands" - echo " yarn publish --access public --non-interactive" - echo - else - yarn publish --access public --non-interactive - fi - - # update all workspaces from the workspace root (../..) with the new version - # make sure publish.sh is called in topological order, `lerna ls --toposort` does this - DEPENDANT_PKGS=$(npx -y lerna@4.0.0 ls --graph --toposort --scope @mux/* | - jq -r "to_entries[] | select(.value[] | contains(\"$PKG_NAME\")) | .key") - scope="" - for name in ${DEPENDANT_PKGS}; do - scope+="--scope $name " - done - - if "$dry_run"; then - echo "Running the following command" npx -y lerna@4.0.0 exec $scope -- npm pkg set dependencies.$PKG_NAME=$VERSION > /dev/null - fi - npx -y lerna@4.0.0 exec $scope -- npm pkg set dependencies.$PKG_NAME=$VERSION > /dev/null - - echo "Ending release $PKG_NAME@$VERSION" -}; - -function canary { - PKG_VERSION=$(cat package.json | jq -r '.version') - - # get last published version from NPM without alpha / beta, remove -SHA hash - - # debug jq command at https://jqplay.org/s/Vnz8ioZ2vtm - # - # 1. remove alpha or beta versions - # 2 & 3. convert to { version: 'x.x.x', dist: 'canary', build: x } - # 4. sort first by `version` then by `build` number - # 5. put back together to a string `x.x.x-canary.x` - # 6. pick the last item in the array - - LAST_VERSION=$(npm view $PKG_NAME versions --json | - jq -r '. - map(select(contains("alpha") or contains("beta"))) - | map(capture("(?(?\\d+)\\.(?\\d+)\\.(?\\d+))(-(?[a-z]+))?(\\.(?\\d+))?")) - | map(.build? |= (. // 0 | tonumber)) - | map(.patch? |= (. // 0 | tonumber)) - | map(.minor? |= (. // 0 | tonumber)) - | map(.major? |= (. // 0 | tonumber)) - | sort_by(.major, .minor, .patch, .build) - | map(.version + "-" + (.dist // "latest") + "." + (.build|tostring)) - | last') - - # if json is empty GH actions made this a `null` string, replace it with a null value - LAST_VERSION=$(echo $LAST_VERSION | sed "s/null//g") - - # default to local package version if no last version was found on NPM - PRE_VERSION=$(npx semver ${LAST_VERSION:-$PKG_VERSION} -i prerelease --preid canary) - VERSION=$PRE_VERSION-$(git rev-parse --short HEAD) - - echo "Beginning release $PKG_NAME@$VERSION" - yarn version --no-git-tag-version --new-version $VERSION - if "$dry_run"; then - echo - echo "In non-dry-run, will run the following commands" - echo " yarn publish --tag canary --access public --non-interactive" - echo - else - yarn publish --tag canary --access public --non-interactive - fi - - # update all workspaces from the workspace root (../..) with the new version - # make sure publish.sh is called in topological order, `lerna ls --toposort` does this - DEPENDANT_PKGS=$(npx -y lerna@4.0.0 ls --graph --toposort --scope @mux/* | - jq -r "to_entries[] | select(.value[] | contains(\"$PKG_NAME\")) | .key") - scope="" - for name in ${DEPENDANT_PKGS}; do - scope+="--scope $name " - done - - if [ -n "$scope" ]; then - if "$dry_run"; then - echo "Running the following command" npx -y lerna@4.0.0 exec $scope -- npm pkg set dependencies.$PKG_NAME=$VERSION > /dev/null - fi - npx -y lerna@4.0.0 exec $scope -- npm pkg set dependencies.$PKG_NAME=$VERSION > /dev/null - fi - - echo "Ending release $PKG_NAME@$VERSION" -} - -main "$@"