-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (83 loc) · 2.87 KB
/
draft-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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: 📜 Draft a release
on:
workflow_dispatch:
inputs:
version:
description: "New version to draft"
required: true
type: string
jobs:
release:
name: Draft a Release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: 18
- name: Define version
run: |
INPUT_VERSION=${{ github.event.inputs.version }}
NEW_VERSION=${INPUT_VERSION:-"0.0.1"}
echo "Input version: ${INPUT_VERSION}"
echo "New version: ${NEW_VERSION}"
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
- name: Version validation
run: |
if ! echo "$NEW_VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$'; then
echo "Invalid semver format" >&2
exit 1
fi
- name: Get latest tag
id: latest-tag
run: |
git fetch --tags
LATEST_TAG=$(git tag | tail -n1)
echo "latest_tag=${LATEST_TAG}" >> $GITHUB_OUTPUT
- name: Version comparison
id: compare-versions
run: |
LATEST_VERSION="${{ steps.latest-tag.outputs.latest_tag }}"
echo "Latest version: $LATEST_VERSION"
echo "New version: $NEW_VERSION"
if dpkg --compare-versions $NEW_VERSION le $LATEST_VERSION; then
echo "New version must be higher than $LATEST_VERSION"
exit 1
fi
- name: Set branch name
run: |
echo "BRANCH_NAME=release/${NEW_VERSION//./-}" >> $GITHUB_ENV
- name: Version bump
id: version-bump
run: |
npm --no-git-tag-version version "$NEW_VERSION"
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Create pull request
id: cpr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
base: main
delete-branch: true
branch: ${{ env.BRANCH_NAME }}
commit-message: "feat(repo): ${{ env.NEW_VERSION }}"
committer: GitHub <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
title: "feat(repo): ${{ env.NEW_VERSION }}"
draft: false
#labels: |
# docs
body: |
Bumps version to ${{ env.NEW_VERSION }}
add-paths: |
package.json
- name: "Debug: Check outputs"
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"