diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml index 85d0310d8..7cd7266a1 100644 --- a/.github/workflows/publish_release.yml +++ b/.github/workflows/publish_release.yml @@ -2,7 +2,7 @@ name: Publish Release on: workflow_run: - workflows: ["Prepare Release"] + workflows: ["Tag Release"] types: - completed @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Read and increment version with TypeScript + - name: Read version id: increment_version uses: actions/github-script@v7 with: @@ -24,59 +24,6 @@ jobs: const version = packageJson.version; core.exportVariable('VERSION', version) - - name: Create tag - id: create_tag - run: | - # Check if the tag already exists in the remote repository - if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then - echo "Tag v${{ env.VERSION }} already exists." - else - # Create and push the new tag - git tag "v${{ env.VERSION }}" - git push origin "v${{ env.VERSION }}" - fi - - - name: Create a release - id: create_release - uses: actions/github-script@v7 - with: - script: | - const version = "${{ env.VERSION }}"; - - // Fetch the pull requests merged into the base branch (master) - const { data: pulls } = await github.rest.pulls.list({ - owner: context.repo.owner, - repo: context.repo.repo, - state: 'closed', - sort: 'updated', - direction: 'desc', - per_page: 1, - base: 'master', - }); - - if (pulls.length === 0) { - throw new Error('No pull requests merged into master were found.'); - } - - const lastPr = pulls[0]; - console.log(`Last PR found: ${lastPr.title} (#${lastPr.number})`); - - // Use the PR description for the release notes - const releaseBody = lastPr.body || 'No description provided for the last merged PR.'; - - // Create the release - const { data: release } = await github.rest.repos.createRelease({ - owner: context.repo.owner, - repo: context.repo.repo, - tag_name: `v${version}`, - name: `v${version} - ${lastPr.title}`, - body: releaseBody, - draft: false, - prerelease: false, - }); - - console.log(`Release created: ${release.html_url}`); - - name: Publish to GitHub Marketplace uses: actions/github-script@v7 with: diff --git a/.github/workflows/tag_release.yml b/.github/workflows/tag_release.yml new file mode 100644 index 000000000..a8bdc4f07 --- /dev/null +++ b/.github/workflows/tag_release.yml @@ -0,0 +1,78 @@ +name: Tag Release + +on: + workflow_run: + workflows: ["Prepare Release"] + types: + - completed + +jobs: + publish: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + name: Publish version + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Read version + id: increment_version + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8')); + const version = packageJson.version; + core.exportVariable('VERSION', version) + + - name: Create tag + id: create_tag + run: | + # Check if the tag already exists in the remote repository + if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then + echo "Tag v${{ env.VERSION }} already exists." + else + # Create and push the new tag + git tag "v${{ env.VERSION }}" + git push origin "v${{ env.VERSION }}" + fi + + - name: Create a release + id: create_release + uses: actions/github-script@v7 + with: + script: | + const version = "${{ env.VERSION }}"; + + // Fetch the pull requests merged into the base branch (master) + const { data: pulls } = await github.rest.pulls.list({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'closed', + sort: 'updated', + direction: 'desc', + per_page: 1, + base: 'master', + }); + + if (pulls.length === 0) { + throw new Error('No pull requests merged into master were found.'); + } + + const lastPr = pulls[0]; + console.log(`Last PR found: ${lastPr.title} (#${lastPr.number})`); + + // Use the PR description for the release notes + const releaseBody = lastPr.body || 'No description provided for the last merged PR.'; + + // Create the release + const { data: release } = await github.rest.repos.createRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + tag_name: `v${version}`, + name: `v${version} - ${lastPr.title}`, + body: releaseBody, + draft: false, + prerelease: false, + }); + + console.log(`Release created: ${release.html_url}`);