Skip to content

Commit

Permalink
fix npm package (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyNikiforov authored Jun 15, 2023
1 parent 215c32f commit d49ae34
Show file tree
Hide file tree
Showing 21 changed files with 173 additions and 56 deletions.
26 changes: 6 additions & 20 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,17 @@ jobs:

- name: Build Release Executables (Windows)
run: |
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloudpd.py icloud.py --name icloudpd-${{needs.get_version.outputs.icloudpd_version}}-windows-amd64
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloud.py --name icloud-${{needs.get_version.outputs.icloudpd_version}}-windows-amd64
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile exec.py --name icloudpd-ex-${{needs.get_version.outputs.icloudpd_version}}-windows-amd64
scripts/build_bin_windows ${{needs.get_version.outputs.icloudpd_version}} amd64
if: ${{ matrix.os == 'windows-latest' }}

- name: Build Release Executables (Linux)
run: |
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloudpd.py icloud.py --name icloudpd-${{needs.get_version.outputs.icloudpd_version}}-linux-amd64
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloud.py --name icloud-${{needs.get_version.outputs.icloudpd_version}}-linux-amd64
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile exec.py --name icloudpd-ex-${{needs.get_version.outputs.icloudpd_version}}-linux-amd64
scripts/build_bin_linux ${{needs.get_version.outputs.icloudpd_version}} amd64
if: ${{ matrix.os == 'ubuntu-latest' }}

- name: Build Release Executables (MacOS)
run: |
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloudpd.py icloud.py --name icloudpd-${{needs.get_version.outputs.icloudpd_version}}-macos-amd64
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile exec.py --name icloudpd-ex-${{needs.get_version.outputs.icloudpd_version}}-macos-amd64
scripts/build_bin_macos ${{needs.get_version.outputs.icloudpd_version}} amd64
if: ${{ matrix.os == 'macos-latest' }}

- name: Upload artifacts
Expand Down Expand Up @@ -184,25 +179,16 @@ jobs:
path: |
dist
- name: Make Package
- name: Build Package
run: |
cp -r npm dist/npm
cp LICENSE.md dist/npm/icloudpd
mkdir dist/npm/@icloudpd/win32-x64/bin
mv dist/icloudpd-${{needs.get_version.outputs.icloudpd_version}}-windows-amd64.exe dist/npm/@icloudpd/win32-x64/bin/icloudpd.exe
cp LICENSE.md dist/npm/@icloudpd/win32-x64/
mkdir dist/npm/@icloudpd/linux-x64/bin
mv dist/icloudpd-${{needs.get_version.outputs.icloudpd_version}}-linux-amd64 dist/npm/@icloudpd/linux-x64/bin/icloudpd
cp LICENSE.md dist/npm/@icloudpd/linux-x64/
mkdir dist/npm/@icloudpd/darwin-x64/bin
mv dist/icloudpd-${{needs.get_version.outputs.icloudpd_version}}-macos-amd64 dist/npm/@icloudpd/darwin-x64/bin/icloudpd
cp LICENSE.md dist/npm/@icloudpd/darwin-x64/
scripts/build_npm ${{needs.get_version.outputs.icloudpd_version}}
- name: Publish NPM
run: |
npm publish dist/npm/@icloudpd/linux-x64 --access public
npm publish dist/npm/@icloudpd/win32-x64 --access public
npm publish dist/npm/@icloudpd/darwin-x64 --access public
npm publish dist/npm/@icloudpd/darwin-arm64 --access public
npm publish dist/npm/icloudpd --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
26 changes: 6 additions & 20 deletions .github/workflows/quality-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,17 @@ jobs:

- name: Build Release Executables (Windows)
run: |
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloudpd.py icloud.py --name icloudpd-${{needs.get_version.outputs.icloudpd_version}}-windows-amd64
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloud.py --name icloud-${{needs.get_version.outputs.icloudpd_version}}-windows-amd64
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile exec.py --name icloudpd-ex-${{needs.get_version.outputs.icloudpd_version}}-windows-amd64
scripts/build_bin_windows ${{needs.get_version.outputs.icloudpd_version}} amd64
if: ${{ matrix.os == 'windows-latest' }}

- name: Build Release Executables (Linux)
run: |
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloudpd.py icloud.py --name icloudpd-${{needs.get_version.outputs.icloudpd_version}}-linux-amd64
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloud.py --name icloud-${{needs.get_version.outputs.icloudpd_version}}-linux-amd64
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile exec.py --name icloudpd-ex-${{needs.get_version.outputs.icloudpd_version}}-linux-amd64
scripts/build_bin_linux ${{needs.get_version.outputs.icloudpd_version}} amd64
if: ${{ matrix.os == 'ubuntu-latest' }}

- name: Build Release Executables (MacOS)
run: |
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloudpd.py icloud.py --name icloudpd-${{needs.get_version.outputs.icloudpd_version}}-macos-amd64
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile exec.py --name icloudpd-ex-${{needs.get_version.outputs.icloudpd_version}}-macos-amd64
scripts/build_bin_macos ${{needs.get_version.outputs.icloudpd_version}} amd64
if: ${{ matrix.os == 'macos-latest' }}

- name: Upload artifacts
Expand Down Expand Up @@ -165,25 +160,16 @@ jobs:
path: |
dist
- name: Make Package
- name: Build Package
run: |
cp -r npm dist/npm
cp LICENSE.md dist/npm/icloudpd
mkdir dist/npm/@icloudpd/win32-x64/bin
mv dist/icloudpd-${{needs.get_version.outputs.icloudpd_version}}-windows-amd64.exe dist/npm/@icloudpd/win32-x64/bin/icloudpd.exe
cp LICENSE.md dist/npm/@icloudpd/win32-x64/
mkdir dist/npm/@icloudpd/linux-x64/bin
mv dist/icloudpd-${{needs.get_version.outputs.icloudpd_version}}-linux-amd64 dist/npm/@icloudpd/linux-x64/bin/icloudpd
cp LICENSE.md dist/npm/@icloudpd/linux-x64/
mkdir dist/npm/@icloudpd/darwin-x64/bin
mv dist/icloudpd-${{needs.get_version.outputs.icloudpd_version}}-macos-amd64 dist/npm/@icloudpd/darwin-x64/bin/icloudpd
cp LICENSE.md dist/npm/@icloudpd/darwin-x64/
scripts/build_npm ${{needs.get_version.outputs.icloudpd_version}}
- name: Publish NPM (Dry-run)
run: |
npm publish dist/npm/@icloudpd/linux-x64 --access public --dry-run=true
npm publish dist/npm/@icloudpd/win32-x64 --access public --dry-run=true
npm publish dist/npm/@icloudpd/darwin-x64 --access public --dry-run=true
npm publish dist/npm/@icloudpd/darwin-arm64 --access public --dry-run=true
npm publish dist/npm/icloudpd --access public --dry-run=true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

## Unreleased

## 1.13.3 (2023-06-11)
## 1.13.4 (2023-06-14)

- experimental: fix npm packaging

## 1.13.4 (2023-06-11)

- experimental: fix npm registry publishing

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ When testing a bugfix it is important to test the faulty behavior and also the e
## How to release

We have github actions taking care for building, testing, and releasing software. Building and testing are happenning automatically on git pushed, pull requests, and merges. For releases the following steps are manual:
- Bump version in setup.py, all .md files, and all package.json files in npm subfolder
- Bump version in setup.py, abd all .md files
- Update CHANGELOG.md with date of the release
- Update CHANGELOG.md with release changes if they were not added with commits
- Commit & push/merge changes
Expand Down
4 changes: 2 additions & 2 deletions README_NPM.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ A command-line tool to download all your iCloud photos.
## [EXPERIMENTAL] Install, Run, and Use

``` sh
npx icloudpd --directory /data --username [email protected] --watch-with-interval 3600
npx --yes icloudpd --directory /data --username [email protected] --watch-with-interval 3600
```

Synchronization logic can be adjusted with command-line parameters. Run the following to get full list:

``` sh
npx icloudpd --help
npx --yes icloudpd --help
```

## Getting Node and Npm
Expand Down
1 change: 1 addition & 0 deletions jq/version.jq
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.version |= $version | (.optionalDependencies |= with_entries(.value |= $version))? // .
3 changes: 3 additions & 0 deletions npm/@icloudpd/darwin-arm64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# icloudpd

The macOS ARM 64-bit binary for icloudpd, a iCloud Photo Downloader. See https://github.com/icloud_photo_downloader/icloud_photo_downloader for details.
17 changes: 17 additions & 0 deletions npm/@icloudpd/darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@icloudpd/darwin-arm64",
"version": "0.0.1",
"description": "The macOS ARM 64-bit binary for icloudpd, a iCloud Photo Downloader.",
"repository": "https://github.com/icloud_photo_downloader/icloud_photo_downloader",
"license": "MIT",
"engines": {
"node": ">=12"
},
"preferUnplugged": true,
"os": [
"darwin"
],
"cpu": [
"arm64"
]
}
2 changes: 1 addition & 1 deletion npm/@icloudpd/darwin-x64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@icloudpd/darwin-x64",
"version": "1.13.3",
"version": "0.0.1",
"description": "The macOS 64-bit binary for icloudpd, a iCloud Photo Downloader.",
"repository": "https://github.com/icloud_photo_downloader/icloud_photo_downloader",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion npm/@icloudpd/linux-x64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@icloudpd/linux-x64",
"version": "1.13.3",
"version": "0.0.1",
"description": "The Linux 64-bit binary for icloudpd, a iCloud Photo Downloader.",
"repository": "https://github.com/icloud_photo_downloader/icloud_photo_downloader",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion npm/@icloudpd/win32-x64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@icloudpd/win32-x64",
"version": "1.13.3",
"version": "0.0.1",
"description": "The Windows 64-bit binary for icloudpd, a iCloud Photo Downloader.",
"repository": "https://github.com/icloud_photo_downloader/icloud_photo_downloader",
"license": "MIT",
Expand Down
3 changes: 0 additions & 3 deletions npm/icloudpd/README.md

