diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2cb7caf..8369953 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,17 @@ on: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CHANGES_TEMPLATE: "## 202x.x.x (Unreleased)\n\n### General\n- \n\n### Client\n- \n\n### Server\n- \n" + CHANGES_TEMPLATE: | + ## 202x.x.x (Unreleased) + + ### General + - + + ### Client + - + + ### Server + - name: "Release Manager" @@ -31,7 +41,9 @@ jobs: - uses: actions/checkout@v4 # jqでpackage.jsonから現在のバージョンを取得 - name: Get current version - run: echo "current_version=$(jq -r '.version' package.json)" >> $GITHUB_OUTPUT + run: | + jq -r '.version' package.json + echo "current_version=$(jq -r '.version' package.json)" >> $GITHUB_OUTPUT id: get_current_version # バージョンをインクリメント - name: Increment version @@ -43,11 +55,13 @@ jobs: const now = new Date(); const year = now.toLocaleDateString('en-US', { year: 'numeric', timeZone: 'Asia/Tokyo' }); const month = now.toLocaleDateString('en-US', { month: 'numeric', timeZone: 'Asia/Tokyo' }); - const [major, minor, patch] = process.env.CURRENT_VERSION.split('.'); + const [major, minor, _patch] = process.env.CURRENT_VERSION.split('.'); + const patch = Number(_patch.split('-')[0]); + if (patch.isNaN()) throw new Error('Invalid patch version'); if (year !== major || month !== minor) { return `${year}.${month}.0`; } else { - return `${major}.${minor}.${Number(patch) + 1}`; + return `${major}.${minor}.${patch + 1}`; } result-encoding: string id: increment_version @@ -62,6 +76,7 @@ jobs: sed -n '/## 202x.x.x (Unreleased)/,/^## /p' CHANGELOG.md | sed -e 1d -e '$d' id: changelog # CHANGELOG.mdのバージョンの書き換え + # 環境変数から挿入する部分: https://qiita.com/sahayan/items/8658992f0f48eb5d2bc4 - name: Modify CHANGELOG.md run: | sed -i 's/## 202x.x.x (Unreleased)/## ${{ steps.increment_version.outputs.result }}/' CHANGELOG.md