-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
MIYASHITA, Akihiro
committed
May 29, 2024
1 parent
765a31c
commit 31b818b
Showing
2 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Release | ||
on: | ||
push: | ||
tags: | ||
- "v*.*.*" | ||
permissions: | ||
contents: write | ||
jobs: | ||
release-npm: | ||
name: Release npm package | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup repository | ||
uses: actions/checkout@v3 | ||
- name: Version check | ||
run: | | ||
echo Checking version to publish... | ||
head_hash=$(git rev-parse HEAD) | ||
latest_tag=${{ github.ref_name }} | ||
latest_tag_hash=$(git rev-parse ${latest_tag}) | ||
if [ "${head_hash}" != "${latest_tag_hash}" ]; then | ||
echo "HEAD is not at the latest tag (${latest_tag})" | ||
exit 1 | ||
fi | ||
package_version=$(cat package.json | grep version | awk -F'"' '{ print "v" $4; }') | ||
if [ "${latest_tag}" != "${package_version}" ]; then | ||
echo "Latest tag (${latest_tag}) does not match package version (${package_version})" | ||
exit 2 | ||
fi | ||
echo "Package version: ${package_version}" | ||
- name: Publish npm package | ||
run: | | ||
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | ||
pre_release=$(echo ${{ github.ref_name }} | awk -F'-' '{ print $2 }') | ||
if [ "${pre_release}" = "" ]; then | ||
npm publish --access public | ||
else | ||
npm publish --access public --tag beta | ||
fi | ||
- name: Create GitHub release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref_name }} | ||
draft: false | ||
prerelease: ${{ contains(github.ref_name, '-') }} |