This file was deleted.

6 changes: 5 additions & 1 deletion npm/icloudpd/bin/icloudpd.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ var knownPlatforms = {
"pkgName": "@icloudpd/darwin-x64",
"subPath": "bin/icloudpd"
},
"darwin arm64 LE": {
"pkgName": "@icloudpd/darwin-arm64",
"subPath": "bin/icloudpd"
},
"win32 x64 LE": {
"pkgName": "@icloudpd/win32-x64",
"subPath": "bin/icloudpd.exe"
Expand All @@ -21,5 +25,5 @@ if (platformKey in knownPlatforms) {
var binPath = require.resolve(`${pkgName}/${subPath}`);
require("child_process").execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" });
} else {
throw new Error(`Unsupported platform: ${platformKey}`);
throw new Error(`Unsupported platform: '${platformKey}'`);
}
9 changes: 5 additions & 4 deletions npm/icloudpd/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "icloudpd",
"version": "1.13.3",
"version": "0.0.1",
"description": "iCloud Photo Downloader",
"engines": {
"node": ">=12"
Expand All @@ -23,8 +23,9 @@
},
"homepage": "https://github.com/icloud_photos_downloader/icloud_photos_downloader#readme",
"optionalDependencies": {
"@icloudpd/linux-x64": "1.13.3",
"@icloudpd/win32-x64": "1.13.3",
"@icloudpd/darwin-x64": "1.13.3"
"@icloudpd/linux-x64": "0.0.1",
"@icloudpd/win32-x64": "0.0.1",
"@icloudpd/darwin-x64": "0.0.1",
"@icloudpd/darwin-arm64": "0.0.1"
}
}
10 changes: 10 additions & 0 deletions scripts/build_bin_linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -euo pipefail

