Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 2 additions & 55 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish Release

on:
workflow_run:
workflows: ["Prepare Release"]
workflows: ["Tag Release"]
types:
- completed

Expand All @@ -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:
Expand All @@ -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:
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/tag_release.yml
Original file line number Diff line number Diff line change
@@ -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}`);