Skip to content

Commit

Permalink
Merge pull request #88 from tshion/feature/2.1.0
Browse files Browse the repository at this point in the history
Update 2.1.0
  • Loading branch information
tshion authored Jan 3, 2025
2 parents 1e54980 + 08ca853 commit ec98679
Show file tree
Hide file tree
Showing 8 changed files with 194 additions and 138 deletions.
25 changes: 25 additions & 0 deletions .github/scripts/presume-release-notes.bash
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"
82 changes: 0 additions & 82 deletions .github/workflows/140-create-version-pr.yml

This file was deleted.

47 changes: 0 additions & 47 deletions .github/workflows/160-create-release-pr.yml

This file was deleted.

139 changes: 139 additions & 0 deletions .github/workflows/create-release-pr.yml
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 180 Release preparation
name: Prepare a GitHub release note

on:
push:
Expand All @@ -14,10 +14,10 @@ concurrency:
jobs:
preparation:
if: ${{ github.ref_type == 'branch' }}
runs-on: ubuntu-latest
timeout-minutes: 5
runs-on: ubuntu-24.04
permissions:
contents: write
timeout-minutes: 5
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4
Expand Down
Loading

0 comments on commit ec98679

Please sign in to comment.