-
Notifications
You must be signed in to change notification settings - Fork 1
47 lines (46 loc) · 1.4 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: publish
env:
CI: true
on:
push:
branches:
- main
tags:
- '!*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
always-auth: true
registry-url: https://npm.pkg.github.com
scope: '@hatena'
- run: pnpm install
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# まだ publish されていないバージョンなら publish する
- name: publish package
run: |
npx can-npm-publish --verbose && pnpm publish || echo "Does not publish"
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# package.json からバージョンを取得する
- name: get version from package.json
id: package-version
run: echo "version=$(cat package.json | jq -r .version)" >> $GITHUB_OUTPUT
# まだ tag がないバージョンなら tag を push する
- name: publish tag
uses: pkgdeps/git-tag-action@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_repo: ${{ github.repository }}
git_commit_sha: ${{ github.sha }}
version: ${{ steps.package-version.outputs.version }}
git_tag_prefix: 'v'