Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

リリース自動化のワークフローを変更 #183

Merged
merged 1 commit into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/create_release_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: create_release_pr

on:
workflow_dispatch:
inputs:
release-version:
description: 'select release semantic version (patch, minor, major)'
required: true
type: choice
options:
- 'patch'
- 'minor'
- 'major'

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16

# アップデート後のバージョンを環境変数にセット
- name: Get new version
id: new-version
run: |
echo "NEW_VERSION=$(npm --no-git-tag-version version $RELEASE_TYPE)" >> $GITHUB_ENV

# package.jsonのバージョンをアップデートしてコミット
- name: Update package.json version
run: |
NEW_VERSION=$(npm --no-git-tag-version version ${{ env.RELEASE_VERSION }})
git add package.json
git commit -m "chore: release $NEW_VERSION"
env:
RELEASE_VERSION: ${{ github.event.inputs.release-version }}

- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v5
with:
branch: release/v${{ env.NEW_VERSION }}
title: release ${{ env.NEW_VERSION }}
labels: release

- name: Enable Pull Request Automerge
run: gh pr merge --merge --auto "${{ steps.cpr.outputs.pull-request-number }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50 changes: 15 additions & 35 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
name: release

on:
workflow_dispatch:
inputs:
release-typ:
description: 'select release type (patch, minor, major)'
required: true
type: choice
options:
- 'patch'
- 'minor'
- 'major'
pull_request:
types:
- closed
branches:
- main

jobs:
release:
runs-on: macos-latest
# releaseラベルが付いているPRがマージされたときに実行
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -48,35 +45,18 @@ jobs:
- name: Package app
run: yarn package

# gitを設定
- name: Git configuration
- name: set new version
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
NEW_VERSION=$(node -pe "require('./package.json').version")
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV

# アップデート後のバージョンを環境変数にセット
- name: Get new version
# アップデート後のバージョンのタグを生成してプッシュ
- name: push new version tag
id: new-version
run: |
echo "NEW_VERSION=$(npm --no-git-tag-version version $RELEASE_TYPE)" >> $GITHUB_ENV
env:
RELEASE_TYPE: ${{ github.event.inputs.release-typ }}

# package.jsonのバージョンをアップデートしてコミット
- name: Update package.json version
run: |
git add package.json
git commit -m "chore: release ${{ env.NEW_VERSION }}"
git tag ${{ env.NEW_VERSION }}
env:
RELEASE_TYPE: ${{ github.event.inputs.release-typ }}

# 変更をリポジトリにプッシュ
- name: Push changes to repository
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push origin && git push --tags
TAG_NAME="v${{ env.NEW_VERSION }}"
git tag $TAG_NAME
git push origin $TAG_NAME

# リリースノートを生成して最新バージョンのアプリケーションを添付
- name: Release
Expand Down
Loading