# prepare npm packages in dist
# expects dist to have comipled binary versions
# required param: version

pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloudpd.py icloud.py --name icloudpd-$1-linux-$2
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloud.py --name icloud-$1-linux-$2
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile exec.py --name icloudpd-ex-$1-linux-$2
9 changes: 9 additions & 0 deletions scripts/build_bin_macos
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -euo pipefail

# prepare npm packages in dist
# expects dist to have comipled binary versions
# required param: version

pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloudpd.py icloud.py --name icloudpd-$1-macos-$2
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile exec.py --name icloudpd-ex-$1-macos-$2
10 changes: 10 additions & 0 deletions scripts/build_bin_windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -euo pipefail

# prepare bin packages in dist
# expects python with installed dependencies
# required param: version

pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloudpd.py icloud.py --name icloudpd-$1-windows-$2
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloud.py --name icloud-$1-windows-$2
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile exec.py --name icloudpd-ex-$1-windows-$2
46 changes: 46 additions & 0 deletions scripts/build_npm
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
set -euo pipefail

# prepare npm packages in dist
# expects dist to have comipled binary versions
# required param: version

# clean start
rm -rf dist/npm

# basic
cp -r npm dist/npm

# main package
cp LICENSE.md dist/npm/icloudpd
cp README_NPM.md dist/npm/icloudpd/README.md
jq --arg version $1 --from-file jq/version.jq < npm/icloudpd/package.json > dist/npm/icloudpd/package.json

