From 2b9d52875bc93c51a580513e534e12f96a7e824f Mon Sep 17 00:00:00 2001 From: David Tesar Date: Thu, 7 Mar 2024 11:50:24 -0800 Subject: [PATCH 1/3] Change logic for only one file Signed-off-by: David Tesar --- .github/workflows/release.yaml | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 25d324c5c96..6ecd14c66d0 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -6,6 +6,7 @@ on: - main paths: - 'CHANGELOG/*.md' + workflow_dispatch: permissions: # added using https://github.com/step-security/secure-repo contents: read @@ -33,19 +34,17 @@ jobs: - name: Get release version id: release-version run: | - if [[ ${{ steps.changed-files.outputs.all_changed_files_count }} != 1 ]]; then - echo "1 release notes file should be changed to create a release tag, found ${{ steps.changed-files.outputs.all_changed_files_count }}" - exit 1 - fi for changed_file in ${{ steps.changed-files.outputs.all_changed_files }}; do - export RELEASE_VERSION=$(echo "${changed_file}" | grep -oP '(?<=/)[^/]+(?=\.md)') - echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV - echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT - if [[ "$RELEASE_VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then - echo "Valid semver: $RELEASE_VERSION" - else - echo "Invalid semver: $RELEASE_VERSION" - exit 1 + if [[ $changed_file =~ CHANGELOG/.*\.md ]]; then + export RELEASE_VERSION=$(echo "${changed_file}" | grep -oP '(?<=/)[^/]+(?=\.md)') + echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV + echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT + if [[ "$RELEASE_VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then + echo "Valid semver: $RELEASE_VERSION" + else + echo "Invalid semver: $RELEASE_VERSION" + exit 1 + fi fi done - name: Determine the release branch to use From eb0e9868591f4313d2cd5a462064c993830d8e02 Mon Sep 17 00:00:00 2001 From: David Tesar Date: Thu, 7 Mar 2024 14:18:55 -0800 Subject: [PATCH 2/3] Filter proper changed files Signed-off-by: David Tesar --- .github/workflows/release.yaml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6ecd14c66d0..01a5b14eac7 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -6,7 +6,6 @@ on: - main paths: - 'CHANGELOG/*.md' - workflow_dispatch: permissions: # added using https://github.com/step-security/secure-repo contents: read @@ -31,20 +30,25 @@ jobs: - name: Get changed files id: changed-files uses: tj-actions/changed-files@800a2825992141ddde1a8bca8ad394cec34d3188 # tag=v42.0.5 + with: + files: | + 'CHANGELOG/**.md' - name: Get release version id: release-version run: | + if [[ ${{ steps.changed-files.outputs.all_changed_files_count }} != 1 ]]; then + echo "1 release notes file should be changed to create a release tag, found ${{ steps.changed-files.outputs.all_changed_files_count }}" + exit 1 + fi for changed_file in ${{ steps.changed-files.outputs.all_changed_files }}; do - if [[ $changed_file =~ CHANGELOG/.*\.md ]]; then - export RELEASE_VERSION=$(echo "${changed_file}" | grep -oP '(?<=/)[^/]+(?=\.md)') - echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV - echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT - if [[ "$RELEASE_VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then - echo "Valid semver: $RELEASE_VERSION" - else - echo "Invalid semver: $RELEASE_VERSION" - exit 1 - fi + export RELEASE_VERSION=$(echo "${changed_file}" | grep -oP '(?<=/)[^/]+(?=\.md)') + echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV + echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT + if [[ "$RELEASE_VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then + echo "Valid semver: $RELEASE_VERSION" + else + echo "Invalid semver: $RELEASE_VERSION" + exit 1 fi done - name: Determine the release branch to use From 663d4185eeba98f9153684bfe8a7f79a490ab4f6 Mon Sep 17 00:00:00 2001 From: David Tesar Date: Fri, 8 Mar 2024 17:53:11 -0800 Subject: [PATCH 3/3] Fix logic Signed-off-by: David Tesar --- .github/workflows/release.yaml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 01a5b14eac7..ba413ca3491 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -28,19 +28,18 @@ jobs: with: fetch-depth: 0 - name: Get changed files - id: changed-files + id: changed-markdown-files uses: tj-actions/changed-files@800a2825992141ddde1a8bca8ad394cec34d3188 # tag=v42.0.5 with: - files: | - 'CHANGELOG/**.md' + files: CHANGELOG/**.md - name: Get release version id: release-version run: | - if [[ ${{ steps.changed-files.outputs.all_changed_files_count }} != 1 ]]; then - echo "1 release notes file should be changed to create a release tag, found ${{ steps.changed-files.outputs.all_changed_files_count }}" + if [[ ${{ steps.changed-markdown-files.outputs.all_changed_files_count }} != 1 ]]; then + echo "1 release notes file should be changed to create a release tag, found ${{ steps.changed-markdown-files.outputs.all_changed_files_count }}" exit 1 fi - for changed_file in ${{ steps.changed-files.outputs.all_changed_files }}; do + for changed_file in ${{ steps.changed-markdown-files.outputs.all_changed_files }}; do export RELEASE_VERSION=$(echo "${changed_file}" | grep -oP '(?<=/)[^/]+(?=\.md)') echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT @@ -124,4 +123,4 @@ jobs: draft: true files: out/* body_path: ${{ env.RELEASE_TAG }}.md - tag_name: ${{ env.RELEASE_TAG }} + tag_name: ${{ env.RELEASE_TAG }} \ No newline at end of file