diff --git a/.github/workflows/fetch_updated_release_notes_file.yml b/.github/workflows/fetch_updated_release_notes_file.yml new file mode 100644 index 0000000..4e7e3a2 --- /dev/null +++ b/.github/workflows/fetch_updated_release_notes_file.yml @@ -0,0 +1,36 @@ +name: Fetch Updated Release Notes File + +on: + workflow_call: + inputs: + version-name: + description: "Version Name" + required: true + type: string + outputs: + description: "Filepath for the updated release notes file" + updated-release-notes-filepath: ${{ jobs.fetch_updated_release_notes_file.outputs.updated-release-notes-filepath }} + + +jobs: + fetch_updated_release_notes_file: + name: Fetch Updated Release Notes File + runs-on: ubuntu-latest + outputs: + updated-release-notes-filepath: ${{ steps.fetch_updated_release_notes_file.outputs.updated-release-notes-filepath }} + + steps: + - uses: actions/checkout@v4 + with: + ref: "release-notes-test-9.9.9" + + - name: Fetch filepath for updated release notes file + id: fetch_updated_release_notes_file + env: + PROJECT_ROOT: ${{ github.workspace }} + VERSION_NAME: ${{ inputs.version-name }} + run: | + chmod +x scripts/fetch_updated_release_notes_file.sh + UPDATED_RELEASE_NOTES_FILEPATH=$(./scripts/fetch_updated_release_notes_file.sh $PROJECT_ROOT $VERSION_NAME) + echo -e "updated-release-notes-filepath=$UPDATED_RELEASE_NOTES_FILEPATH" >> $GITHUB_OUTPUT + echo -e $UPDATED_RELEASE_NOTES_FILEPATH diff --git a/.github/workflows/fetch_version_name_from_release_notes.yml b/.github/workflows/fetch_version_name_from_release_notes.yml deleted file mode 100644 index d73564b..0000000 --- a/.github/workflows/fetch_version_name_from_release_notes.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Fetch version name from release notes - -on: - workflow_call: - outputs: - version-name: - description: "The version name of the release associated to latest release notes" - value: ${{ jobs.fetch_version_name.outputs.version-name }} - -jobs: - fetch_version_name: - name: Fetch Version Name - runs-on: ubuntu-latest - outputs: - version-name: ${{ steps.fetch_version_name.outputs.version_name }} - - steps: - - uses: actions/checkout@v4 - - name: Fetch version name from latest release notes - id: fetch_version_name - run: | - chmod +x scripts/fetch_release_notes_version_name.sh - commit_message="${{ github.event.head_commit.message }}" - VERSION_NAME=$(./scripts/fetch_release_notes_version_name.sh "${commit_message// /}") - echo -e "version-name=$VERSION_NAME" >> $GITHUB_OUTPUT - echo -e $VERSION_NAME diff --git a/.github/workflows/finalize_release.yml b/.github/workflows/finalize_release.yml index 3018646..280a657 100644 --- a/.github/workflows/finalize_release.yml +++ b/.github/workflows/finalize_release.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: inputs: version-name: - description: "Version name of the build" + description: "Version Name" required: true type: string @@ -13,13 +13,5 @@ jobs: name: Update release notes uses: ./.github/workflows/update_release_notes.yml secrets: inherit - needs: fetch_version_name - with: - version-name: ${{ inputs.version-name }} - publish_github_release: - name: Update release notes - uses: ./.github/workflows/publish_github_release.yml - secrets: inherit - needs: [fetch_version_name, update_release_notes] with: version-name: ${{ inputs.version-name }} diff --git a/.github/workflows/update_github_release_notes.yml b/.github/workflows/update_github_release_notes.yml new file mode 100644 index 0000000..0156ff2 --- /dev/null +++ b/.github/workflows/update_github_release_notes.yml @@ -0,0 +1,43 @@ +name: Update GitHub Release Notes + +on: + workflow_call: + inputs: + version-name: + description: "Version Name" + required: true + type: string + updated-release-notes-filepath: + description: "Updated Release Notes Filepath" + required: true + type: string +jobs: + update_release_notes: + name: Update Release Notes + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + ref: "release-notes-test-9.9.9" + + - name: Print updated release notes + run: | + cat ${{ inputs.updated-release-notes-filepath }} + + # Update Github release with the updated release notes + - name: Update Github release notes + id: update_github_release_notes + uses: ncipollo/release-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION_NAME: ${{ inputs.version-name }} + BODY_FILE: ${{ inputs.updated-release-notes-filepath }} + with: + token: ${{ env.GITHUB_TOKEN }} + tag: ${{ env.VERSION_NAME }} + allowUpdates: true + updateOnlyUnreleased: true + omitNameDuringUpdate: true + draft: true + bodyFile: ${{ env.BODY_FILE }} diff --git a/.github/workflows/update_release_notes.yml b/.github/workflows/update_release_notes.yml index 33d96a7..ce0efe7 100644 --- a/.github/workflows/update_release_notes.yml +++ b/.github/workflows/update_release_notes.yml @@ -5,59 +5,40 @@ on: workflow_call: inputs: version-name: + description: "Version Name" required: true type: string jobs: - fetch_updated_release_notes_file: - name: Fetch Updated Release Notes File - runs-on: ubuntu-latest - outputs: - updated-release-notes-filepath: ${{ steps.fetch_updated_release_notes_file.outputs.updated-release-notes-filepath }} - - steps: - - uses: actions/checkout@v4 - with: - ref: "release-notes" - - - name: Fetch filepath for updated release notes file - id: fetch_updated_release_notes_file - env: - PROJECT_ROOT: ${{ github.workspace }} - VERSION_NAME: ${{ inputs.version-name }} - run: | - chmod +x scripts/fetch_updated_release_notes_file.sh - UPDATED_RELEASE_NOTES_FILEPATH=$(./scripts/fetch_updated_release_notes_file.sh $PROJECT_ROOT $VERSION_NAME) - echo -e "updated-release-notes-filepath=$UPDATED_RELEASE_NOTES_FILEPATH" >> $GITHUB_OUTPUT - echo -e $UPDATED_RELEASE_NOTES_FILEPATH - - update_release_notes: - name: Update Release Notes + create_github_release: runs-on: ubuntu-latest - needs: fetch_updated_release_notes_file steps: - uses: actions/checkout@v4 - with: - ref: "release-notes" - - name: Print updated release notes - run: | - cat ${{ needs.fetch_updated_release_notes_file.outputs.updated-release-notes-filepath }} - - # Update Github release with the updated release notes - - name: Update Github release notes - id: update_github_release_notes + # Create a Github release with release notes. + - name: Create Github release uses: ncipollo/release-action@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VERSION_NAME: ${{ inputs.version-name }} - BODY_FILE : ${{ needs.fetch_updated_release_notes_file.outputs.updated-release-notes-filepath }} + VERSION_NAME: "9.9.9" with: token: ${{ env.GITHUB_TOKEN }} tag: ${{ env.VERSION_NAME }} - allowUpdates: true - updateOnlyUnreleased: true - omitNameDuringUpdate: true + name: ${{ env.VERSION_NAME }} draft: true - bodyFile: ${{ env.BODY_FILE }} + + fetch_updated_release_notes_file: + name: Fetch Updated Release Notes File + needs: create_github_release + uses: ./.github/workflows/fetch_updated_release_notes_file.yml + with: + version-name: ${{ inputs.version-name }} + + update_release_notes: + name: Update Github Release Notes + uses: ./.github/workflows/update_github_release_notes.yml + needs: fetch_updated_release_notes_file + with: + version-name: ${{ inputs.version-name }} + updated-release-notes-filepath: ${{ needs.fetch_updated_release_notes_file.outputs.updated-release-notes-filepath }} diff --git a/scripts/fetch_release_notes_version_name.sh b/scripts/fetch_release_notes_version_name.sh deleted file mode 100755 index 1dde7b6..0000000 --- a/scripts/fetch_release_notes_version_name.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2024 Adyen N.V. -# -# This file is open source and available under the MIT license. See the LICENSE file for more info. -# -# Created by ozgur on 10/12/2024. -# -function fetch_release_notes_version_name() { - if [ "$#" -ne 1 ]; then - echo "Usage: $0 " >&2 - exit 1 - fi - commit_message=$1 - - # Extract the branch name - release_notes_branch_name=$(echo "$commit_message" | grep -oE 'release-notes.*') - - # Check if "release-notes" was found - if [[ -z "$release_notes_branch_name" ]]; then - echo "No part starting with 'release-notes' found in the string." >&2 - exit 1 - fi - - # Regex for version (starts with a version number like 1.2.3.md) - version_name_regex="[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}(-(alpha|beta|rc)[0-9]{2})?" - - # Extract the version name from the "release-notes" part - version_name=$(echo "$release_notes_branch_name" | grep -oE "$version_name_regex") - - # Check if version name was found - if [[ -z "$version_name" ]]; then - echo "Version cannot be extracted." >&2 - exit 1 - fi - - echo "$version_name" -} - -fetch_release_notes_version_name "$1" diff --git a/scripts/fetch_updated_release_notes_file.sh b/scripts/fetch_updated_release_notes_file.sh deleted file mode 100644 index f62b353..0000000 --- a/scripts/fetch_updated_release_notes_file.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2024 Adyen N.V. -# -# This file is open source and available under the MIT license. See the LICENSE file for more info. -# -# Created by ozgur on 10/12/2024. -# -function fetch_updated_release_notes_file() { - if [ "$#" -ne 2 ]; then - echo "Error: Not enough arguments. Usage: $0 " >&2 - exit 1 - fi - - directory=$1 - version_name=$2 - notes_file_name="${version_name}.md" - - # Search for matching files using the find command - file=$(ls -R "$directory" 2>/dev/null | grep -x "$notes_file_name") - if [[ -z "$file" ]]; then - echo "Release notes file is not found. Make sure release notes file with name ${notes_file_name} exists in the project root directory." >&2 - exit 1 - fi - if [[ "${directory: -1}" == "/" ]]; then - full_path="${directory}${file}" - else - full_path="${directory}/${file}" - fi - echo "$full_path" -} - -fetch_updated_release_notes_file $1 $2