Skip to content

Commit

Permalink
Update GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
MIYASHITA, Akihiro committed May 29, 2024
1 parent 765a31c commit 31b818b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/nodejs.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Node CI
name: Build check

on: [push]

Expand All @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x]
node-version: [14.x, 16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v1
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
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, '-') }}

0 comments on commit 31b818b

Please sign in to comment.