From a125920aef0b2b740b088e6c3e1839bd5eca90d5 Mon Sep 17 00:00:00 2001 From: Vaclav Petras Date: Tue, 24 May 2022 12:12:35 -0400 Subject: [PATCH 1/2] CI: Add test run for release workflow * Run the create release workflow for PRs and on branches, too, for testing puproses, but exclude the release-only steps one by one. (Not even expression syntax is not checked when workflow does not run.) * Upload artifacts always since now it runs for non-release commits as well. * Fix expression syntax: Use single quotes for a string. * Run only for selected paths for PRs, run always for selected branches and all tags. * Don't use tags in the git log release notes test in additional checks because there for tags, this would be the same tag and so no difference (although the workflow now runs only for branches, not tags). --- .github/workflows/additional_checks.yml | 6 +++--- .github/workflows/create_release_draft.yml | 25 ++++++++++++++++------ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.github/workflows/additional_checks.yml b/.github/workflows/additional_checks.yml index e91d80f5005..74f50a94f81 100644 --- a/.github/workflows/additional_checks.yml +++ b/.github/workflows/additional_checks.yml @@ -49,9 +49,9 @@ jobs: cd utils # Git works without any special permissions. # Using current branch or the branch against the PR is open. - # Using last tag as start (works for release branches) or last 30 commits - # (for main and PRs). End is the current (latest) commit. + # Using the last 30 commits (for branches, tags, and PRs). + # End is the current (latest) commit. python ./generate_release_notes.py log \ ${{ github.ref_name }} \ - $(git describe --abbrev=0 --tags || git rev-parse HEAD~30) \ + $(git rev-parse HEAD~30) \ "" diff --git a/.github/workflows/create_release_draft.yml b/.github/workflows/create_release_draft.yml index 7b684e1e03a..86fb24154bb 100644 --- a/.github/workflows/create_release_draft.yml +++ b/.github/workflows/create_release_draft.yml @@ -2,8 +2,18 @@ name: Create a release draft on: push: + branches: + - main + - releasebranch_* tags: - '**' + pull_request: + branches: + - main + - releasebranch_* + paths: + - '.github/**' + - 'utils/**' jobs: build: @@ -24,8 +34,9 @@ jobs: git add core_modules_with_last_commit.json git diff --cached > core_modules_with_last_commit.patch - - name: Create new release draft + - name: Create new release draft (for tags only) id: create_release + if: startsWith(github.ref, 'refs/tags/') uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -37,9 +48,10 @@ jobs: - First change - Second change draft: true - prerelease: ${{ contains(github.ref, "RC") }} + prerelease: ${{ contains(github.ref, 'RC') }} - - name: Upload core_modules_with_last_commit.json file + - name: Upload core_modules_with_last_commit.json file (for tags only) + if: startsWith(github.ref, 'refs/tags/') uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ github.token }} @@ -49,7 +61,8 @@ jobs: asset_name: core_modules_with_last_commit.json asset_content_type: application/json - - name: Upload core_modules_with_last_commit.patch file + - name: Upload core_modules_with_last_commit.patch file (for tags only) + if: startsWith(github.ref, 'refs/tags/') uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ github.token }} @@ -59,9 +72,9 @@ jobs: asset_name: core_modules_with_last_commit.patch asset_content_type: text/plain - - name: On failure, make the created files available + - name: Make the created files available uses: actions/upload-artifact@v3 - if: failure() + if: always() with: name: artifacts path: | From 1fee76ce2e62dfec73d2f9cb2c3c334c4a69ee15 Mon Sep 17 00:00:00 2001 From: Vaclav Petras Date: Tue, 24 May 2022 17:44:59 -0400 Subject: [PATCH 2/2] Avoid confusion by adding 'check' into the workflow name --- .github/workflows/create_release_draft.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create_release_draft.yml b/.github/workflows/create_release_draft.yml index 86fb24154bb..2e6e6b53c96 100644 --- a/.github/workflows/create_release_draft.yml +++ b/.github/workflows/create_release_draft.yml @@ -1,4 +1,4 @@ -name: Create a release draft +name: Create or check a release draft on: push: