diff --git a/.github/workflows/push-master.yml b/.github/workflows/push-master.yml index f4878709df..f7d981baa7 100644 --- a/.github/workflows/push-master.yml +++ b/.github/workflows/push-master.yml @@ -5,7 +5,7 @@ on: - master jobs: - release-www: + www: strategy: matrix: step: ['build:release:www'] @@ -19,6 +19,7 @@ jobs: - name: ${{ matrix.step }} env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }} GH_PAGES_SRC: packages/apps/build GH_PAT: ${{ secrets.GH_PAT }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} @@ -27,19 +28,18 @@ jobs: run: | yarn install --immutable | grep -v 'YN0013' yarn ${{ matrix.step }} - release-electron: + + electron: strategy: matrix: os: [macos-latest, ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} if: "! contains(github.event.head_commit.message, '[CI Skip]') && github.repository == 'polkadot-js/apps'" - name: ${{ matrix.step }} - + name: ${{ matrix.os }} steps: - uses: actions/checkout@v1 with: token: ${{ secrets.GH_PAT }} - - name: Build/release Electron app uses: samuelmeuli/action-electron-builder@v1 with: diff --git a/package.json b/package.json index 9df835f59f..b4d3e50775 100644 --- a/package.json +++ b/package.json @@ -88,6 +88,7 @@ "@types/styled-components": "^5.1.0", "@types/styled-theming": "^2.2.3", "concurrently": "^5.2.0", + "dnslink-cloudflare": "^2.0.4", "electron": "8.3.0", "electron-builder": "^22.6.1", "i18next-scanner": "^2.11.0", diff --git a/scripts/ipfsUpload.js b/scripts/ipfsUpload.js index 20d9930209..4fd1137b46 100644 --- a/scripts/ipfsUpload.js +++ b/scripts/ipfsUpload.js @@ -4,10 +4,12 @@ const fs = require('fs'); const pinataSDK = require('@pinata/sdk'); +const cloudflare = require('dnslink-cloudflare'); const execSync = require('@polkadot/dev/scripts/execSync'); // https://gateway.pinata.cloud/ipfs/ const GATEWAY = 'https://ipfs.io/ipfs/'; +const DOMAIN = 'dotapps.io'; const DST = 'packages/apps/build'; const SRC = 'packages/apps/public'; const WOPTS = { encoding: 'utf8', flag: 'w' }; @@ -52,7 +54,7 @@ async function pin () { writeFiles('index.html', html); writeFiles('pin.json', JSON.stringify(result)); - updateGh(result.IpfsHas); + updateGh(result.IpfsHash); console.log(`Pinned ${result.IpfsHash}`); @@ -74,7 +76,22 @@ async function unpin (exclude) { } } -pin() - .then(unpin) +async function dnslink (hash) { + await cloudflare.update( + { token: process.env.CF_API_TOKEN }, + { link: `/ipfs/${hash}`, record: `_dnslink.${DOMAIN}`, zone: DOMAIN } + ); + + console.log(`Dnslink ${hash}`); +} + +async function main () { + const hash = await pin(); + + await dnslink(hash); + await unpin(hash); +} + +main() .catch(console.error) .finally(() => process.exit()); diff --git a/yarn.lock b/yarn.lock index d030f43a3d..2b8fdf3c42 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5684,6 +5684,13 @@ __metadata: languageName: node linkType: hard +"autocreate@npm:^1.1.0": + version: 1.2.0 + resolution: "autocreate@npm:1.2.0" + checksum: 3/467780fb5dee2c8a2ab34ae93006b18a369394ae19f224e74be297d6491f6850d323c881d1a51cbeb72dbab655e404f924d44a37317e65a4e22abd94a4705e25 + languageName: node + linkType: hard + "autoprefixer@npm:^9.5.1, autoprefixer@npm:^9.7.6": version: 9.8.0 resolution: "autoprefixer@npm:9.8.0" @@ -6721,6 +6728,13 @@ __metadata: languageName: node linkType: hard +"capture-stack-trace@npm:^1.0.0": + version: 1.0.1 + resolution: "capture-stack-trace@npm:1.0.1" + checksum: 3/c857f977ca42626cf9187b753ae7e891c894689b917f7d83510c89cec58bdd2fbf77055987226efa862cf95c15ade4e02ccd463f53fdec49819170c0905d1071 + languageName: node + linkType: hard + "caseless@npm:~0.12.0": version: 0.12.0 resolution: "caseless@npm:0.12.0" @@ -7174,6 +7188,21 @@ __metadata: languageName: node linkType: hard +"cloudflare@npm:^2.7.0": + version: 2.7.0 + resolution: "cloudflare@npm:2.7.0" + dependencies: + autocreate: ^1.1.0 + es-class: ^2.1.1 + got: ^6.3.0 + https-proxy-agent: ^2.1.1 + object-assign: ^4.1.0 + should-proxy: ^1.0.4 + url-pattern: ^1.0.3 + checksum: 3/c2001239a70d653a4d0a794c13079b423a3bcdec6c2c51e06619a090409ecb0c550a42fa76d16db4af4d3d960d5d314c2da0fa66b09ac8d1cbf33bedbeb129f0 + languageName: node + linkType: hard + "co@npm:^4.6.0": version: 4.6.0 resolution: "co@npm:4.6.0" @@ -7851,6 +7880,15 @@ __metadata: languageName: node linkType: hard +"create-error-class@npm:^3.0.0": + version: 3.0.2 + resolution: "create-error-class@npm:3.0.2" + dependencies: + capture-stack-trace: ^1.0.0 + checksum: 3/cbd6512694a5bf8cd3f8742cb58cd4b85c67812316878d9515cbbc8f531b22b4fb14e074de6b564fc4951be4e7ce223ed4bf245865ac0cb09e1209d8e6cae0ec + languageName: node + linkType: hard + "create-hash@npm:^1.1.0, create-hash@npm:^1.1.2, create-hash@npm:^1.2.0": version: 1.2.0 resolution: "create-hash@npm:1.2.0" @@ -8898,6 +8936,18 @@ __metadata: languageName: node linkType: hard +"dnslink-cloudflare@npm:^2.0.4": + version: 2.0.4 + resolution: "dnslink-cloudflare@npm:2.0.4" + dependencies: + cloudflare: ^2.7.0 + yargs: ^15.0.1 + bin: + dnslink-cloudflare: ./bin/index.js + checksum: 3/279d1cdfedf146bc298ffcc2ce2556a8a1e91fcdf1bddd6f816d9799eea3ddd9c27731f33adc4da5c33678adade70bbacd67dd1be68271653e1e087499a2c3b6 + languageName: node + linkType: hard + "docsearch.js@npm:^2.5.2": version: 2.6.3 resolution: "docsearch.js@npm:2.6.3" @@ -9467,6 +9517,13 @@ __metadata: languageName: node linkType: hard +"es-class@npm:^2.1.1": + version: 2.1.1 + resolution: "es-class@npm:2.1.1" + checksum: 3/0640cff3541456f251330edaa508070ed6b7fd6a0e8788c20f538576285f75e6a602da82cefd65f1d5e3eccbcd62060d56b3090c9631ef15796732a40de12b5b + languageName: node + linkType: hard + "es-to-primitive@npm:^1.2.1": version: 1.2.1 resolution: "es-to-primitive@npm:1.2.1" @@ -11010,6 +11067,13 @@ __metadata: languageName: node linkType: hard +"get-stream@npm:^3.0.0": + version: 3.0.0 + resolution: "get-stream@npm:3.0.0" + checksum: 3/83ed722c1b43b3889f12cc4530d663b282a6fee915856d0c7122138d4864a3db54d252df2f9de032d1a2bb6b5a807083954992e583180b500013b2351fb5f440 + languageName: node + linkType: hard + "get-stream@npm:^4.0.0, get-stream@npm:^4.1.0": version: 4.1.0 resolution: "get-stream@npm:4.1.0" @@ -11431,6 +11495,25 @@ __metadata: languageName: node linkType: hard +"got@npm:^6.3.0": + version: 6.7.1 + resolution: "got@npm:6.7.1" + dependencies: + create-error-class: ^3.0.0 + duplexer3: ^0.1.4 + get-stream: ^3.0.0 + is-redirect: ^1.0.0 + is-retry-allowed: ^1.0.0 + is-stream: ^1.0.0 + lowercase-keys: ^1.0.0 + safe-buffer: ^5.0.1 + timed-out: ^4.0.0 + unzip-response: ^2.0.1 + url-parse-lax: ^1.0.0 + checksum: 3/bf19ee1cbb915bf67b93c13cd441023b209562f4fd2d965099d40c05746a8a550e09787d94558a5e6d7064e91e7a4529a2c919f7e8c4a482517a38e98930ef5e + languageName: node + linkType: hard + "got@npm:^9.6.0": version: 9.6.0 resolution: "got@npm:9.6.0" @@ -12094,7 +12177,7 @@ __metadata: languageName: node linkType: hard -"https-proxy-agent@npm:^2.2.3": +"https-proxy-agent@npm:^2.1.1, https-proxy-agent@npm:^2.2.3": version: 2.2.4 resolution: "https-proxy-agent@npm:2.2.4" dependencies: @@ -13093,6 +13176,13 @@ __metadata: languageName: node linkType: hard +"is-redirect@npm:^1.0.0": + version: 1.0.0 + resolution: "is-redirect@npm:1.0.0" + checksum: 3/24c2aef7dbc710f7ec4534c6ba617b62d938cfcdf366db319563ff32cf9d6a20047b0fd44dfb018f389e60d76ff96f4801ae39ddbde2ad124d2a51330760b605 + languageName: node + linkType: hard + "is-regex@npm:^1.0.4, is-regex@npm:^1.0.5": version: 1.0.5 resolution: "is-regex@npm:1.0.5" @@ -13139,6 +13229,13 @@ __metadata: languageName: node linkType: hard +"is-retry-allowed@npm:^1.0.0": + version: 1.2.0 + resolution: "is-retry-allowed@npm:1.2.0" + checksum: 3/739384d2662f38fe0edd1bcdf7f88551c6f1b1fdc7fde3ba86442cd675d337f14100d6479bcbb4635f7e38d11e1a2c2e173a52ba39547631960641d9fbe65531 + languageName: node + linkType: hard + "is-ssh@npm:^1.3.0": version: 1.3.1 resolution: "is-ssh@npm:1.3.1" @@ -13148,7 +13245,7 @@ __metadata: languageName: node linkType: hard -"is-stream@npm:^1.0.1, is-stream@npm:^1.1.0": +"is-stream@npm:^1.0.0, is-stream@npm:^1.0.1, is-stream@npm:^1.1.0": version: 1.1.0 resolution: "is-stream@npm:1.1.0" checksum: 3/39843ee9ff68ebda05237199f18831eb6e0e28db7799ee9ddaac5573b0681f18b4dc427afdb7b7ad906db545e4648999c42a1810b277acc8451593ff59da00fa @@ -17517,6 +17614,7 @@ __metadata: "@types/styled-components": ^5.1.0 "@types/styled-theming": ^2.2.3 concurrently: ^5.2.0 + dnslink-cloudflare: ^2.0.4 electron: 8.3.0 electron-builder: ^22.6.1 i18next-scanner: ^2.11.0 @@ -18147,7 +18245,7 @@ __metadata: languageName: node linkType: hard -"prepend-http@npm:^1.0.0": +"prepend-http@npm:^1.0.0, prepend-http@npm:^1.0.1": version: 1.0.4 resolution: "prepend-http@npm:1.0.4" checksum: 3/f723f34a23394b568a9ff0cd502bdda244b343c03b12a259343566eab1184cf41a6c7e9975d9e6010ccb2901b7c428d296e56a67a72d0a6ecb0f13531a3fa44e @@ -20257,6 +20355,13 @@ __metadata: languageName: node linkType: hard +"should-proxy@npm:^1.0.4": + version: 1.0.4 + resolution: "should-proxy@npm:1.0.4" + checksum: 3/4787b9960e1584d89964750d66e91513ebc4820150bf048dbf71b98427c82ecc745c1430720b0338ce7c0757b07dfead9c4314545c5ff6cb0cf037a190472aa2 + languageName: node + linkType: hard + "side-channel@npm:^1.0.2": version: 1.0.2 resolution: "side-channel@npm:1.0.2" @@ -21753,6 +21858,13 @@ __metadata: languageName: node linkType: hard +"timed-out@npm:^4.0.0": + version: 4.0.1 + resolution: "timed-out@npm:4.0.1" + checksum: 3/e3046640806b0aca3ce65214f026277280f31df9aa6ff407d7ebb3cc7706d404ae02a3e024b47c06443c89e54e3823ef76b2d67ac54a12d338591938011d51e0 + languageName: node + linkType: hard + "timers-browserify@npm:^2.0.4": version: 2.0.11 resolution: "timers-browserify@npm:2.0.11" @@ -22636,6 +22748,13 @@ __metadata: languageName: node linkType: hard +"unzip-response@npm:^2.0.1": + version: 2.0.1 + resolution: "unzip-response@npm:2.0.1" + checksum: 3/ba0ef3428f3d55c07bfac4ed27497b37cc782c2fa3b93030dce965499d029447f8d6e7a92b1246661abf484d5678c40e67a739eff7836e6e2e66db5f47b4f8c7 + languageName: node + linkType: hard + "upath@npm:^1.1.0, upath@npm:^1.1.1, upath@npm:^1.2.0": version: 1.2.0 resolution: "upath@npm:1.2.0" @@ -22719,6 +22838,15 @@ __metadata: languageName: node linkType: hard +"url-parse-lax@npm:^1.0.0": + version: 1.0.0 + resolution: "url-parse-lax@npm:1.0.0" + dependencies: + prepend-http: ^1.0.1 + checksum: 3/454fddd78658293a03b7e978c3aef8487e9e926c44d903f40de4bf4470148e6df2cb9aea6df62f44c51bd6fb148f2fe2096756a7778e1dcf78f7cc6badbfbfdd + languageName: node + linkType: hard + "url-parse-lax@npm:^3.0.0": version: 3.0.0 resolution: "url-parse-lax@npm:3.0.0" @@ -22738,6 +22866,13 @@ __metadata: languageName: node linkType: hard +"url-pattern@npm:^1.0.3": + version: 1.0.3 + resolution: "url-pattern@npm:1.0.3" + checksum: 3/55e1c22dbebfa67329e70159eda837b7c92df672ca4651931c1c9a205fde569b19656fbda35668eb2c0f0fab4c04f24af6850740092dc5d69eb897eeb439b000 + languageName: node + linkType: hard + "url@npm:^0.11.0": version: 0.11.0 resolution: "url@npm:0.11.0" @@ -24035,7 +24170,7 @@ __metadata: languageName: node linkType: hard -"yargs@npm:^15.3.1": +"yargs@npm:^15.0.1, yargs@npm:^15.3.1": version: 15.3.1 resolution: "yargs@npm:15.3.1" dependencies: