Add release script
This commit is contained in:
parent
008d582ac3
commit
ff7499c705
48
README.md
48
README.md
|
|
@ -55,6 +55,54 @@ It can be useful for automating repetitive tasks such as updating version number
|
|||
replacement-text: '42'
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
### Update the Action Code
|
||||
|
||||
The [`src/`](./src/) directory contains the source code that will be run when
|
||||
the action is invoked.
|
||||
|
||||
After making changes to the action code, make sure to run the following command
|
||||
to run all tests, lint the code, and build the final JavaScript action code:
|
||||
|
||||
```bash
|
||||
npm run all
|
||||
```
|
||||
|
||||
> This step is important! It will run [`ncc`](https://github.com/vercel/ncc) to
|
||||
> build the final JavaScript action code with all dependencies included. If you
|
||||
> do not run this step, the action will not work correctly when it is used in a
|
||||
> workflow. This step also includes the `--license` option for `ncc`, which will
|
||||
> create a license file for all of the production node modules used in your
|
||||
> project.
|
||||
|
||||
### Publishing a New Release
|
||||
|
||||
This project includes a helper script, [`script/release`](./script/release)
|
||||
designed to streamline the process of tagging and pushing new releases for
|
||||
GitHub Actions.
|
||||
|
||||
GitHub Actions allows users to select a specific version of the action to use,
|
||||
based on release tags. This script simplifies this process by performing the
|
||||
following steps:
|
||||
|
||||
1. **Retrieving the latest release tag:** The script starts by fetching the most
|
||||
recent release tag by looking at the local data available in your repository.
|
||||
1. **Prompting for a new release tag:** The user is then prompted to enter a new
|
||||
release tag. To assist with this, the script displays the latest release tag
|
||||
and provides a regular expression to validate the format of the new tag.
|
||||
1. **Tagging the new release:** Once a valid new tag is entered, the script tags
|
||||
the new release.
|
||||
1. **Pushing the new tag to the remote:** Finally, the script pushes the new tag
|
||||
to the remote repository. From here, you will need to create a new release in
|
||||
GitHub and users can easily reference the new tag in their workflows.
|
||||
|
||||
To use the script, run the following command:
|
||||
|
||||
```bash
|
||||
./script/release
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! Here are some ways you can contribute:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
#!/bin/bash
|
||||
|
||||
# About:
|
||||
#
|
||||
# This is a helper script to tag and push a new release. GitHub Actions use
|
||||
# release tags to allow users to select a specific version of the action to use.
|
||||
#
|
||||
# See: https://github.com/actions/typescript-action#publishing-a-new-release
|
||||
#
|
||||
# This script will do the following:
|
||||
#
|
||||
# 1. Get the latest release tag
|
||||
# 2. Prompt the user for a new release tag
|
||||
# 3. Tag the new release
|
||||
# 4. Push the new tag to the remote
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# script/release
|
||||
|
||||
# Terminal colors
|
||||
OFF='\033[0m'
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
|
||||
# Get the latest release tag
|
||||
latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
|
||||
|
||||
if [[ -z "$latest_tag" ]]; then
|
||||
# There are no existing release tags
|
||||
echo -e "No tags found (yet) - Continue to create and push your first tag"
|
||||
latest_tag="[unknown]"
|
||||
fi
|
||||
|
||||
# Display the latest release tag
|
||||
echo -e "The latest release tag is: ${BLUE}${latest_tag}${OFF}"
|
||||
|
||||
# Prompt the user for the new release tag
|
||||
read -r -p 'Enter a new release tag (vX.X.X format): ' new_tag
|
||||
|
||||
# Validate the new release tag
|
||||
tag_regex='v[0-9]+(\.[0-9]+){0,2}$'
|
||||
if echo "$new_tag" | grep -q -E "$tag_regex"; then
|
||||
echo -e "Tag: ${BLUE}$new_tag${OFF} is valid"
|
||||
else
|
||||
# Release tag is not `vX.X.X` format
|
||||
echo -e "Tag: ${BLUE}$new_tag${OFF} is ${RED}not valid${OFF} (must be in vX.X.X format)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Tag the new release
|
||||
git tag -a "$new_tag" -m "$new_tag Release"
|
||||
echo -e "${GREEN}Tagged: $new_tag${OFF}"
|
||||
|
||||
# Push the new tag to the remote
|
||||
git push --tags
|
||||
echo -e "${GREEN}Release tag pushed to remote${OFF}"
|
||||
echo -e "${GREEN}Done!${OFF}"
|
||||
Loading…
Reference in New Issue