name: Release Dry Run
on:
pull_request:
branches: [main, dev]
workflow_dispatch:
permissions:
contents: read
pull-requests: write
concurrency:
group: release-dry-run-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
dry-run:
name: Semantic Release Dry Run
runs-on: ubuntu-latest
env:
TARGET_BRANCH: ${{ github.base_ref || github.ref_name }}
steps:
- name: Checkout PR head
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
run: npm install --no-audit --no-fund
- name: Ensure local bootstrap tag
run: |
if git rev-parse v0.0.0 >/dev/null 2>&1; then
echo "Local v0.0.0 tag exists"
else
first_commit=$(git rev-list --max-parents=0 HEAD)
git tag v0.0.0 "$first_commit"
echo "Created local v0.0.0 tag at $first_commit for dry-run"
fi
- name: Run semantic-release dry-run
id: dry_run
env:
DRY_RUN_SUMMARY_FILE: semantic-release-summary.txt
run: node scripts/semantic-release-dry-run.mjs
- name: Comment dry-run result on PR
if: always() && github.event_name == 'pull_request'
uses: actions/github-script@v7
env:
DRY_RUN_OUTCOME: ${{ steps.dry_run.outcome }}
with:
script: |
const fs = require("fs");
const marker = "<!-- semantic-release-dry-run -->";
const summaryPath = "semantic-release-summary.txt";
let summary = "No summary produced.";
if (fs.existsSync(summaryPath)) {
summary = fs.readFileSync(summaryPath, "utf8").trim();
}
const body = `${marker}
### Semantic Release Dry Run
Status: \`${process.env.DRY_RUN_OUTCOME}\`
${summary}
`;
const issue_number = context.payload.pull_request.number;
const { owner, repo } = context.repo;
const comments = await github.paginate(github.rest.issues.listComments, {
owner,
repo,
issue_number,
per_page: 100
});
const existing = comments.find(
(c) => c.user.type === "Bot" && c.body && c.body.includes(marker)
);
if (existing) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: existing.id,
body
});
} else {
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body
});
}