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

Make the release script update the package.json version #854

Open
2zqa opened this issue Jan 26, 2024 · 7 comments · May be fixed by #964
Open

Make the release script update the package.json version #854

2zqa opened this issue Jan 26, 2024 · 7 comments · May be fixed by #964
Assignees

Comments

@2zqa
Copy link

2zqa commented Jan 26, 2024

I think it would be useful if the release script would also automatically set the version of package.json to the newly specified version. Currently one must remember to update this before running the release script. Alternatively, the script could be updated to check if the newly specified version is the same as the version in package.json.

@2zqa
Copy link
Author

2zqa commented Jan 26, 2024

This might be more complicated than I anticipated - this would also include updating the package-lock.json file, along with committing and pushing these changes on behalf of the user. Still leaving this issue up to gather opinions.

EDIT: to simplify this PR, it might suffice to add a warning/notice for the user to update their package.json and package-lock.json files before running the script.

@ncalteen
Copy link
Collaborator

ncalteen commented Feb 1, 2024

Hi @2zqa 👋

Thanks for the input! I do agree that it would be useful, however as you've noticed there are some complications involved with updating the package.json and package-lock.json. Additionally, developers may be using other runtimes, so it may not work correctly in those cases.

As an alternative, I maintain a separate action, issue-ops/semver that can be used as a PR check to confirm that the version has been updated before a PR is merged. A usage example is below:

# This workflow checks the version of the application package that is being
# built in the current pull request. If the version has already been published,
# the workflow fails to prevent PRs from being merged until the version has been
# incremented in the manifest file.
name: Version Check

on:
  pull_request:
    branches:
      - main

env:
  MANIFEST_PATH: package.json

permissions:
  checks: write
  contents: read
  pull-requests: write

jobs:
  check-version:
    name: Version Check
    runs-on: ubuntu-latest

    if: ${{ github.actor != 'dependabot[bot]' }}

    steps:
      # The fetch-depth and fetch-tags options are required
      - name: Checkout
        id: checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          fetch-tags: true

      - name: Check Version
        id: check-version
        uses: issue-ops/[email protected]
        with:
          check-only: true
          manifest-path: ${{ env.MANIFEST_PATH }}

The end result is the Version Check job is added as a PR check that fails if the version in package.json is already present in the repository tags.

Image

You would need to then need to enable the Require status checks to pass before merging option in your branch protection rules.

Let me know if that helps you!

@ncalteen ncalteen self-assigned this Feb 1, 2024
@2zqa
Copy link
Author

2zqa commented Feb 2, 2024

This is a great solution, thanks! I added it to my repo. It's great that I now know about this, should we now also advertise this in the README of this project? Or is that overreaching?

@ncalteen
Copy link
Collaborator

ncalteen commented Feb 2, 2024

I'm glad you like it :D Feel free to drop in any feedback/questions int he repo! As far as including in these templates, I am checking with the Actions team to get their thoughts. If they're good with it, I will update the template action repos to all include automatic release management :)

@developer982
Copy link

I think it would be useful if the release script would also automatically set the version of package.json to the newly specified version. Currently one must remember to update this before running the release script. Alternatively, the script could be updated to check if the newly specified version is the same as the version in package.json.

@actions actions deleted a comment May 22, 2024
@actions actions deleted a comment May 22, 2024
@actions actions deleted a comment May 22, 2024
@actions actions deleted a comment May 22, 2024
@Evilwa1 Evilwa1 mentioned this issue Jul 17, 2024
@ncalteen ncalteen linked a pull request Oct 31, 2024 that will close this issue
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 a pull request may close this issue.

5 participants
@ncalteen @2zqa @developer982 and others