# win32-x64
mkdir -p dist/npm/@icloudpd/win32-x64/bin
cp dist/icloudpd-$1-windows-amd64.exe dist/npm/@icloudpd/win32-x64/bin/icloudpd.exe
chmod +x dist/npm/@icloudpd/win32-x64/bin/icloudpd.exe
cp LICENSE.md dist/npm/@icloudpd/win32-x64/
jq --arg version $1 --from-file jq/version.jq < "npm/@icloudpd/win32-x64/package.json" > "dist/npm/@icloudpd/win32-x64/package.json"

# linux-x64
mkdir -p dist/npm/@icloudpd/linux-x64/bin
cp dist/icloudpd-$1-linux-amd64 dist/npm/@icloudpd/linux-x64/bin/icloudpd
chmod +x dist/npm/@icloudpd/linux-x64/bin/icloudpd
cp LICENSE.md dist/npm/@icloudpd/linux-x64/
jq --arg version $1 --from-file jq/version.jq < npm/@icloudpd/linux-x64/package.json > dist/npm/@icloudpd/linux-x64/package.json

# macos x64
mkdir -p dist/npm/@icloudpd/darwin-x64/bin
cp dist/icloudpd-$1-macos-amd64 dist/npm/@icloudpd/darwin-x64/bin/icloudpd
chmod +x dist/npm/@icloudpd/darwin-x64/bin/icloudpd
cp LICENSE.md dist/npm/@icloudpd/darwin-x64/
jq --arg version $1 --from-file jq/version.jq < npm/@icloudpd/darwin-x64/package.json > dist/npm/@icloudpd/darwin-x64/package.json

# macos arm64
mkdir -p dist/npm/@icloudpd/darwin-arm64/bin
# using Intel binary for now
cp dist/icloudpd-$1-macos-amd64 dist/npm/@icloudpd/darwin-arm64/bin/icloudpd
chmod +x dist/npm/@icloudpd/darwin-arm64/bin/icloudpd
cp LICENSE.md dist/npm/@icloudpd/darwin-arm64/
jq --arg version $1 --from-file jq/version.jq < npm/@icloudpd/darwin-arm64/package.json > dist/npm/@icloudpd/darwin-arm64/package.json
30 changes: 30 additions & 0 deletions scripts/publish_npm
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
set -euo pipefail

# dev script
# expecting dist/npm to be set
# required param registry_url
#
# prereq
# npm --registry registry_url adduser
#

# note verdaccio did not work properly when supplying npm folder with @, so we are changing dir...

cd dist/npm/@icloudpd/linux-x64
npm --registry $1 publish .
cd ../../../..

cd dist/npm/@icloudpd/win32-x64
npm --registry $1 publish .
cd ../../../..

cd dist/npm/@icloudpd/darwin-x64
npm --registry $1 publish .
cd ../../../..

cd dist/npm/@icloudpd/darwin-arm64
npm --registry $1 publish .
cd ../../../..

npm --registry $1 publish dist/npm/icloudpd
13 changes: 13 additions & 0 deletions scripts/unpublish_npm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -euo pipefail

# dev script
# required param: registry_url
#
# note that verdaccio v5 is flaky around unpublishing and restart may be required to clean things
#
npm --registry $1 unpublish -f icloudpd
npm --registry $1 unpublish -f @icloudpd/linux-x64
npm --registry $1 unpublish -f @icloudpd/win32-x64
npm --registry $1 unpublish -f @icloudpd/darwin-x64
npm --registry $1 unpublish -f @icloudpd/darwin-arm64
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name="icloudpd",
version="1.13.3",
version="1.13.4",
url="https://github.com/icloud-photos-downloader/icloud_photos_downloader",
description=(
"icloudpd is a command-line tool to download photos and videos from iCloud."
Expand Down

0 comments on commit d49ae34

Please sign in to comment.