-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (120 loc) · 3.98 KB
/
create-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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Create a release pull request
on:
workflow_dispatch:
inputs:
versionMajor:
description: "バージョン情報: major"
required: true
type: string
versionMinor:
description: "バージョン情報: minor"
required: true
type: string
versionPatch:
description: "バージョン情報: patch"
required: true
type: string
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
build:
if: ${{ github.ref_type == 'branch' && github.ref_name == 'develop' }}
runs-on: ubuntu-24.04
outputs:
branch: ${{ steps.meta.outputs.branch }}
version: ${{ steps.meta.outputs.version }}
permissions:
contents: write
timeout-minutes: 5
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4
# https://github.com/actions/setup-node
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: ./package-lock.json
- name: Set version & format branch name
id: meta
env:
VERSION: "${{ inputs.versionMajor }}.${{ inputs.versionMinor }}.${{ inputs.versionPatch }}"
run: |
npm version "$VERSION" --no-git-tag-version
version=$(node -p "require('./package.json').version")
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "branch=feature/$version" >> "$GITHUB_OUTPUT"
- name: Can release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.meta.outputs.version }}
run: bash .github/scripts/can-release.bash "$TAG"
- run: npm ci
- run: npm test
- run: npm run build
# https://github.com/actions/checkout/issues/13#issuecomment-724415212
- name: Set up git user
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: git add & push
env:
BRANCH: ${{ steps.meta.outputs.branch }}
VERSION: ${{ steps.meta.outputs.version }}
run: |
git switch --create "$BRANCH"
git add compiled
git add package.json
git add package-lock.json
git commit --message "Update $VERSION"
git push --set-upstream origin "$BRANCH"
test-action:
needs: build
uses: ./.github/workflows/test-action.yml
with:
git_ref: ${{ needs.build.outputs.branch }}
create-pr:
needs:
- build
- test-action
runs-on: ubuntu-24.04
permissions:
contents: write
pull-requests: write
timeout-minutes: 5
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4
with:
ref: ${{ needs.build.outputs.branch }}
- name: Generate diff notes
id: notes
env:
GH_TOKEN: ${{ github.token }}
REF_NAME: ${{ needs.build.outputs.branch }}
TAG: ${{ needs.build.outputs.version }}
run: |
response=$(bash .github/scripts/presume-release-notes.bash "$TAG" "$REF_NAME")
echo "response=$response" >> "$GITHUB_OUTPUT"
echo "$response"
- name: Create a file for pull request body
shell: ruby {0}
env:
NOTE: ${{ fromJson(steps.notes.outputs.response).body }}
URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
text = <<"BODY"
Test result: #{ENV['URL']}
#{ENV['NOTE']}
BODY
File.open("PR_BODY", "w") { |file|
file.write(text)
}
- name: Create a pull request
env:
ASSIGNEE: tshion
BASE: released
GH_TOKEN: ${{ github.token }}
TITLE: "Update ${{ needs.build.outputs.version }}"
run: gh pr create --assignee "$ASSIGNEE" --base "$BASE" --title "$TITLE" --body-file PR_BODY