Skip to content

Commit 31b818b

Browse files
author
MIYASHITA, Akihiro
committed
Update GitHub actions
1 parent 765a31c commit 31b818b

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Node CI
1+
name: Build check
22

33
on: [push]
44

@@ -9,7 +9,7 @@ jobs:
99

1010
strategy:
1111
matrix:
12-
node-version: [14.x, 16.x]
12+
node-version: [14.x, 16.x, 18.x, 20.x]
1313

1414
steps:
1515
- uses: actions/checkout@v1

.github/workflows/release.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Release
2+
on:
3+
push:
4+
tags:
5+
- "v*.*.*"
6+
permissions:
7+
contents: write
8+
jobs:
9+
release-npm:
10+
name: Release npm package
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Setup repository
14+
uses: actions/checkout@v3
15+
- name: Version check
16+
run: |
17+
echo Checking version to publish...
18+
19+
head_hash=$(git rev-parse HEAD)
20+
latest_tag=${{ github.ref_name }}
21+
latest_tag_hash=$(git rev-parse ${latest_tag})
22+
23+
if [ "${head_hash}" != "${latest_tag_hash}" ]; then
24+
echo "HEAD is not at the latest tag (${latest_tag})"
25+
exit 1
26+
fi
27+
28+
package_version=$(cat package.json | grep version | awk -F'"' '{ print "v" $4; }')
29+
30+
if [ "${latest_tag}" != "${package_version}" ]; then
31+
echo "Latest tag (${latest_tag}) does not match package version (${package_version})"
32+
exit 2
33+
fi
34+
35+
echo "Package version: ${package_version}"
36+
- name: Publish npm package
37+
run: |
38+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
39+
pre_release=$(echo ${{ github.ref_name }} | awk -F'-' '{ print $2 }')
40+
if [ "${pre_release}" = "" ]; then
41+
npm publish --access public
42+
else
43+
npm publish --access public --tag beta
44+
fi
45+
- name: Create GitHub release
46+
uses: actions/create-release@v1
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
with:
50+
tag_name: ${{ github.ref }}
51+
release_name: Release ${{ github.ref_name }}
52+
draft: false
53+
prerelease: ${{ contains(github.ref_name, '-') }}

0 commit comments

Comments
 (0)