Skip to content

Commit b1c89c9

Browse files
authored
Merge pull request #26 from ipfs/switch-to-kubo
feat: use kubo and allow customising ipfs add
2 parents b566e15 + b069fd5 commit b1c89c9

File tree

3 files changed

+43
-27
lines changed

3 files changed

+43
-27
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
## [1.3.0] - 2025-03-05
11+
12+
### Added
13+
14+
- Add `ipfs-add-options` input to allow for customizing the `ipfs add` command used to merkleize the build into a CAR file.
15+
16+
### Changed
17+
18+
- Remove dependency on `ipfs-car` npm package, and use kubo instead to create the CAR file, since we need Kubo for pinning anyways.
19+
1020
## [1.2.1] - 2025-03-03
1121

1222
### Fixed

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,21 @@ The signing key and proof will be used as [inputs](#inputs) to the action.
6868
6969
### Optional Inputs
7070

71-
| Input | Description | Default |
72-
| ------------------------- | ------------------------------------------------------- | -------------------------------- |
73-
| `node-version` | Node.js version to use | `'20'` |
74-
| `cluster-ctl-version` | IPFS Cluster CLI version to use | `'v1.1.2'` |
75-
| `kubo-version` | Kubo CLI version to use for pinning API and CAR uploads | `'v0.33.0'` |
76-
| `pinata-pinning-url` | Pinata Pinning Service URL | `'https://api.pinata.cloud/psa'` |
77-
| `pinata-jwt-token` | Pinata JWT token for authentication | - |
78-
| `filebase-bucket` | Filebase bucket name | - |
79-
| `filebase-access-key` | Filebase access key | - |
80-
| `filebase-secret-key` | Filebase secret key | - |
81-
| `set-github-status` | Set GitHub commit status and PR comments | `'true'` |
82-
| `upload-car-artifact` | Upload and publish the CAR file on GitHub Action Summary pages | `'true'` |
83-
| `cluster-retry-attempts` | Number of retry attempts for IPFS Cluster uploads | `'5'` |
84-
| `cluster-timeout-minutes` | Timeout in minutes for each IPFS Cluster upload attempt | `'2'` |
71+
| Input | Description | Default |
72+
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
73+
| `node-version` | Node.js version to use | `'20'` |
74+
| `cluster-ctl-version` | IPFS Cluster CLI version to use | `'v1.1.2'` |
75+
| `kubo-version` | Kubo CLI version to use for pinning API and CAR uploads | `'v0.33.0'` |
76+
| `ipfs-add-options` | Options to pass to `ipfs add` command that is used to merkleize the build. See [ipfs add docs](https://docs.ipfs.tech/reference/kubo/cli/#ipfs-add) | `'--cid-version 1 --chunker size-1048576'` |
77+
| `pinata-pinning-url` | Pinata Pinning Service URL | `'https://api.pinata.cloud/psa'` |
78+
| `pinata-jwt-token` | Pinata JWT token for authentication | - |
79+
| `filebase-bucket` | Filebase bucket name | - |
80+
| `filebase-access-key` | Filebase access key | - |
81+
| `filebase-secret-key` | Filebase secret key | - |
82+
| `set-github-status` | Set GitHub commit status and PR comments | `'true'` |
83+
| `upload-car-artifact` | Upload and publish the CAR file on GitHub Action Summary pages | `'true'` |
84+
| `cluster-retry-attempts` | Number of retry attempts for IPFS Cluster uploads | `'5'` |
85+
| `cluster-timeout-minutes` | Timeout in minutes for each IPFS Cluster upload attempt | `'2'` |
8586

8687
## Outputs
8788

action.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ branding:
66

77
inputs:
88
kubo-version:
9-
description: 'Kubo version to use for pinning https://dist.ipfs.tech/kubo/versions'
9+
description: 'Kubo version used to merkleize, create CAR file, and pin https://dist.ipfs.tech/kubo/versions'
1010
default: 'v0.33.0'
1111
required: false
1212
path-to-deploy:
1313
description: 'Path to the directory containing the frontend build to merkleize into a CAR file and deploy to IPFS'
1414
required: true
15+
ipfs-add-options:
16+
description: 'Options to pass to `ipfs add` command of Kubo See https://docs.ipfs.tech/reference/kubo/cli/#ipfs-add'
17+
default: '--cid-version 1 --chunker size-1048576'
18+
required: false
1519
kubo-api-url:
1620
description: 'Kubo RPC API URL to pass to `ipfs --api`, e.g. `/dns/YOUR_DOMAIN/tcp/443/https`'
1721
required: false
@@ -93,9 +97,17 @@ runs:
9397
exit 1
9498
fi
9599
96-
- name: Install ipfs-car
100+
- name: Setup Kubo CLI
101+
uses: ipfs/download-ipfs-distribution-action@v1
102+
with:
103+
name: kubo
104+
version: ${{ inputs.kubo-version }}
105+
106+
- name: ipfs init
97107
shell: bash
98-
run: npm install -g ipfs-car@2
108+
# ipfs init is required to use many of the ipfs commands
109+
run: |
110+
ipfs init
99111
100112
- name: Merkleize into CAR file
101113
id: merkleize
@@ -116,11 +128,12 @@ runs:
116128
fi
117129
118130
# Merkleize the directory into a CAR file
119-
CID=$(ipfs-car pack ${{ inputs.path-to-deploy }} --no-wrap --output build.car 2>&1 | tail -n 1)
131+
CID=$(ipfs add ${{ inputs.ipfs-add-options }} -Q -r ${{ inputs.path-to-deploy }})
132+
ipfs dag export $CID > build.car
120133
121134
# Verify that we got a valid CID
122135
if [ -z "$CID" ]; then
123-
echo "::error::Failed to extract CID from ipfs-car output"
136+
echo "::error::Failed to extract CID from ipfs add output"
124137
exit 1
125138
fi
126139
@@ -172,13 +185,6 @@ runs:
172185
echo "- [inbrowser.link](https://inbrowser.link/ipfs/${{ steps.merkleize.outputs.cid }})" >> $GITHUB_STEP_SUMMARY
173186
fi
174187
175-
- name: Setup Kubo CLI
176-
if: ${{ inputs.pinata-jwt-token != '' || inputs.kubo-api-url != ''}}
177-
uses: ipfs/download-ipfs-distribution-action@v1
178-
with:
179-
name: kubo
180-
version: ${{ inputs.kubo-version }}
181-
182188
- name: Upload CAR to Kubo
183189
if: ${{ inputs.kubo-api-url != '' && inputs.kubo-api-auth != ''}}
184190
shell: bash
@@ -266,7 +272,6 @@ runs:
266272
if: ${{ inputs.pinata-jwt-token != ''}}
267273
shell: bash
268274
run: |
269-
ipfs init
270275
ipfs pin remote service add pinata "${{ inputs.pinata-pinning-url }}" ${{ inputs.pinata-jwt-token }}
271276
ipfs pin remote add --service=pinata --background --name="build-${{ github.event.pull_request.head.sha || github.sha }}" ${{ steps.merkleize.outputs.cid }}
272277
echo "✅ Pinned CID \`${{ steps.merkleize.outputs.cid }}\` to Pinata" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)