-
Notifications
You must be signed in to change notification settings - Fork 1
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 #519 from NUTFes/feature/imaimai/auto-release-labe…
…ling 自動リリース機能と自動ラベリング機能の実装
- Loading branch information
Showing
4 changed files
with
101 additions
and
0 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,36 @@ | ||
name: Automatically labeling pull request. | ||
|
||
on: | ||
pull_request: | ||
types: [opened] | ||
|
||
jobs: | ||
auto-labeling-pr: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
# ラベル名を取得する | ||
- name: Get label name | ||
id: label_name | ||
run: | | ||
branch_type=$(echo ${{github.head_ref}} | cut -d "/" -f1) | ||
if [ $branch_type == 'feature' ]; then | ||
label_name=$(echo "enhancement") | ||
elif [ $branch_type == 'fix' ] || [ $branch_type == 'hotfix' ]; then | ||
label_name=$(echo "bug") | ||
else | ||
label_name="" | ||
fi | ||
echo "::set-output name=label_name::$label_name" | ||
# PRにラベルを付与する | ||
- name: Auto labeling | ||
if: ${{ steps.label_name.outputs.label_name }} | ||
run: | | ||
number=$(echo $GITHUB_REF | sed -e 's/[^0-9]//g') | ||
gh pr edit $number --add-label ${{ steps.label_name.outputs.label_name }} |
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,49 @@ | ||
name: Create release tag and release note. | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
create-release-tag: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
TZ: 'Asia/Tokyo' | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
# 前回のりリースタグを取得する | ||
- name: Get previous tag | ||
id: pre_tag | ||
run: | | ||
echo "::set-output name=pre_tag::$(curl -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)" | ||
# タグを生成する 「{YYYY.MM.DD}-{当日リリース回数}」 | ||
- name: Generate release tag | ||
id: release_tag | ||
run: | | ||
today=$(date +'%Y.%m.%d') | ||
pre_release_date=$(echo ${{ steps.pre_tag.outputs.pre_tag }} | awk -F'-' '{print $1}') | ||
pre_release_count=$(echo ${{ steps.pre_tag.outputs.pre_tag }} | awk -F'-' '{print $2}') | ||
if [[ ! $pre_release_date = $today ]]; then | ||
echo "init count" | ||
pre_release_count=0 | ||
fi | ||
echo "::set-output name=release_tag::$today-$(($pre_release_count + 1))" | ||
# 前回リリースからの差分をもとに、リリースノートの本文を生成する | ||
- name: Generate release note | ||
id: release_note | ||
run: | | ||
echo "::set-output name=release_note::$(curl -X POST -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' https://api.github.com/repos/${{ github.repository }}/releases/generate-notes -d '{"tag_name":"${{ steps.release_tag.outputs.release_tag }}", "previous_tag_name":"${{ steps.pre_tag.outputs.pre_tag }}"}' | jq .body | sed 's/"//g')" | ||
# タグを切り、リリースノートを作成する | ||
- name: Create Release | ||
run: | | ||
curl -X POST \ | ||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-d "{ \"tag_name\": \"${{ steps.release_tag.outputs.release_tag }}\", \"name\": \"${{ steps.release_tag.outputs.release_tag }}\", \"body\": \"${{ steps.release_note.outputs.release_note }}\"}" \ | ||
https://api.github.com/repos/${{ github.repository }}/releases |
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,15 @@ | ||
changelog: | ||
exclude: | ||
# リリースノートから除外したいユーザー | ||
authors: | ||
- github-actions | ||
categories: | ||
- title: New Features 🎉 | ||
labels: | ||
- "enhancement" | ||
- title: Bug Fix 💊 | ||
labels: | ||
- "bug" | ||
- title: Other Changes 🛠 | ||
labels: | ||
- "*" |
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 @@ | ||
test dayo |