-
Notifications
You must be signed in to change notification settings - Fork 2
78 lines (65 loc) · 2.46 KB
/
release-pr.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
78
name: Create Release PR
on:
workflow_dispatch:
inputs:
version:
description: "Release version"
required: true
default: 0.0.0
type: string
workflow_call:
inputs:
version:
default: 0.0.0
type: string
jobs:
release-pr:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git fetch --all --tags
- name: Check Version
run: bash -c '$([[ "${{ inputs.version }}" =~ ^([0-9]+\.){2}[0-9]+ ]])'
- run: |
git config --global user.name "releasebot"
git config --global user.email "[email protected]"
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm ci
- name: Bump version
if: ${{ inputs.version != '0.0.0' }}
run: npm --no-git-tag-version version ${{ inputs.version }}
- name: Changelog
id: create-changelog
run: |
./node_modules/.bin/generate-changelog -a
cat CHANGELOG.md >> $GITHUB_STEP_SUMMARY
- name: lint fix
if: ${{ inputs.version != '0.0.0' }}
run: yarn run fix
- name: Create Branch
if: ${{ inputs.version != '0.0.0' }}
id: create-branch
run: |
COMMIT_SHA=$(git rev-parse --short HEAD)
BRANCH=releases/draft-$COMMIT_SHA-$(date +%s)
git checkout -b $BRANCH
git add CHANGELOG.md package.json package-lock.json
git status
git commit -m "Release: v${{ inputs.version }}"
git push origin HEAD
echo "branch_name=$BRANCH" >> $GITHUB_OUTPUT
- name: Create PR
if: ${{ inputs.version != '0.0.0' }}
run: |
gh pr create -B main -H ${{ steps.create-branch.outputs.branch_name }} --title "Release: v${{ inputs.version }}" --body-file CHANGELOG.md
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}