diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index be64ee10f..370fdbffd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -60,3 +60,18 @@ jobs: GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_TOKEN }} GITHUB_USER: sui-bot NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + publish-tagged-packages: + name: Publish Tagged Packages to NPM + if: github.ref != 'refs/heads/master' + runs-on: ubuntu-latest + steps: + - name: Get Files + id: files + uses: jitterbit/get-changed-files@v1 + with: + format: 'json' + + - name: Publish Packages + working-directory: ${{ github.workspace }} + run: publish-tagged-packages '${{ steps.files.outputs.added_modified }}' diff --git a/package.json b/package.json index 02b9a1b71..897a4fb33 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,9 @@ "workspaces": [ "packages/*" ], + "bin": { + "publish-tagged-packages": "./scripts/publish-tagged-packages.mjs" + }, "scripts": { "phoenix": "npx @s-ui/mono phoenix && npx -y ultra-runner --raw --recursive prepublishOnly --build &>/dev/null", "co": "npx @s-ui/mono commit", @@ -34,6 +37,7 @@ "@s-ui/precommit": "3", "@s-ui/react-context": "1", "chai": "4.3.6", + "commander": "11.1.0", "react": "17", "sinon": "10.0.0", "typescript": "5.0.4", diff --git a/scripts/publish-tagged-packages.mjs b/scripts/publish-tagged-packages.mjs new file mode 100644 index 000000000..98f8f9f7f --- /dev/null +++ b/scripts/publish-tagged-packages.mjs @@ -0,0 +1,21 @@ +#!/usr/bin/env node + +const program = require('commander') + +program + .option('-f, --files [files]', 'JSON-stringified list of added and modified files.') + .on('--help', () => { + console.log(' Examples:') + console.log('') + console.log( + ' $ publish-tagged-packages --tag ongoing-branch --files \'["packages/sui-mono/foo.js", "packages/sui-bundler/bar.js"]\'' + ) + console.log('') + }) + .parse(process.argv) + +const {files} = program.opts() + +console.log({files}) + +program.exit(0)