From c479e81b23f7e864ee551e71e6d7e842e390ce3a Mon Sep 17 00:00:00 2001 From: miroslavpojer Date: Thu, 1 Aug 2024 11:01:12 +0200 Subject: [PATCH 1/4] - Improvement of release draft creation. --- .github/workflows/release_draft.yml | 72 ++++++++++++++++------------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/.github/workflows/release_draft.yml b/.github/workflows/release_draft.yml index a849ab4..fd53619 100644 --- a/.github/workflows/release_draft.yml +++ b/.github/workflows/release_draft.yml @@ -23,8 +23,9 @@ on: required: true jobs: - tag: + check-tag: runs-on: ubuntu-latest + name: Check tag steps: - uses: actions/checkout@v4 with: @@ -55,11 +56,14 @@ jobs: repo: context.repo.repo, ref: 'tags/' }); - console.log(`Existing tags: ${refs.map(ref => ref.ref.replace('refs/tags/', '')).join(', ')}`); - const latestTag = refs.sort((a, b) => new Date(b.object.date) - new Date(a.object.date))[0].ref.replace('refs/tags/', ''); - console.log(`Latest tag: ${latestTag}`); + if (refs.length === 0) { + // No existing tags, so any new tag is valid + console.log('No existing tags found. Any new tag is considered valid.'); + return; + } + const latestTag = refs.sort((a, b) => new Date(b.object.date) - new Date(a.object.date))[0].ref.replace('refs/tags/', ''); const latestVersion = latestTag.replace('v', '').split('.').map(Number); const newVersion = newTag.replace('v', '').split('.').map(Number); @@ -75,33 +79,17 @@ jobs: tag-name: ${{ github.event.inputs.tagName }} - - name: Create and push tag - uses: actions/github-script@v7 - with: - script: | - const tag = core.getInput('tag-name') - const ref = `refs/tags/${tag}`; - const sha = context.sha; // The SHA of the commit to tag - - await github.rest.git.createRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: ref, - sha: sha - }); - - console.log(`Tag created: ${tag}`); - github-token: ${{ secrets.GITHUB_TOKEN }} - tag-name: ${{ github.event.inputs.tagName }} - - release: - needs: tag + generate-release-notes: + needs: check-tag runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - ref: refs/tags/${{ github.event.inputs.tagName }} + + - uses: actions/setup-python@v5.1.1 + with: + python-version: '3.11' - name: Generate release notes id: generate_release_notes @@ -110,22 +98,40 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag-name: ${{ github.event.inputs.tagName }} - chapters: | - [ + chapters: '[ {"title": "Breaking Changes 💥", "label": "breaking-change"}, {"title": "New Features 🎉", "label": "feature"}, {"title": "New Features 🎉", "label": "enhancement"}, {"title": "Bugfixes 🛠", "label": "bug"} - ] + ]' warnings: true - - name: Create draft release + - name: Create and Push Tag + uses: actions/github-script@v7 + with: + script: | + const tag = core.getInput('tag-name') + const ref = `refs/tags/${tag}`; + const sha = context.sha; // The SHA of the commit to tag + + await github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: ref, + sha: sha + }); + + console.log(`Tag created: ${tag}`); + github-token: ${{ secrets.GITHUB_TOKEN }} + tag-name: ${{ github.event.inputs.tag-name }} + + - name: Create Draft Release uses: softprops/action-gh-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - name: ${{ github.event.inputs.tagName }} - body: ${{ steps.generate_release_notes.outputs.releaseNotes }} - tag_name: ${{ github.event.inputs.tagName }} + name: ${{ github.event.inputs.tag-name }} + body: ${{ steps.generate_release_notes.outputs.release-notes }} + tag_name: ${{ github.event.inputs.tag-name }} draft: true prerelease: false From efcfaca731f9f422b7fddc5f39ef2a953e6d3e3a Mon Sep 17 00:00:00 2001 From: miroslavpojer Date: Thu, 1 Aug 2024 13:16:18 +0200 Subject: [PATCH 2/4] - Debugging a source of problem. --- .github/workflows/release_draft.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release_draft.yml b/.github/workflows/release_draft.yml index fd53619..75c295f 100644 --- a/.github/workflows/release_draft.yml +++ b/.github/workflows/release_draft.yml @@ -61,6 +61,8 @@ jobs: // No existing tags, so any new tag is valid console.log('No existing tags found. Any new tag is considered valid.'); return; + } else { + console.log(`Existing tags: ${refs.map(ref => ref.ref.replace('refs/tags/', '')).join(', ')}`); } const latestTag = refs.sort((a, b) => new Date(b.object.date) - new Date(a.object.date))[0].ref.replace('refs/tags/', ''); From a9c5727979f8b606b7ba909ee3b70760ef0647e7 Mon Sep 17 00:00:00 2001 From: miroslavpojer Date: Thu, 1 Aug 2024 13:28:01 +0200 Subject: [PATCH 3/4] - Fix correct input name. --- .github/workflows/release_draft.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release_draft.yml b/.github/workflows/release_draft.yml index 75c295f..72bee14 100644 --- a/.github/workflows/release_draft.yml +++ b/.github/workflows/release_draft.yml @@ -18,7 +18,7 @@ name: Release - create draft release on: workflow_dispatch: inputs: - tagName: + tag-name: description: 'Name of git tag to be created, and then draft release created. Syntax: "v[0-9]+.[0-9]+.[0-9]+".' required: true @@ -42,7 +42,7 @@ jobs: core.setFailed('Tag does not match the required format "v[0-9]+.[0-9]+.[0-9]+"'); return; } - tag-name: ${{ github.event.inputs.tagName }} + tag-name: ${{ github.event.inputs.tag-name }} - name: Check tag's correct version increment uses: actions/github-script@v7 @@ -79,7 +79,7 @@ jobs: return; } - tag-name: ${{ github.event.inputs.tagName }} + tag-name: ${{ github.event.inputs.tag-name }} generate-release-notes: needs: check-tag @@ -99,7 +99,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag-name: ${{ github.event.inputs.tagName }} + tag-name: ${{ github.event.inputs.tag-name }} chapters: '[ {"title": "Breaking Changes 💥", "label": "breaking-change"}, {"title": "New Features 🎉", "label": "feature"}, From 43bfbe09fadda7fed5fa6cca4856fc757abb2a4c Mon Sep 17 00:00:00 2001 From: miroslavpojer Date: Thu, 1 Aug 2024 14:14:25 +0200 Subject: [PATCH 4/4] - Add required values for publish. --- action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/action.yml b/action.yml index ed2f08a..ced26cb 100644 --- a/action.yml +++ b/action.yml @@ -30,6 +30,11 @@ outputs: report-path: description: "Path to the generated report file. Not used when 'console' is selected as the report format." value: ${{ steps.filename-inspector.outputs.report-path }} + +branding: + icon: 'book' + color: 'yellow' + runs: using: 'composite' steps: