How to tag and draft a new Packagist release via GitHub using the command line
GitHubHere are some shorthand methods if you're frequently updating your Packagist repositories via GitHub.
`Drafting a new release` is preceded by `tag` creation. But this can quickly get boring and repetitive.
git tag -a v0.5 -m "v0.5" git push origin v0.5 gh release create v0.5 --title "v0.5" --notes "Cleaned up README.md." lang-bash
As you can see you'll need `gh` installed.
To make this even quicker if you're doing many releases in a row, here is a Bash script. The Bash script can be used like this:
release 7 "Fancy new feature" lang-bash
It will first print out older release information and give the user a chance to abort.
#!/usr/bin/env bash
# Set the default prefix. You can change this value if needed.
VERSION_PREFIX="v0."
# Check that the correct number of arguments is provided.
if [[ $# -ne 2 ]]; then
echo "Usage: $0 <param1> <param2>"
echo "param1: Version number (e.g., 5)"
echo "param2: Release notes (in quotes)"
exit 1
fi
# Extract parameters from the command line.
VERSION_NUMBER=$1
RELEASE_NOTES=$2
# Construct the version string.
VERSION="${VERSION_PREFIX}${VERSION_NUMBER}"
# Display the current tags and release notes
for version in $(gh release list --json tagName -q ".[].tagName"); do
echo -n "$version: " && gh release view "$version" --json body -q ".body" | cat
done
# Pause and prompt for confirmation before proceeding.
echo -e "\nPress [Enter] to continue and create the new tag, or Ctrl+C to cancel."
read -r # Waits for user to press Enter.
# Proceed with the commands if the user presses Enter.
git tag -a "${VERSION}" -m "${VERSION}"
git push origin "${VERSION}"
gh release create "${VERSION}" --title "${VERSION}" --notes "${RELEASE_NOTES}"
lang-bashOn Mac you can save the file to:
sudo vi /usr/local/bin/release sudo chmod +x /usr/local/bin/release lang-bash