-
Notifications
You must be signed in to change notification settings - Fork 1
75 lines (65 loc) · 2.24 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
name: Release Workflow
on:
workflow_dispatch:
inputs:
releaseType:
description: 'Release Type (MAJOR, MINOR, PATCH)'
required: true
default: '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
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 "v*" --sort=-v:refname | grep -E '^v[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 v${{ steps.next_version.outputs.version }}
- name: Push Git tag
run: |
git config --global user.name 'Anton Potapov'
git config --global user.email '47938145+Flagro@users.noreply.github.com.'
git push origin v${{ steps.next_version.outputs.version }}
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.next_version.outputs.version }}
release_name: Release v${{ steps.next_version.outputs.version }}
draft: ${{ github.event.inputs.draft }}
prerelease: ${{ github.event.inputs.prerelease }}