diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index 2e3ba390c4..4867bc5daf 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -16,21 +16,28 @@ jobs: fetch-depth: 0 - name: Fetch Pull Request Details + continue-on-error: true run: | SOURCE_BRANCH=${{ github.event.pull_request.head.ref }} # Checking if the source branch was a release + # If the branch is not a release branch we return early and skip the subsequent steps if [[ "$SOURCE_BRANCH" != release/* ]]; then + echo "PROCEED=false" >> $GITHUB_ENV echo "Source branch does not match pattern. Exiting." - exit 1 + echo "IS_RELEASE_BRANCH=false" >> $GITHUB_ENV + exit 0 fi # Extracting the version number from the source branch name + # If the version number does not match we fail to indicate an issue VERSION_NUMBER=${SOURCE_BRANCH#release/} if [[ ! "$VERSION_NUMBER" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "'$VERSION_NUMBER' does not match semantic versioning format. Exiting." exit 1 fi + + echo "IS_RELEASE_BRANCH=true" >> $GITHUB_ENV MERGE_COMMIT_SHA=${{ github.event.pull_request.merge_commit_sha }} PR_NUMBER=${{ github.event.pull_request.number }} @@ -49,6 +56,7 @@ jobs: echo "$PR_BODY" >> "${{ github.workspace }}/release_content.md" - name: Create Release + if: env.IS_RELEASE_BRANCH == 'true' uses: softprops/action-gh-release@v2 with: body_path: "${{ github.workspace }}/release_content.md" diff --git a/.github/workflows/get_release_notes.yml b/.github/workflows/get_release_notes.yml index ab0cd6348c..b445c5ee7e 100644 --- a/.github/workflows/get_release_notes.yml +++ b/.github/workflows/get_release_notes.yml @@ -65,7 +65,7 @@ jobs: IFS="" echo "$OUTPUT" >> $GITHUB_STEP_SUMMARY # Converting the output to Base64 to get a single line required by the GITHUB_OUTPUT - BASE64_RELEASE_NOTES=$(echo "$OUTPUT" | base64) + BASE64_RELEASE_NOTES=$(echo "$OUTPUT" | base64 | tr -d '\n') echo "Base64 Release Notes: $BASE64_RELEASE_NOTES" IFS="" echo "RELEASE_NOTES=$BASE64_RELEASE_NOTES" >> $GITHUB_OUTPUT fi diff --git a/.github/workflows/prepare_release.yml b/.github/workflows/prepare_release.yml index f7084f3c02..d5555959dd 100644 --- a/.github/workflows/prepare_release.yml +++ b/.github/workflows/prepare_release.yml @@ -46,8 +46,18 @@ jobs: - name: Prepare Release Notes run: | RELEASE_NOTES=$(echo "$BASE_64_RELEASE_NOTES" | base64 --decode) - rm -rf "${{ github.workspace }}/release_notes.md" # Making sure we start a fresh document - echo "$RELEASE_NOTES" >> "${{ github.workspace }}/release_notes.md" + TMP_DIR="${{ github.workspace }}/.tmp" + RELEASE_NOTES_FILE_PATH="$TMP_DIR/release_notes.md" + + if [ -e $RELEASE_NOTES_FILE_PATH ] + then + echo "OLD RELEASE NOTES" + cat "$RELEASE_NOTES_FILE_PATH" + rm -rf $RELEASE_NOTES_FILE_PATH # Making sure we start a fresh document + fi + + mkdir -p "$TMP_DIR" + echo "$RELEASE_NOTES" >> $RELEASE_NOTES_FILE_PATH env: BASE_64_RELEASE_NOTES: ${{ needs.get-release-notes.outputs.RELEASE_NOTES }} @@ -59,5 +69,5 @@ jobs: branch: "release/${{ github.event.inputs.sdk-version }}" commit-message: "chore: prepare '${{ github.event.inputs.sdk-version }}' release" title: "[Release] ${{ github.event.inputs.sdk-version }}" - body-path: "${{ github.workspace }}/release_notes.md" + body-path: "${{ github.workspace }}/.tmp/release_notes.md" token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 83095408d6..f9a489b73e 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,4 @@ Package.resolved TempProject/ .build .vscode +.tmp