-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yaml
More file actions
90 lines (82 loc) · 3.16 KB
/
action.yaml
File metadata and controls
90 lines (82 loc) · 3.16 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
84
85
86
87
88
89
90
name: "Create PR on Dependent Project"
description: "Updates a dependent project with new library version and creates a pull request"
inputs:
libraryName:
description: "Name of this library (e.g., gisce/commitlint-rules)"
required: true
dependentProject:
description: "Name of dependent projects (e.g., gisce/ooui.js)"
required: true
dependentProjectBranch:
description: "Name of the branch for the dependent project (e.g., alpha)"
required: true
tagName:
description: "Name of the tag (e.g., v1.0.0-alpha.0)"
required: true
githubToken:
description: "GitHub token for authentication"
required: true
releaseType:
description: "Type of release (e.g., minor, major, patch)"
required: true
nodeVersion:
description: "Node.js version to use for npm install"
required: false
default: "24.12.0"
runs:
using: "composite"
steps:
- name: Checkout dependent project repository
uses: actions/checkout@v2
with:
repository: ${{ inputs.dependentProject }}
ref: ${{ inputs.dependentProjectBranch }}
token: ${{ inputs.githubToken }}
- name: Update library version in package.json
run: |
NEW_VERSION=${{ inputs.tagName }}
NEW_VERSION=${NEW_VERSION#v} # Remove the leading 'v'
sed -i 's|"@${{ inputs.libraryName }}": "[^"]*"|"@${{ inputs.libraryName }}": "'"$NEW_VERSION"'"|' package.json
shell: bash
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ inputs.nodeVersion }}
- name: Install npm dependencies and generate package-lock.json
run: |
npm install
shell: bash
- name: Format Library Name
id: format-lib-name
run: |
FORMATTED_NAME="${{ inputs.libraryName }}"
FORMATTED_NAME="${FORMATTED_NAME//\//-}"
echo "FORMATTED_NAME=$FORMATTED_NAME" >> $GITHUB_ENV
shell: bash
- name: Determine Commit Message
id: commit-message
run: |
RELEASE_TYPE=${{ inputs.releaseType }}
if [[ "$RELEASE_TYPE" == "patch" ]]; then
PREFIX="fix"
elif [[ "$RELEASE_TYPE" == "minor" ]]; then
PREFIX="feat"
elif [[ "$RELEASE_TYPE" == "major" ]]; then
PREFIX="feat"
BREAKING_CHANGE="BREAKING CHANGE: bump major version"
echo "BREAKING_CHANGE=$BREAKING_CHANGE" >> $GITHUB_ENV
fi
echo "PREFIX=$PREFIX" >> $GITHUB_ENV
shell: bash
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ inputs.githubToken }}
commit-message: |
${{ env.PREFIX }}: update ${{ inputs.libraryName }} to ${{ inputs.tagName }}
${{ env.BREAKING_CHANGE }}
https://github.com/${{ inputs.libraryName }}/releases/tag/${{ inputs.tagName }}
title: "update ${{ inputs.libraryName }} to ${{ inputs.tagName }}"
branch: "update-${{ env.FORMATTED_NAME }}-${{ inputs.tagName }}"
body: |
This PR updates [${{ inputs.libraryName }}](https://github.com/${{ inputs.libraryName }}) to [${{ inputs.tagName }}](https://github.com/${{ inputs.libraryName }}/releases/tag/${{ inputs.tagName }}).