Publish flipper-server to NPM (#3224)

Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/3224

Automatically publish to https://www.npmjs.com/package/flipper-server

Changelog: [experimental] It is now possible to run a full fledged Flipper as node + browser appication by using `npx flipper-server`

Pull Request resolved: https://github.com/facebook/flipper/pull/3224

Test Plan:
https://github.com/facebook/flipper/runs/4659854128?check_suite_focus=true

Checked that the build is non-fb, has no fb plugins etc, and runs from npm

{F690008124}

{F690008123}

{F690008122}

Reviewed By: nikoant

Differential Revision: D33297125

Pulled By: mweststrate

fbshipit-source-id: b5fe6fcb81c665036273db814cb61855aaceff85
This commit is contained in:
Michel Weststrate
2022-01-04 04:11:47 -08:00
committed by Facebook GitHub Bot
parent 25e585b819
commit 582ea64011
2 changed files with 45 additions and 1 deletions

View File

@@ -149,11 +149,40 @@ jobs:
with: with:
filename: .github/action-failure-template.md filename: .github/action-failure-template.md
build-flipper-server:
needs:
- release
runs-on: ubuntu-latest
env:
desktop-directory: ./desktop
steps:
- uses: actions/checkout@v2
with:
ref: ${{ needs.release.outputs.tag }}
- uses: actions/setup-node@v1
with:
node-version: '14.x'
- name: Install
uses: nick-invision/retry@v2.0.0
with:
timeout_minutes: 10
max_attempts: 3
command: cd ${{env.desktop-directory}} && yarn
- name: Build
run: cd ${{env.desktop-directory}} && yarn build:flipper-server
- name: Upload flipper-server
uses: actions/upload-artifact@v1
with:
name: 'flipper-server.tgz'
path: 'dist/flipper-server.zip'
publish: publish:
needs: needs:
- build-win - build-win
- build-linux - build-linux
- build-mac - build-mac
- build-flipper-server
- release - release
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -176,6 +205,12 @@ jobs:
with: with:
name: 'Flipper-win.zip' name: 'Flipper-win.zip'
path: 'Flipper-win.zip' path: 'Flipper-win.zip'
- name: Download Flipper Server
if: ${{ needs.release.outputs.tag != '' }}
uses: actions/download-artifact@v1
with:
name: 'flipper-server.tgz'
path: 'flipper-server.tgz'
- name: GitHub Upload Release Artifacts - name: GitHub Upload Release Artifacts
if: ${{ needs.release.outputs.tag != '' }} if: ${{ needs.release.outputs.tag != '' }}
uses: passy/github-upload-release-artifacts-action@v2.2.2 uses: passy/github-upload-release-artifacts-action@v2.2.2
@@ -183,7 +218,14 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
created_tag: ${{ needs.release.outputs.tag }} created_tag: ${{ needs.release.outputs.tag }}
args: Flipper-mac.dmg/Flipper-mac.dmg Flipper-linux.zip/Flipper-linux.zip Flipper-win.zip/Flipper-win.zip args: Flipper-mac.dmg/Flipper-mac.dmg Flipper-linux.zip/Flipper-linux.zip Flipper-win.zip/Flipper-win.zip flipper-server.tgz/flipper-server.tgz
- name: Set up npm token
run: echo "//registry.yarnpkg.com/:_authToken=${{ secrets.FLIPPER_NPM_TOKEN }}" >> ~/.npmrc
- name: Publish flipper-server on NPM
run: |
tar zxvf flipper-server.tgz
cd package
yarn publish
- name: Open issue on failure - name: Open issue on failure
if: failure() if: failure()
uses: JasonEtco/create-an-issue@v2.4.0 uses: JasonEtco/create-an-issue@v2.4.0

View File

@@ -209,6 +209,7 @@ async function modifyPackageManifest(
const manifest = require('../flipper-server/package.json'); const manifest = require('../flipper-server/package.json');
manifest.version = versionNumber; manifest.version = versionNumber;
manifest.private = false; // make this package npm-publishable
if (hgRevision != null) { if (hgRevision != null) {
manifest.revision = hgRevision; manifest.revision = hgRevision;
} }
@@ -262,6 +263,7 @@ async function modifyPackageManifest(
if (argv.npx) { if (argv.npx) {
// This is a hack, as npx cached very aggressively if package.version // This is a hack, as npx cached very aggressively if package.version
// didn't change // didn't change
console.log(`⚙️ Installing flipper-server.tgz using npx`); console.log(`⚙️ Installing flipper-server.tgz using npx`);
await fs.remove(path.join(homedir(), '.npm', '_npx')); await fs.remove(path.join(homedir(), '.npm', '_npx'));
await spawn('npx', [archive, argv.open ? '--open' : '--no-open'], { await spawn('npx', [archive, argv.open ? '--open' : '--no-open'], {