-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: cicd - create rls draft on tags
- Loading branch information
1 parent
7d4577f
commit 45d1f96
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
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,29 @@ | ||
name: create-release-draft | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: read | ||
|
||
jobs: | ||
draft_release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.ref }} # Explicitly specifies the tag ref | ||
|
||
|
||
- name: Setup GitHub CLI | ||
run: | | ||
sudo apt update | ||
sudo apt install gh | ||
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token | ||
- name: Create Draft Release | ||
run: ./scripts/create-release-draft.sh ${{ github.ref_name }} ${{ github.workspace }} |
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,45 @@ | ||
#!/bin/bash | ||
|
||
# Usage: ./create_release.sh <tag_name> | ||
|
||
TAG_NAME=$1 | ||
REPO_PATH=$2 # Ensure the script is executed in the repository's root directory | ||
|
||
# Navigate to the repository path (if not already there) | ||
cd $REPO_PATH || exit 1 | ||
|
||
# Get the commit ID for the tag | ||
RELEASE_COMMIT_ID=$(git rev-list -n 1 "$TAG_NAME") | ||
|
||
echo "Creating a draft release for tag $TAG_NAME with commit ID $RELEASE_COMMIT_ID" | ||
|
||
CHANGELOG_TAG_NAME=${1#v} # Remove 'v' prefix if present | ||
|
||
#Parse the release notes from the CHANGELOG.md file | ||
|
||
RELEASE_NOTES=$(awk -v version="$CHANGELOG_TAG_NAME" ' | ||
# Start printing if the line exactly matches the version heading format | ||
$0 ~ "^## " version " - " { | ||
printit = 1; | ||
} | ||
# Continue printing if printit was set | ||
printit { | ||
if (/^## [0-9]+\.[0-9]+\.[0-9]+/ && $0 !~ version) { | ||
printit = 0; # Stop printing immediately before printing this line | ||
} else { | ||
print $0; | ||
} | ||
} | ||
' CHANGELOG.md) | ||
|
||
# Prepend the header to the release notes | ||
HEADER=$'Thanks for trying out MetaMask Mobile! We really appreciate your feedback 🤗.\n\n## Table of Contents\n- [What’s new](https://github.com/MetaMask/metamask-mobile/blob/main/CHANGELOG.md)\n- [Feedback](https://github.com/MetaMask/metamask-mobile/issues/new?assignees=&labels=&projects=&template=general-issue.yml)\n\n' | ||
FULL_RELEASE_NOTES="$HEADER$RELEASE_NOTES" | ||
|
||
# Create a draft release using GitHub CLI | ||
gh release create \ | ||
"$TAG_NAME" \ | ||
--title "$TAG_NAME" \ | ||
--notes "$FULL_RELEASE_NOTES" \ | ||
--target "$RELEASE_COMMIT_ID" \ | ||
--draft |