-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from tshion/feature/2.1.0
Update 2.1.0
- Loading branch information
Showing
8 changed files
with
194 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# まだリリースしていないGit タグのリリースノートの推定 | ||
# ※GitHub CLI のアクセス権限等の設定が必要 | ||
# | ||
# $1 -> リリースしようとしているGit タグ名 | ||
# $2 -> $1 があるGit ブランチ名 | ||
|
||
repoName="tshion/apply-git-user" | ||
|
||
latestTag=$(gh release list \ | ||
--exclude-drafts \ | ||
--exclude-pre-releases \ | ||
--order desc --limit 1 \ | ||
--json tagName --jq '.[].tagName' \ | ||
) | ||
|
||
gh api \ | ||
--method POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
"/repos/$repoName/releases/generate-notes" \ | ||
-f "tag_name=preview$1" \ | ||
-f "target_commitish=$2" \ | ||
-f "previous_tag_name=$latestTag" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.