-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (76 loc) · 2.41 KB
/
release.yaml
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
78
79
80
81
82
83
84
85
86
name: Release Workflow
on:
workflow_dispatch:
inputs:
releaseType:
description: 'Release Type'
required: true
default: 'patch'
type: choice
options:
- major
- minor
- patch
draft:
description: 'Create a draft release'
required: false
default: false
type: boolean
prerelease:
description: 'Mark release as a prerelease'
required: false
default: false
type: boolean
releaseMessage:
description: 'Release Message'
required: false
default: ''
type: string
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Fetch tags
run: git fetch --depth=1 --tags
- name: Get latest tag or set default
id: latest_tag
run: |
TAG=$(git tag -l --sort=-v:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)
if [ -z "$TAG" ]; then
TAG="0.0.0"
fi
echo "::set-output name=tag::$TAG"
- name: Create dummy package.json
run: |
echo "{\"version\": \"${{ steps.latest_tag.outputs.tag }}\"}" > package.json
cat package.json
- name: Calculate next version
id: next_version
run: |
npm --no-git-tag-version version ${{ github.event.inputs.releaseType }}
NEXT_VERSION=$(node -p "require('./package.json').version")
echo "Next version: $NEXT_VERSION"
echo "::set-output name=version::$NEXT_VERSION"
- name: Create Git tag
run: git tag ${{ steps.next_version.outputs.version }}
- name: Push Git tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push origin ${{ steps.next_version.outputs.version }}
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.next_version.outputs.version }}
release_name: Release v${{ steps.next_version.outputs.version }}
body: ${{ github.event.inputs.releaseMessage }}
draft: ${{ github.event.inputs.draft }}
prerelease: ${{ github.event.inputs.prerelease }}