-
Notifications
You must be signed in to change notification settings - Fork 2
83 lines (72 loc) · 2.94 KB
/
release.yml
File metadata and controls
83 lines (72 loc) · 2.94 KB
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
name: Release
on:
workflow_dispatch:
inputs:
version:
description: "Version bump type"
required: true
type: choice
options:
- patch
- minor
- major
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v4.2.2
with:
fetch-depth: 0
- name: Setup Project
uses: ./.github/actions/setup-node-yarn
- name: Extract release notes from Unreleased section
id: changelog
run: |
NOTES=$(awk '/## \[Unreleased\]/ {flag=1; next} /^## \[/ {flag=0} flag && NF {print}' CHANGELOG.md)
if [ -z "$NOTES" ] || [ -z "$(echo "$NOTES" | tr -d '[:space:]')" ]; then
echo "Error: No release notes found in the [Unreleased] section of CHANGELOG.md"
echo "Please add release notes before creating a release."
exit 1
fi
echo "notes<<EOF" >> $GITHUB_OUTPUT
echo "$NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Bump version and update CHANGELOG
id: bump
run: |
NEW_VERSION=$(npm version ${{ github.event.inputs.version }} --no-git-tag-version)
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
sed -i "s/## \[Unreleased\]/## [Unreleased]\n\n## [$NEW_VERSION] - $(date +%Y-%m-%d)/" CHANGELOG.md
- name: Check if release already exists
run: |
if git ls-remote --tags origin | grep -q "refs/tags/${{ steps.bump.outputs.version }}$"; then
echo "Error: Release tag ${{ steps.bump.outputs.version }} already exists"
echo "Please check existing releases or use a different version bump type."
exit 1
fi
- name: Build and pack
id: pack
run: |
yarn install --immutable
yarn prepare
yarn pack --filename mendix-native-${{ steps.bump.outputs.version }}.tgz
echo "tgz=mendix-native-${{ steps.bump.outputs.version }}.tgz" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
with:
tag_name: ${{ steps.bump.outputs.version }}
name: ${{ steps.bump.outputs.version }}
body: ${{ steps.changelog.outputs.notes }}
files: ${{ steps.pack.outputs.tgz }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@84ae59a2cdc2258d6fa0732dd66352dddae2a412 # v7.0.9
with:
commit-message: "chore: release ${{ steps.bump.outputs.version }}"
branch: release/${{ steps.bump.outputs.version }}
title: "Release ${{ steps.bump.outputs.version }}"
body: "This PR updates CHANGELOG.md and package.json for release ${{ steps.bump.outputs.version }}."
base: main