Update npm-publish.yml #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create Release | |
on: | |
push: | |
workflow_dispatch: | |
jobs: | |
create-release: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Check out the code | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# Step 2: Set up Node.js | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' # Use the latest LTS version of Node.js | |
# Step 3: Read the version from package.json | |
- name: Get version from package.json | |
id: get_version | |
run: | | |
PACKAGE_VERSION=$(node -p "require('./package.json').version") | |
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV | |
# Step 4: Create the tag | |
- name: Create tag | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git tag -a "${PACKAGE_VERSION}" -m "Release ${PACKAGE_VERSION}" | |
git push origin "${PACKAGE_VERSION}" | |
# Step 5: Create GitHub release | |
- name: Create GitHub Release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: "${{ env.PACKAGE_VERSION }}" | |
release_name: "Release ${{ env.PACKAGE_VERSION }}" | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |