-
Notifications
You must be signed in to change notification settings - Fork 6
77 lines (74 loc) · 2.29 KB
/
release.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: release
on:
workflow_dispatch:
inputs:
bumpType:
description: Bump Type
required: true
type: choice
options:
- patch
- minor
- major
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- run: pnpm install
- run: pnpm test run
- run: pnpm build
- name: Configure git user
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
- name: Bump package.json version
id: bump
run: |
pnpm version ${{ github.event.inputs.bumpType }}
echo "VERSION=v$(cat package.json | jq -r '.version')" >> $GITHUB_OUTPUT
git push
git push --tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release
run: |
pnpm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
- name: Get commit summary
id: get_commit_summary
run: |
PREVIOUS_TAG=$(git tag --sort=-creatordate | sed -n 2p)
echo "PREVIOUS_TAG: $PREVIOUS_TAG"
COMMIT_SUMMARY="$(git log --oneline --pretty=tformat:"%h %s" $PREVIOUS_TAG..${{ github.ref }})"
COMMIT_SUMMARY="${COMMIT_SUMMARY//$'\n'/'%0A'}"
echo ::set-output name=COMMIT_SUMMARY::$COMMIT_SUMMARY
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
release_name: Release ${{ steps.get_version.outputs.VERSION }}
body: |
${{ steps.get_commit_summary.outputs.COMMIT_SUMMARY }}
draft: true
prerelease: true