Update changelog #6
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
name: Update changelog | |
concurrency: | |
group: update-changelog-${{ github.event_name }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
type: string | |
required: true | |
description: 'EMQX version (with v/e prefix)' | |
repository: | |
type: choice | |
required: true | |
options: | |
- emqx/emqx | |
- emqx/emqx-platform | |
run_id: | |
type: string | |
required: true | |
description: 'The run id of the workflow that generates the changelog' | |
permissions: | |
contents: read | |
jobs: | |
update-changelog: | |
runs-on: ubuntu-latest | |
env: | |
EMQX_VERSION: ${{ github.event.inputs.version }} | |
REPOSITORY: ${{ github.event.inputs.repository }} | |
RUN_ID: ${{ github.event.inputs.run_id }} | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Generate GitHub App token | |
id: app-token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ vars.AUTH_APP_ID }} | |
private-key: ${{ secrets.AUTH_APP_PRIVATE_KEY }} | |
owner: ${{ github.repository_owner }} | |
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
with: | |
name: changes | |
repository: ${{ env.REPOSITORY }} | |
run-id: ${{ env.RUN_ID }} | |
github-token: ${{ steps.app-token.outputs.token }} | |
- name: create release branch and PR | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
set -euxo pipefail | |
RE='^[ve]([0-9]+)\.([0-9]+)\.([0-9]+)(-([a-z]+\.[0-9]+))?$' | |
echo "$EMQX_VERSION" | grep -qE "$RE" || exit 1 | |
MAJOR=$(echo "$EMQX_VERSION" | sed -r "s#$RE#\1#") | |
MINOR=$(echo "$EMQX_VERSION" | sed -r "s#$RE#\2#") | |
PATCH=$(echo "$EMQX_VERSION" | sed -r "s#$RE#\3#") | |
NEW_BRANCH="release-notes-${EMQX_VERSION##[v|e]}" | |
BASE_BRANCH="release-${MAJOR}.${MINOR}" | |
git config --global user.name "${GITHUB_ACTOR}" | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git fetch origin | |
if [ -z "$(git ls-remote --heads origin $BASE_BRANCH)" ]; then | |
git checkout -b $BASE_BRANCH | |
fi | |
if [ -z "$(git ls-remote --heads origin $NEW_BRANCH)" ]; then | |
git checkout $BASE_BRANCH | |
git checkout -b $NEW_BRANCH | |
fi | |
mkdir dev | |
tar -xzf changes.tar.gz -C dev | |
./update-changelog.sh dev/changes "$MAJOR.$MINOR.$PATCH" | |
git add en_US/changes/changes-*-v5.md | |
git add en_US/changes/breaking-changes-*.md | |
git commit -m "chore: update changelog for ${EMQX_VERSION}" | |
git push origin $NEW_BRANCH | |
pr_title="${MAJOR}.${MINOR}.${PATCH} Release Notes" | |
pr=$(gh pr list --state open --base "${BASE_BRANCH}" --label release-notes --search "${pr_title} in:title" --repo ${{ github.repository }} --json number --jq '.[] | .number') | |
if [ -z "$pr" ]; then | |
gh pr create --title "${pr_title}" --body "" --base "${BASE_BRANCH}" --head "${NEW_BRANCH}" --label release-notes --repo ${{ github.repository }} | |
fi |