-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
95 changed files
with
3,612 additions
and
412 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Create hotfix branch | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
create_branch: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ secrets.AUTO_RELEASE_PAT }} | ||
|
||
- name: Check if the input is valid tag | ||
shell: bash | ||
run: | | ||
if [[ ${{github.ref}} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
echo "::notice::${{github.ref}} is a valid tag." | ||
else | ||
echo "::error::${{github.ref}} is not a valid tag." | ||
exit 1 | ||
fi | ||
- name: Create hotfix branch | ||
shell: bash | ||
run: | | ||
HOTFIX_BRANCH="hotfix-${GITHUB_REF#refs/tags/v}" | ||
if git switch --create "$HOTFIX_BRANCH"; then | ||
git push origin "$HOTFIX_BRANCH" | ||
echo "::notice::Created hotfix branch: $HOTFIX_BRANCH" | ||
else | ||
echo "::error::Failed to create hotfix branch" | ||
exit 1 | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
name: Create tag on hotfix branch | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
create_tag: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ secrets.AUTO_RELEASE_PAT }} | ||
|
||
- name: Install git-cliff | ||
uses: baptiste0928/cargo-install@v2.1.0 | ||
with: | ||
crate: git-cliff | ||
version: 1.2.0 | ||
|
||
- name: Check if the input is valid hotfix branch | ||
shell: bash | ||
run: | | ||
if [[ ${{github.ref}} =~ ^refs/heads/hotfix-[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
echo "::notice::${{github.ref}} is a valid branch." | ||
else | ||
echo "::error::${{github.ref}} is not a valid branch." | ||
exit 1 | ||
fi | ||
- name: Check if the latest commit is tag | ||
shell: bash | ||
run: | | ||
if [[ -z "$(git tag --points-at HEAD)" ]]; then | ||
echo "::notice::The latest commit is not a tag " | ||
else | ||
echo "::error::The latest commit on the branch is already a tag" | ||
exit 1 | ||
fi | ||
- name: Determine current and next tag | ||
shell: bash | ||
run: | | ||
function get_next_tag() { | ||
local previous_tag="${1}" | ||
local previous_hotfix_number | ||
local next_tag | ||
previous_hotfix_number="$(echo "${previous_tag}" | awk -F. '{ print $4 }')" | ||
if [[ -z "${previous_hotfix_number}" ]]; then | ||
# Previous tag was not a hotfix tag | ||
next_tag="${previous_tag}+hotfix.1" | ||
else | ||
# Previous tag was a hotfix tag, increment hotfix number | ||
local hotfix_number=$((previous_hotfix_number + 1)) | ||
next_tag="${previous_tag/%${previous_hotfix_number}/${hotfix_number}}" | ||
fi | ||
echo "${next_tag}" | ||
} | ||
PREVIOUS_TAG="$(git tag --merged | sort --version-sort | tail --lines 1)" | ||
NEXT_TAG="$(get_next_tag "${PREVIOUS_TAG}")" | ||
echo "PREVIOUS_TAG=${PREVIOUS_TAG}" >> $GITHUB_ENV | ||
echo "NEXT_TAG=${NEXT_TAG}" >> $GITHUB_ENV | ||
- name: Generate changelog | ||
shell: bash | ||
run: | | ||
# Generate changelog content and store it in `release-notes.md` | ||
git-cliff --config '.github/git-cliff-changelog.toml' --strip header --tag "${NEXT_TAG}" "${PREVIOUS_TAG}^.." \ | ||
| sed "/## ${PREVIOUS_TAG#v}\$/,\$d" \ | ||
| sed '$s/$/\n- - -/' > release-notes.md | ||
# Append release notes after the specified pattern in CHANGELOG.md | ||
sed --in-place '0,/^- - -/!b; /^- - -/{ | ||
a | ||
r release-notes.md | ||
}' CHANGELOG.md | ||
rm release-notes.md | ||
- name: Set Git Configuration | ||
shell: bash | ||
run: | | ||
git config --local user.name 'github-actions' | ||
git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com' | ||
- name: Push created commit and tag | ||
shell: bash | ||
run: | | ||
# Stage, commit and tag the changelog | ||
git add CHANGELOG.md | ||
git commit --message "chore(version): ${NEXT_TAG}" | ||
git tag --message "$(git show --no-patch --format=%s HEAD)" "${NEXT_TAG}" HEAD | ||
git push | ||
git push --tags |
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
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
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
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
Oops, something went wrong.