Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github action setup question #386

Open
ryanbas21 opened this issue Aug 9, 2024 · 2 comments
Open

Github action setup question #386

ryanbas21 opened this issue Aug 9, 2024 · 2 comments

Comments

@ryanbas21
Copy link

ryanbas21 commented Aug 9, 2024

I want to make sure I understand this correctly. My goal is for changesets to have this flow

feature branch -> merge develop -> create pr against master -> merge to master releases to npm.

on:
  push:
    branches:
      - develop
      - master
      
      ....rest of setup
     - name: publish
        uses: changesets/action@v1
        with:
          publish: pnpm release-packages ## command in root package.json that builds and publishes
          title: Release PR
          branch: master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_CONFIG_PROVENANCE: true

is this correct? I read a few issues and saw the PR that added the branch to it. the description of the config setting wasn't entirely clear to me though.

@Andarist
Copy link
Member

Andarist commented Aug 10, 2024

I don't think branch is what you are looking for. It's a setting that you can use to override the source branch but you want to change the target branch of the versioning PR.

In the scenario that you describe, develop would contain all of the changeset files and landing your versioning PR would remove them... but only from master. How do you "backport" master to develop? do you immediately merge it back? force push?

@ryanbas21
Copy link
Author

ryanbas21 commented Aug 10, 2024

Hi @Andarist I actually was able to just solve it, so i'll put what I did here. Yes - I have to rebase develop with master due to the new commit.

In this repo i'm using main instead of master so ignore the inconsistency.

branch seems to create release PR from develop -> main.

Then once I merge, main has a new commit from the changesets-release branch, that develop will not have.

On success of the changesets step, (cant forget the id on the publish step), I can rebase develop with the updated main.

 name: publish
        uses: changesets/action@v1
        id: changesets
        with:
          publish: pnpm release
          title: Release PR
          branch: main
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_CONFIG_PROVENANCE: true

      - name: rebase develop with main on publish
        if: ${{ steps.changesets.outputs.published == 'true' }}
        run: |
          git checkout main
          git fetch --all
          git pull origin main

          git checkout develop
          git restore . # clears out the .npmrc change I dont want to commit.
          git rebase main
          git push -f
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

This is how I was able to get changesets action working with a github flow. I genuinely prefer not using the github flow, but because we use it at work, I wanted to get a working example of it with changesets to present.

I'm using an NX monorepo, and in this case also using pnpm workspaces and it seems that this does the trick although i've only just now run the CI and published

If you see a problem with this flow please let me know :)

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

No branches or pull requests

2 participants