Skip to content

Commit

Permalink
Merge pull request #183 from t-yng/chore/release-ci-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
t-yng authored Oct 14, 2023
2 parents da2f9fe + 0bcc76b commit e76822c
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 35 deletions.
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

0 comments on commit e76822c

Please sign in to comment.