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

feat: republish major tag on new npm version #20

Merged
merged 2 commits into from
Jul 7, 2023

Conversation

domharrington
Copy link
Member

🚥 Fixes #9

🧰 Changes

GitHub Actions allows you to define a tag for an action to use that doesn't have to be a fully qualified semver version. This means we can publish v2.3.0 onto npm and then re-push that to v2 as a git tag. This means we dont have to prompt users to upgrade any time we push a non-breaking change. This is a pretty common pattern that GitHub does themselves, and we also do it in rdme too!

So then instead of telling people to do this:

- name: GitHub Action
  uses: readmeio/readme-micro@v2.3.0

We can just do this

- name: GitHub Action
  uses: readmeio/readme-micro@v2

🧬 QA & Testing

If you run this:

./bin/set-major-version-tag.js
$ git tag v2 -f -m 'Top-level tag pointing to 2.3.0'
Updated tag 'v2' (was fc99ec6)

You'll see how it works. We've automatically wired this up to the postversion event which is after the new npm version has been created and the new git tag is present.

@@ -17,7 +17,7 @@
"test": "jest",
"preversion": "echo $npm_package_version > .old-version.txt",
"version": "sed -i '' \"s/$(cat .old-version.txt)/$npm_package_version/\" README.md && git add README.md",
"postversion": "rm -rf .old-version.txt"
"postversion": "rm -rf .old-version.txt && ./bin/set-major-version-tag.js"
Copy link
Contributor

Choose a reason for hiding this comment

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

to avoid needing executable permissions, this should be fine:

Suggested change
"postversion": "rm -rf .old-version.txt && ./bin/set-major-version-tag.js"
"postversion": "rm -rf .old-version.txt && node ./bin/set-major-version-tag.js"

since it already works, this should be fine

@domharrington domharrington merged commit 529d7d3 into main Jul 7, 2023
@domharrington domharrington deleted the feat/repush-major-version-tag branch July 7, 2023 17:31
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.

Add util postversion hook to repush major version tag
2 participants