2024-01-23 14:07:10 +08:00
|
|
|
name: 🔖 Release
|
2024-09-30 00:44:23 +08:00
|
|
|
run-name: 🔖 Release (${{ github.ref_name }})
|
2024-01-23 14:07:10 +08:00
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- release
|
2024-09-30 00:44:23 +08:00
|
|
|
- release-*
|
2024-01-23 14:07:10 +08:00
|
|
|
tags-ignore:
|
|
|
|
- "**"
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
release:
|
|
|
|
name: 🔖 Release (${{ github.ref_name }})
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: write
|
|
|
|
pull-requests: write
|
|
|
|
issues: write
|
|
|
|
outputs:
|
|
|
|
channel: ${{ steps.release.outputs.new_release_channel }}
|
|
|
|
released: ${{ steps.release.outputs.new_release_published }}
|
|
|
|
tag: ${{ steps.release.outputs.new_release_git_tag }}
|
|
|
|
version: ${{ steps.release.outputs.new_release_version }}
|
2024-05-22 23:22:16 +08:00
|
|
|
merge_to: ${{ steps.summary.outputs.merge_to }}
|
|
|
|
split_to: ${{ steps.summary.outputs.split_to }}
|
2024-01-23 14:07:10 +08:00
|
|
|
steps:
|
|
|
|
- name: 🚚 Checkout (${{ github.ref_name }})
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: 🔖 Run semantic release
|
|
|
|
uses: cycjimmy/semantic-release-action@v4
|
|
|
|
id: release
|
|
|
|
with:
|
|
|
|
working_directory: Packages/src
|
|
|
|
extra_plugins: |
|
|
|
|
@semantic-release/changelog
|
|
|
|
@semantic-release/git
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
|
|
|
2024-05-22 23:22:16 +08:00
|
|
|
- id: summary
|
|
|
|
run: |
|
2024-01-23 14:07:10 +08:00
|
|
|
echo "🔖 New release published: '${{ steps.release.outputs.new_release_published }}'" | tee -a $GITHUB_STEP_SUMMARY
|
|
|
|
echo "🔖 New release version: '${{ steps.release.outputs.new_release_version }}'" | tee -a $GITHUB_STEP_SUMMARY
|
|
|
|
echo "🔖 New release channel: '${{ steps.release.outputs.new_release_channel }}'" | tee -a $GITHUB_STEP_SUMMARY
|
|
|
|
echo "🔖 New release git tag: '${{ steps.release.outputs.new_release_git_tag }}'" | tee -a $GITHUB_STEP_SUMMARY
|
2024-05-22 23:22:16 +08:00
|
|
|
|
|
|
|
if [ '${{ steps.release.outputs.new_release_published }}' = 'false' ]; then
|
|
|
|
echo "No new release published." | tee -a $GITHUB_STEP_SUMMARY
|
|
|
|
elif [ '${{ github.ref_name }}' = 'release' ]; then
|
2024-09-30 00:44:23 +08:00
|
|
|
echo "merge_to=develop" | tee -a $GITHUB_OUTPUT $GITHUB_STEP_SUMMARY
|
|
|
|
echo "split_to=main" | tee -a $GITHUB_OUTPUT $GITHUB_STEP_SUMMARY
|
|
|
|
else
|
|
|
|
channel=$(echo ${{ github.ref_name }} | sed 's/^release-//')
|
|
|
|
echo "merge_to=develop-${channel}" | tee -a $GITHUB_OUTPUT $GITHUB_STEP_SUMMARY
|
|
|
|
echo "split_to=${channel}" | tee -a $GITHUB_OUTPUT $GITHUB_STEP_SUMMARY
|
2024-05-22 23:22:16 +08:00
|
|
|
fi
|
2024-01-23 14:07:10 +08:00
|
|
|
|
2024-05-22 23:22:16 +08:00
|
|
|
merge-to:
|
|
|
|
if: needs.release.outputs.merge_to != ''
|
2024-01-23 14:07:10 +08:00
|
|
|
needs: release
|
2024-05-22 23:22:16 +08:00
|
|
|
name: 🔀 Merge to ${{ needs.release.outputs.merge_to }}
|
2024-01-23 14:07:10 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: write
|
|
|
|
steps:
|
2024-05-22 23:22:16 +08:00
|
|
|
- name: 🚚 Checkout (${{ needs.release.outputs.merge_to }})
|
2024-01-23 14:07:10 +08:00
|
|
|
uses: actions/checkout@v4
|
|
|
|
with:
|
2024-05-22 23:22:16 +08:00
|
|
|
ref: ${{ needs.release.outputs.merge_to }}
|
2024-01-23 14:07:10 +08:00
|
|
|
fetch-depth: 0
|
2024-05-22 23:22:16 +08:00
|
|
|
- name: 🔀 Merge '${{ needs.release.outputs.tag }}' into '${{ needs.release.outputs.merge_to }}'
|
2024-01-23 14:07:10 +08:00
|
|
|
run: |
|
|
|
|
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
|
|
|
git config --local user.name "github-actions[bot]"
|
|
|
|
|
|
|
|
git merge ${{ needs.release.outputs.tag }}
|
2024-05-22 23:22:16 +08:00
|
|
|
git push origin ${{ needs.release.outputs.merge_to }}
|
2024-01-23 14:07:10 +08:00
|
|
|
|
2024-05-22 23:22:16 +08:00
|
|
|
split-to:
|
|
|
|
if: needs.release.outputs.split_to != ''
|
2024-01-23 14:07:10 +08:00
|
|
|
needs: release
|
2024-05-22 23:22:16 +08:00
|
|
|
name: 🔀 Split package to ${{ needs.release.outputs.split_to }}
|
2024-01-23 14:07:10 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: write
|
|
|
|
steps:
|
|
|
|
- name: 🚚 Checkout (${{ needs.release.outputs.tag }})
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
ref: ${{ needs.release.outputs.tag }}
|
|
|
|
fetch-depth: 0
|
2024-05-22 23:22:16 +08:00
|
|
|
- name: 🔀 Split subtree 'Packages/src' to '${{ needs.release.outputs.split_to }}'
|
2024-01-23 14:07:10 +08:00
|
|
|
run: |
|
2024-05-22 23:22:16 +08:00
|
|
|
split_to=${{ needs.release.outputs.split_to }}
|
|
|
|
git branch $split_to origin/$split_to
|
|
|
|
git subtree split --prefix=Packages/src --branch $split_to
|
|
|
|
git tag ${{ needs.release.outputs.version }} $split_to
|
|
|
|
git push origin ${{ needs.release.outputs.version }} $split_to:$split_to
|