├── src ├── types.d.ts ├── post-install.js ├── go-platform.js ├── index.js └── download.js ├── bin └── ipfs ├── .github ├── actions │ ├── publish │ │ ├── action.yml │ │ ├── Dockerfile │ │ └── entrypoint.sh │ └── check-for-kubo-release │ │ ├── action.yml │ │ ├── Dockerfile │ │ └── entrypoint.sh ├── dependabot.yml ├── workflows │ ├── stale.yml │ ├── generated-pr.yml │ ├── test.yml │ └── main.yml └── ISSUE_TEMPLATE │ ├── config.yml │ └── open_an_issue.md ├── .travis.yml ├── test ├── fixtures │ ├── example-project │ │ └── package.json │ └── clean.js ├── path.js ├── install.js └── download.js ├── .gitignore ├── tsconfig.json ├── LICENSE ├── package.json └── README.md /src/types.d.ts: -------------------------------------------------------------------------------- 1 | export function path(): string -------------------------------------------------------------------------------- /bin/ipfs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | console.log('IPFS is not installed.') 4 | -------------------------------------------------------------------------------- /.github/actions/publish/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Publish release' 2 | runs: 3 | using: 'docker' 4 | image: 'Dockerfile' 5 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 'stable' 4 | sudo: false 5 | cache: 6 | directories: 7 | - node_modules 8 | script: 9 | - npm test 10 | -------------------------------------------------------------------------------- /.github/actions/check-for-kubo-release/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Check for kubo release' 2 | runs: 3 | using: 'docker' 4 | image: 'Dockerfile' 5 | outputs: 6 | publish: 7 | description: 'Whether to publish a new version' 8 | -------------------------------------------------------------------------------- /src/post-install.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { downloadAndUpdateBin } = require('./download') 4 | 5 | downloadAndUpdateBin() 6 | .catch(err => { 7 | console.error(err) 8 | process.exit(1) 9 | }) 10 | -------------------------------------------------------------------------------- /test/fixtures/example-project/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "author": "", 7 | "license": "ISC", 8 | "dependencies": { 9 | "kubo": "file://../../../" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Dependency directory 6 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 7 | node_modules 8 | dist 9 | 10 | # while testing npm5 11 | package-lock.json 12 | 13 | # Where the binaries go 14 | go-ipfs 15 | kubo 16 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: Close Stale Issues 2 | 3 | on: 4 | schedule: 5 | - cron: '0 0 * * *' 6 | workflow_dispatch: 7 | 8 | permissions: 9 | issues: write 10 | pull-requests: write 11 | 12 | jobs: 13 | stale: 14 | uses: ipdxco/unified-github-workflows/.github/workflows/reusable-stale-issue.yml@v1 15 | -------------------------------------------------------------------------------- /.github/workflows/generated-pr.yml: -------------------------------------------------------------------------------- 1 | name: Close Generated PRs 2 | 3 | on: 4 | schedule: 5 | - cron: '0 0 * * *' 6 | workflow_dispatch: 7 | 8 | permissions: 9 | issues: write 10 | pull-requests: write 11 | 12 | jobs: 13 | stale: 14 | uses: ipdxco/unified-github-workflows/.github/workflows/reusable-generated-pr.yml@v1 15 | -------------------------------------------------------------------------------- /test/fixtures/clean.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const fs = require('fs-extra') 4 | const path = require('path') 5 | const execa = require('execa') 6 | 7 | module.exports = async function clean () { 8 | await fs.remove(path.resolve(__dirname, '../../kubo')) 9 | await execa('git', ['checkout', '--', path.resolve(__dirname, '../../bin/ipfs')]) 10 | } 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Getting Help on IPFS 4 | url: https://ipfs.io/help 5 | about: All information about how and where to get help on IPFS. 6 | - name: IPFS Official Forum 7 | url: https://discuss.ipfs.io 8 | about: Please post general questions, support requests, and discussions here. 9 | -------------------------------------------------------------------------------- /.github/actions/publish/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:14 2 | 3 | LABEL "com.github.actions.name"="Version and publish" 4 | LABEL "com.github.actions.description"="npm version and publish with new kubo version" 5 | LABEL "com.github.actions.icon"="box" 6 | LABEL "com.github.actions.color"="green" 7 | 8 | COPY entrypoint.sh /entrypoint.sh 9 | ENTRYPOINT ["/entrypoint.sh"] 10 | -------------------------------------------------------------------------------- /.github/actions/check-for-kubo-release/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:14 2 | 3 | LABEL "com.github.actions.name"="Update and publish" 4 | LABEL "com.github.actions.description"="Publish new version when a new kubo version is relased" 5 | LABEL "com.github.actions.icon"="rss" 6 | LABEL "com.github.actions.color"="green" 7 | 8 | COPY entrypoint.sh /entrypoint.sh 9 | ENTRYPOINT ["/entrypoint.sh"] 10 | -------------------------------------------------------------------------------- /src/go-platform.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | function getGoOs () { 4 | switch (process.platform) { 5 | case 'sunos': 6 | return 'solaris' 7 | case 'win32': 8 | return 'windows' 9 | } 10 | 11 | return process.platform 12 | } 13 | 14 | function getGoArch () { 15 | switch (process.arch) { 16 | case 'ia32': 17 | return '386' 18 | case 'x64': 19 | return 'amd64' 20 | case 'arm': 21 | return 'arm' 22 | case 'arm64': 23 | return 'arm64' 24 | } 25 | 26 | return process.arch 27 | } 28 | 29 | module.exports = { 30 | GOOS: getGoOs(), 31 | GOARCH: getGoArch() 32 | } 33 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | 3 | on: 4 | push: 5 | branches: [ main, master ] 6 | pull_request: 7 | branches: [ main, master ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ${{ matrix.os }} 12 | strategy: 13 | matrix: 14 | os: [windows-latest, macos-latest, ubuntu-latest] 15 | node-version: [20.x] 16 | steps: 17 | - uses: actions/checkout@v4 18 | - uses: actions/setup-node@v4 19 | with: 20 | node-version: ${{ matrix.node-version }} 21 | - run: npm install 22 | - uses: gozala/typescript-error-reporter-action@v1.0.9 23 | - run: npm run build --if-present 24 | - run: npm test 25 | -------------------------------------------------------------------------------- /test/path.js: -------------------------------------------------------------------------------- 1 | var test = require('tape') 2 | var fs = require('fs') 3 | var path = require('path') 4 | var cp = require('child_process') 5 | var ipfs = path.join(__dirname, '..', 'bin', 'ipfs') 6 | 7 | if (process.platform === 'win32') { 8 | ipfs += '.exe' 9 | } 10 | 11 | test('ensure ipfs bin path exists', function (t) { 12 | t.plan(4) 13 | fs.stat(ipfs, function (err, stats) { 14 | t.error(err, 'ipfs bin should stat witout error') 15 | cp.exec([ipfs, 'version'].join(' '), function (err, stdout, stderr) { 16 | t.error(err, 'ipfs runs without error') 17 | t.true(stdout.indexOf('ipfs version') >= 0, 'ipfs version retreived') 18 | t.false(stderr, 'no stderr output') 19 | }) 20 | }) 21 | }) 22 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const fs = require('fs') 4 | const path = require('path') 5 | const { download } = require('./download') 6 | 7 | module.exports.download = download 8 | 9 | module.exports.path = function () { 10 | if (process.env.KUBO_BINARY) { 11 | return process.env.KUBO_BINARY 12 | } 13 | 14 | const paths = [ 15 | path.resolve(path.join(__dirname, '..', 'kubo', 'ipfs')), 16 | path.resolve(path.join(__dirname, '..', 'kubo', 'ipfs.exe')) 17 | ] 18 | 19 | for (const bin of paths) { 20 | if (fs.existsSync(bin)) { 21 | return bin 22 | } 23 | } 24 | 25 | throw new Error('kubo binary not found, it may not be installed or an error may have occurred during installation') 26 | } 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/open_an_issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Open an issue 3 | about: Only for actionable issues relevant to this repository. 4 | title: '' 5 | labels: need/triage 6 | assignees: '' 7 | 8 | --- 9 | 20 | -------------------------------------------------------------------------------- /.github/actions/check-for-kubo-release/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eu 3 | 4 | echo '💫 Checking https://dist.ipfs.tech/kubo/versions for new releases...' 5 | 6 | # The version in packge.json e.g. "0.4.20" 7 | CURRENT=`node -e 'console.log(require("./package.json").version)'` 8 | # The latest version on dist.ipfs.tech e.g. "0.4.21" 9 | LATEST=`curl --silent https://dist.ipfs.tech/kubo/versions | tail -n 1 | cut -c 2-` 10 | 11 | # Verify $LATEST is valid semver! 12 | if ! npx semver $LATEST; then 13 | echo "⚠️ Ignoring version $LATEST - Invalid SemVer string" 14 | exit 1 15 | fi 16 | 17 | if [[ "$CURRENT" != "$LATEST" ]]; then 18 | echo "🎉 New release exists $LATEST" 19 | 20 | echo "publish=true" >> $GITHUB_OUTPUT 21 | else 22 | echo "💤 $CURRENT is the latest release. Going back to sleep" 23 | 24 | echo "publish=false" >> $GITHUB_OUTPUT 25 | fi 26 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Release to npm 2 | on: 3 | workflow_dispatch: 4 | schedule: 5 | - cron: '0 * * * *' 6 | 7 | jobs: 8 | publish: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Checkout 12 | uses: actions/checkout@v4 13 | - name: Check for new kubo version 14 | id: check 15 | uses: ./.github/actions/check-for-kubo-release 16 | - name: Set up node 17 | if: steps.check.outputs.publish == 'true' 18 | uses: actions/setup-node@v4 19 | with: 20 | node-version: 20.x 21 | - name: Install 22 | if: steps.check.outputs.publish == 'true' 23 | run: npm install 24 | - name: Test 25 | if: steps.check.outputs.publish == 'true' 26 | run: npm test 27 | - name: Publish 28 | if: steps.check.outputs.publish == 'true' 29 | uses: ./.github/actions/publish 30 | env: 31 | NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} 32 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strict": true, 4 | // project options 5 | "allowJs": true, 6 | "checkJs": true, 7 | "target": "ES2019", 8 | "lib": [ 9 | "ES2019", 10 | "ES2020.Promise", 11 | "ES2020.String", 12 | "ES2020.BigInt", 13 | "DOM", 14 | "DOM.Iterable" 15 | ], 16 | "noEmitOnError": true, 17 | "incremental": true, 18 | "composite": true, 19 | "isolatedModules": true, 20 | "removeComments": false, 21 | // module resolution 22 | "esModuleInterop": true, 23 | "moduleResolution": "node", 24 | // linter checks 25 | "noImplicitReturns": false, 26 | "noFallthroughCasesInSwitch": true, 27 | "noUnusedLocals": true, 28 | "noUnusedParameters": false, 29 | // advanced 30 | "importsNotUsedAsValues": "error", 31 | "forceConsistentCasingInFileNames": true, 32 | "skipLibCheck": true, 33 | "stripInternal": true, 34 | "resolveJsonModule": true, 35 | "outDir": "dist" 36 | }, 37 | "include": [ 38 | "src", 39 | "package.json" 40 | ], 41 | "exclude": [ 42 | "node_modules" 43 | ] 44 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2018, Protocol Labs, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /test/install.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs-extra') 2 | const path = require('path') 3 | const test = require('tape') 4 | const execa = require('execa') 5 | const cachedir = require('cachedir') 6 | 7 | /* 8 | Test that correct kubo is downloaded during npm install. 9 | */ 10 | 11 | const expectedVersion = require('../package.json').version 12 | 13 | async function clean () { 14 | await fs.remove(path.join(__dirname, 'fixtures', 'example-project', 'node_modules')) 15 | await fs.remove(path.join(__dirname, 'fixtures', 'example-project', 'package-lock.json')) 16 | await fs.remove(cachedir('npm-kubo')) 17 | } 18 | 19 | test.onFinish(clean) 20 | 21 | test('Ensure kubo defined in package.json is fetched on dependency install', async (t) => { 22 | await clean() 23 | 24 | const exampleProjectRoot = path.join(__dirname, 'fixtures', 'example-project') 25 | 26 | // from `example-project`, install the module 27 | execa.sync('npm', ['install'], { 28 | cwd: exampleProjectRoot 29 | }) 30 | 31 | // confirm package.json is correct 32 | const fetchedVersion = require(path.join(exampleProjectRoot, 'node_modules', 'kubo', 'package.json')).version 33 | t.ok(expectedVersion === fetchedVersion, `package.json versions match '${expectedVersion}'`) 34 | 35 | // confirm binary is correct 36 | const binary = path.join(exampleProjectRoot, 'node_modules', 'kubo', 'bin', 'ipfs') 37 | const versionRes = execa.sync(binary, ['--version'], { 38 | cwd: exampleProjectRoot 39 | }) 40 | 41 | t.ok(versionRes.stdout === `ipfs version ${expectedVersion}`, `ipfs --version output match '${expectedVersion}'`) 42 | 43 | t.end() 44 | }) 45 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "kubo", 3 | "version": "0.39.0", 4 | "description": "Install the latest Kubo (go-ipfs) binary", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "postinstall": "node src/post-install.js", 8 | "restore-bin": "git reset -- bin/ipfs && git checkout -- bin/ipfs", 9 | "test": "tape test/*.js | tap-spec", 10 | "lint": "tsc --noEmit && standard", 11 | "prepublishOnly": "tsc" 12 | }, 13 | "pre-commit": "restore-bin", 14 | "bin": { 15 | "ipfs": "bin/ipfs" 16 | }, 17 | "files": [ 18 | "bin", 19 | "dist", 20 | "src", 21 | "test", 22 | "LICENSE", 23 | "package.json", 24 | "README.md", 25 | "tsconfig.json" 26 | ], 27 | "repository": { 28 | "type": "git", 29 | "url": "git+https://github.com/ipfs/npm-kubo.git" 30 | }, 31 | "keywords": [ 32 | "ipfs", 33 | "install" 34 | ], 35 | "author": "Protocol Labs, Inc.", 36 | "license": "MIT", 37 | "bugs": { 38 | "url": "https://github.com/ipfs/npm-kubo/issues" 39 | }, 40 | "homepage": "https://github.com/ipfs/npm-kubo", 41 | "types": "./src/types.d.ts", 42 | "devDependencies": { 43 | "@types/got": "^9.6.12", 44 | "@types/gunzip-maybe": "^1.4.0", 45 | "@types/tar-fs": "^2.0.1", 46 | "@types/unzip-stream": "^0.3.1", 47 | "execa": "^4.0.1", 48 | "fs-extra": "^9.0.0", 49 | "pre-commit": "^1.2.2", 50 | "standard": "^13.1.0", 51 | "tap-spec": "^5.0.0", 52 | "tape": "^4.13.2", 53 | "tape-promise": "^4.0.0", 54 | "typescript": "^4.3.5" 55 | }, 56 | "dependencies": { 57 | "cachedir": "^2.3.0", 58 | "got": "^11.7.0", 59 | "gunzip-maybe": "^1.4.2", 60 | "hasha": "^5.2.2", 61 | "pkg-conf": "^3.1.0", 62 | "tar-fs": "^2.1.0", 63 | "unzip-stream": "^0.3.0" 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /test/download.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const test = require('tape-promise').default(require('tape')) 4 | const fs = require('fs-extra') 5 | const os = require('os') 6 | const path = require('path') 7 | const { download, downloadAndUpdateBin } = require('../src/download') 8 | const { path: detectLocation } = require('../') 9 | const clean = require('./fixtures/clean') 10 | 11 | test('Ensure ipfs gets downloaded (current version and platform)', async (t) => { 12 | await clean() 13 | 14 | const installPath = await downloadAndUpdateBin() 15 | const stats = await fs.stat(installPath) 16 | 17 | t.ok(stats, 'kubo was downloaded') 18 | t.ok(installPath, detectLocation(), 'kubo binary was detected') 19 | 20 | t.end() 21 | }) 22 | 23 | test('Returns an error when version unsupported', async (t) => { 24 | await clean() 25 | 26 | await t.rejects(downloadAndUpdateBin('bogusversion', 'linux'), /Error: Version 'bogusversion' not available/) 27 | 28 | t.end() 29 | }) 30 | 31 | test('Returns an error when KUBO_DIST_URL is 404', async (t) => { 32 | await clean() 33 | 34 | process.env.KUBO_DIST_URL = 'https://dist.ipfs.tech/notfound' 35 | 36 | await t.rejects(downloadAndUpdateBin(), /404/) 37 | 38 | delete process.env.KUBO_DIST_URL 39 | 40 | t.end() 41 | }) 42 | 43 | test('Returns an error when legacy GO_IPFS_DIST_URL is 404', async (t) => { 44 | await clean() 45 | 46 | process.env.GO_IPFS_DIST_URL = 'https://dist.ipfs.tech/notfound' 47 | 48 | await t.rejects(downloadAndUpdateBin(), /404/) 49 | 50 | delete process.env.GO_IPFS_DIST_URL 51 | 52 | t.end() 53 | }) 54 | 55 | test('Path returns undefined when no binary has been downloaded', async (t) => { 56 | await clean() 57 | 58 | t.throws(detectLocation, /not found/, 'Path throws if binary is not installed') 59 | 60 | t.end() 61 | }) 62 | 63 | test('Ensure calling download function manually with static values works', async (t) => { 64 | await clean() 65 | 66 | const { version } = require('../package.json') 67 | const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'temp-dir-')) 68 | 69 | console.log(tempDir) 70 | const kuboPath = await download({ 71 | version: `v${version}`, 72 | platform: 'darwin', 73 | arch: 'arm64', 74 | distUrl: 'https://dist.ipfs.tech', 75 | installPath: tempDir 76 | }) 77 | console.log(kuboPath) 78 | const stats = await fs.stat(kuboPath) 79 | 80 | t.ok(stats, 'kubo was downloaded to installPath') 81 | 82 | t.end() 83 | }) 84 | -------------------------------------------------------------------------------- /.github/actions/publish/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eu 3 | 4 | # Set up npm home, so `npm publish` works. 5 | # https://github.com/actions/npm/blob/59b64a598378f31e49cb76f27d6f3312b582f680/entrypoint.sh 6 | if [ -n "$NPM_AUTH_TOKEN" ]; then 7 | # Respect NPM_CONFIG_USERCONFIG if it is provided, default to $HOME/.npmrc 8 | NPM_CONFIG_USERCONFIG="${NPM_CONFIG_USERCONFIG-"$HOME/.npmrc"}" 9 | NPM_REGISTRY_URL="${NPM_REGISTRY_URL-registry.npmjs.org}" 10 | NPM_STRICT_SSL="${NPM_STRICT_SSL-true}" 11 | NPM_REGISTRY_SCHEME="https" 12 | if ! $NPM_STRICT_SSL 13 | then 14 | NPM_REGISTRY_SCHEME="http" 15 | fi 16 | 17 | # Allow registry.npmjs.org to be overridden with an environment variable 18 | printf "//%s/:_authToken=%s\\nregistry=%s\\nstrict-ssl=%s" "$NPM_REGISTRY_URL" "$NPM_AUTH_TOKEN" "${NPM_REGISTRY_SCHEME}://$NPM_REGISTRY_URL" "${NPM_STRICT_SSL}" > "$NPM_CONFIG_USERCONFIG" 19 | 20 | chmod 0600 "$NPM_CONFIG_USERCONFIG" 21 | fi 22 | 23 | # The version in packge.json e.g. "0.4.20" 24 | CURRENT=`node -e 'console.log(require("./package.json").version)'` 25 | # The latest version on dist.ipfs.tech e.g. "0.4.21" 26 | LATEST=`curl --silent https://dist.ipfs.tech/kubo/versions | tail -n 1 | cut -c 2-` 27 | 28 | # Verify $LATEST is valid semver! 29 | if ! npx semver $LATEST; then 30 | echo "⚠️ Ignoring version $LATEST - Invalid SemVer string" 31 | exit 1 32 | fi 33 | 34 | if [[ "$CURRENT" != "$LATEST" ]]; then 35 | 36 | # If the version contains a dash it's a pre-release, e.g "0.4.21-rc3" 37 | # Publish pre-releases under the @next tag and releases @latest tag. 38 | if [[ $LATEST =~ "-" ]]; then 39 | NPM_DIST_TAG='next' 40 | echo "🧪 Found new kubo pre-release $LATEST@$NPM_DIST_TAG" 41 | else 42 | NPM_DIST_TAG='latest' 43 | echo "🎉 Found new kubo release $LATEST@$NPM_DIST_TAG" 44 | fi 45 | 46 | git config --global --add safe.directory /github/workspace 47 | 48 | # The workspace starts as a detached commit for scheduled builds... 49 | git rev-parse --abbrev-ref HEAD 50 | git checkout master 51 | 52 | # post-install rewrites bin/ipfs so undo that change 53 | git checkout -- bin/ipfs 54 | 55 | # Set sensible commit info 56 | git config --global user.name "${GITHUB_ACTOR}" 57 | git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" 58 | 59 | 60 | npm install 61 | npm version $LATEST 62 | npm publish --access public --tag $NPM_DIST_TAG 63 | echo "📦 Published $LATEST to npm as kubo@$NPM_DIST_TAG" 64 | 65 | git push -u origin master 66 | git push --tags 67 | echo "👍 Pushed changes back to master" 68 | 69 | else 70 | echo "💤 $CURRENT is the latest release. Going back to sleep" 71 | # neutral github action exit... not good, not bad. 72 | # https://developer.github.com/actions/creating-github-actions/accessing-the-runtime-environment/#exit-codes-and-statuses 73 | exit 78 74 | fi 75 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
4 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |