Skip to content

Conversation

@benwinding
Copy link
Contributor

Scope
Added functionality for deploying a package within a subdirectory in a monorepo. Similar to PR #7, but here's my changes anyway...

Features
In mono repos the src directory and compiled dist directory are usually in different folders. So I added the 2 environment variables:

  • SRC_PACKAGE_DIR (where the src package.json is to increment)
  • DEPLOY_DIR (where the dist package.json is to run npm publish)

In angular development it's convention to use a projects folder for the src code and a dist folder for the builds.

Here's a working snippet using a forked version of this repo:

- name: Publish
      if: github.ref == 'refs/heads/master'
      uses: benwinding/merge-release@master
      env:
        DEPLOY_DIR: dist/ngx-firestate
        SRC_PACKAGE_DIR: projects/ngx-firestate
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

Cheers for making this anyway, hope this PR helps someone else 👍

Copy link
Owner

@mikeal mikeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a minor change request.

I also want to spend a little more time thinking about this code. It seems fine but since there’s no good way to test GitHub Actions I want to give myself a little more time for reviewing it mentally :)

const event = JSON.parse(fs.readFileSync('/github/workflow/event.json').toString())

let pkg = require(path.join(process.cwd(), 'package.json'))
const deployDir = path.join(process.cwd(), process.env.DEPLOY_DIR || './')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should also use path.normalize to remove the dangling ./ on the default case.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, it looks like .join does normalization now. i wonder why i thought it didn’t.

@mattdsteele
Copy link
Contributor

mattdsteele commented May 3, 2020

@benwinding thank you for putting this together! Conceptually it looks like exactly what I'm looking for; I'm using pika/pack for my tooling, which builds the package in a pkg/ subfolder.

I'm trying to use your branched version in my project, but it doesn't appear to be working:

https://github.com/mattdsteele/bt-device/blob/60b453d03176c03f03c5134ba739b224b15abef9/.github/workflows/publish.yml#L24-L28

Using this approach, my NPM packages still are published at the root:, instead of the subfolder I want https://unpkg.com/browse/[email protected]/

Looking at the Action's entrypoint, I think this is because it's using the NPM version of merge-release when actually being used by a component:

https://github.com/mikeal/merge-release/blob/master/entrypoint.sh#L31

Which makes me thing this PR needs merged and published for folks to actually use 🙃

@mikeal can you confirm? Is there anything I can do to help get this merged?

@mikeal
Copy link
Owner

mikeal commented May 3, 2020

pinging @FredKSchott who might find this interesting.

@mikeal
Copy link
Owner

mikeal commented May 3, 2020

Apologies, I didn’t see the last commit come in after my last review comment. This shouldn’t have sat here for so long, my bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants