Skip to content

Commit ec98679

Browse files
authored
Merge pull request #88 from tshion/feature/2.1.0
Update 2.1.0
2 parents 1e54980 + 08ca853 commit ec98679

File tree

8 files changed

+194
-138
lines changed

8 files changed

+194
-138
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# まだリリースしていないGit タグのリリースノートの推定
4+
# ※GitHub CLI のアクセス権限等の設定が必要
5+
#
6+
# $1 -> リリースしようとしているGit タグ名
7+
# $2 -> $1 があるGit ブランチ名
8+
9+
repoName="tshion/apply-git-user"
10+
11+
latestTag=$(gh release list \
12+
--exclude-drafts \
13+
--exclude-pre-releases \
14+
--order desc --limit 1 \
15+
--json tagName --jq '.[].tagName' \
16+
)
17+
18+
gh api \
19+
--method POST \
20+
-H "Accept: application/vnd.github+json" \
21+
-H "X-GitHub-Api-Version: 2022-11-28" \
22+
"/repos/$repoName/releases/generate-notes" \
23+
-f "tag_name=preview$1" \
24+
-f "target_commitish=$2" \
25+
-f "previous_tag_name=$latestTag"

.github/workflows/140-create-version-pr.yml

Lines changed: 0 additions & 82 deletions
This file was deleted.

.github/workflows/160-create-release-pr.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Create a release pull request
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
versionMajor:
7+
description: "バージョン情報: major"
8+
required: true
9+
type: string
10+
versionMinor:
11+
description: "バージョン情報: minor"
12+
required: true
13+
type: string
14+
versionPatch:
15+
description: "バージョン情報: patch"
16+
required: true
17+
type: string
18+
19+
concurrency:
20+
group: ${{ github.workflow }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
build:
25+
if: ${{ github.ref_type == 'branch' && github.ref_name == 'develop' }}
26+
runs-on: ubuntu-24.04
27+
outputs:
28+
branch: ${{ steps.meta.outputs.branch }}
29+
version: ${{ steps.meta.outputs.version }}
30+
permissions:
31+
contents: write
32+
timeout-minutes: 5
33+
steps:
34+
# https://github.com/actions/checkout
35+
- uses: actions/checkout@v4
36+
37+
# https://github.com/actions/setup-node
38+
- uses: actions/setup-node@v4
39+
with:
40+
node-version-file: .node-version
41+
cache: npm
42+
cache-dependency-path: ./package-lock.json
43+
44+
- name: Set version & format branch name
45+
id: meta
46+
env:
47+
VERSION: "${{ inputs.versionMajor }}.${{ inputs.versionMinor }}.${{ inputs.versionPatch }}"
48+
run: |
49+
npm version "$VERSION" --no-git-tag-version
50+
version=$(node -p "require('./package.json').version")
51+
echo "version=$version" >> "$GITHUB_OUTPUT"
52+
echo "branch=feature/$version" >> "$GITHUB_OUTPUT"
53+
54+
- name: Can release
55+
env:
56+
GH_TOKEN: ${{ github.token }}
57+
TAG: ${{ steps.meta.outputs.version }}
58+
run: bash .github/scripts/can-release.bash "$TAG"
59+
60+
- run: npm ci
61+
62+
- run: npm test
63+
64+
- run: npm run build
65+
66+
# https://github.com/actions/checkout/issues/13#issuecomment-724415212
67+
- name: Set up git user
68+
run: |
69+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
70+
git config --local user.name "github-actions[bot]"
71+
72+
- name: git add & push
73+
env:
74+
BRANCH: ${{ steps.meta.outputs.branch }}
75+
VERSION: ${{ steps.meta.outputs.version }}
76+
run: |
77+
git switch --create "$BRANCH"
78+
git add compiled
79+
git add package.json
80+
git add package-lock.json
81+
git commit --message "Update $VERSION"
82+
git push --set-upstream origin "$BRANCH"
83+
84+
85+
test-action:
86+
needs: build
87+
uses: ./.github/workflows/test-action.yml
88+
with:
89+
git_ref: ${{ needs.build.outputs.branch }}
90+
91+
92+
create-pr:
93+
needs:
94+
- build
95+
- test-action
96+
runs-on: ubuntu-24.04
97+
permissions:
98+
contents: write
99+
pull-requests: write
100+
timeout-minutes: 5
101+
steps:
102+
# https://github.com/actions/checkout
103+
- uses: actions/checkout@v4
104+
with:
105+
ref: ${{ needs.build.outputs.branch }}
106+
107+
- name: Generate diff notes
108+
id: notes
109+
env:
110+
GH_TOKEN: ${{ github.token }}
111+
REF_NAME: ${{ needs.build.outputs.branch }}
112+
TAG: ${{ needs.build.outputs.version }}
113+
run: |
114+
response=$(bash .github/scripts/presume-release-notes.bash "$TAG" "$REF_NAME")
115+
echo "response=$response" >> "$GITHUB_OUTPUT"
116+
echo "$response"
117+
118+
- name: Create a file for pull request body
119+
shell: ruby {0}
120+
env:
121+
NOTE: ${{ fromJson(steps.notes.outputs.response).body }}
122+
URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
123+
run: |
124+
text = <<"BODY"
125+
Test result: #{ENV['URL']}
126+
127+
#{ENV['NOTE']}
128+
BODY
129+
File.open("PR_BODY", "w") { |file|
130+
file.write(text)
131+
}
132+
133+
- name: Create a pull request
134+
env:
135+
ASSIGNEE: tshion
136+
BASE: released
137+
GH_TOKEN: ${{ github.token }}
138+
TITLE: "Update ${{ needs.build.outputs.version }}"
139+
run: gh pr create --assignee "$ASSIGNEE" --base "$BASE" --title "$TITLE" --body-file PR_BODY

.github/workflows/180-release-preparation.yml renamed to .github/workflows/prepare-release-note.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 180 Release preparation
1+
name: Prepare a GitHub release note
22

33
on:
44
push:
@@ -14,10 +14,10 @@ concurrency:
1414
jobs:
1515
preparation:
1616
if: ${{ github.ref_type == 'branch' }}
17-
runs-on: ubuntu-latest
18-
timeout-minutes: 5
17+
runs-on: ubuntu-24.04
1918
permissions:
2019
contents: write
20+
timeout-minutes: 5
2121
steps:
2222
# https://github.com/actions/checkout
2323
- uses: actions/checkout@v4

0 commit comments

Comments
 (0)